Open-Typer
Open source typewriting tutor program
Loading...
Searching...
No Matches
KeyboardLayout Class Reference

The KeyboardLayout class provides information about a keyboard layout. More...

#include "framework/keyboard/internal/KeyboardLayout.h"

Inheritance diagram for KeyboardLayout:
Collaboration diagram for KeyboardLayout:

Public Types

enum  Hand { Hand_Invalid = 0 , Hand_Left = -1 , Hand_Right = 1 }
 
enum  Finger {
  Finger_Invalid = 0 , Finger_LeftLittle = -5 , Finger_LeftRing = -4 , Finger_LeftMiddle = -3 ,
  Finger_LeftIndex = -2 , Finger_LeftThumb = -1 , Finger_RightThumb = 1 , Finger_RightIndex = 2 ,
  Finger_RightMiddle = 3 , Finger_RightRing = 4 , Finger_RightLittle = 5
}
 
enum  Row {
  Row_A = 0 , Row_B = 1 , Row_C = 2 , Row_D = 3 ,
  Row_E = 4
}
 

Signals

void layoutIdChanged (QString id)
 
void variantChanged (QString variant)
 
void rowBChanged (KeyboardRow row)
 
void rowCChanged (KeyboardRow row)
 
void rowDChanged (KeyboardRow row)
 
void rowEChanged (KeyboardRow row)
 

Public Member Functions

 KeyboardLayout (QObject *parent=nullptr)
 
 KeyboardLayout (QString id, QObject *parent=nullptr)
 
QString layoutId (void)
 
void setLayoutId (QString id)
 
QString variant (void)
 
void setVariant (QString variant)
 
KeyboardRow rowB (void)
 
KeyboardRow rowC (void)
 
KeyboardRow rowD (void)
 
KeyboardRow rowE (void)
 
Q_INVOKABLE Finger keyFinger (Row row, int id)
 
Q_INVOKABLE Hand fingerHand (Finger finger)
 
Q_INVOKABLE KeyboardRow characterKeys (QChar character)
 

Properties

QString layoutId
 
QString variant
 
QVariantList rowB
 
QVariantList rowC
 
QVariantList rowD
 
QVariantList rowE
 

Private Member Functions

void init (void)
 
void loadLayout (QString rawData, QString variantName)
 
QVariantList parse (QString data)
 
QString nestedData (int *pos, QString data, QString startToken, QString endToken)
 
QPair< QString, QString > keyText (QString id, bool *isDead=nullptr)
 
QPoint keyPos (QString keyId, KeyboardUtils::KeyType *type=nullptr)
 
void addKey (Key key, int x, int y)
 
Key findKeyInRow (QChar character, KeyboardRow row, int *id=nullptr, bool *isShifted=nullptr, bool *ok=nullptr)
 
Key findKey (QChar character, Row *row=nullptr, int *id=nullptr, bool *isShifted=nullptr, bool *ok=nullptr)
 
KeyboardUtils::KeyType getShiftKey (Row row, int id)
 

Private Attributes

QString m_layoutId
 
QString m_variant
 
KeyboardRow m_rowB
 
KeyboardRow m_rowC
 
KeyboardRow m_rowD
 
KeyboardRow m_rowE
 

Detailed Description

The KeyboardLayout class provides information about a keyboard layout.

Constructor & Destructor Documentation

◆ KeyboardLayout() [1/2]

KeyboardLayout::KeyboardLayout ( QObject *  parent = nullptr)
explicit

Constructs KeyboardLayout.

◆ KeyboardLayout() [2/2]

KeyboardLayout::KeyboardLayout ( QString  id,
QObject *  parent = nullptr 
)

Constructs KeyboardLayout with the given ID.

Member Function Documentation

◆ addKey()

void KeyboardLayout::addKey ( Key  key,
int  x,
int  y 
)
private

Adds a key to the layout.

◆ characterKeys()

KeyboardRow KeyboardLayout::characterKeys ( QChar  character)

Returns list of keys that should be used to compose the given character.
For example:
ó -> o + ´
Ď -> LShift + ´ (ˇ) + RShift + d
(on Slovak keyboard layout)

◆ findKey()

Key KeyboardLayout::findKey ( QChar  character,
Row *  row = nullptr,
int *  id = nullptr,
bool *  isShifted = nullptr,
bool *  ok = nullptr 
)
private

Returns the key with the given character.

Parameters
[out]isShiftedTrue if this key has to be composed using shift.
[out]okTrue if this key exists.

◆ findKeyInRow()

Key KeyboardLayout::findKeyInRow ( QChar  character,
KeyboardRow  row,
int *  id = nullptr,
bool *  isShifted = nullptr,
bool *  ok = nullptr 
)
private

Returns the key with the given character in (from the given row).

Parameters
[out]isShiftedTrue if this key has to be composed using shift.
[out]okTrue if this key exists.

◆ fingerHand()

KeyboardLayout::Hand KeyboardLayout::fingerHand ( Finger  finger)

Returns the hand of the given finger.

◆ getShiftKey()

KeyboardUtils::KeyType KeyboardLayout::getShiftKey ( Row  row,
int  id 
)
private

Returns the shift key that should be used with the given key.

◆ init()

void KeyboardLayout::init ( void  )
private

Initializes the keyboard layout (reads all keys from xkeyboard-config).

◆ keyFinger()

KeyboardLayout::Finger KeyboardLayout::keyFinger ( Row  row,
int  id 
)

Returns the finger which should be used for the given key (id starts with 0).

◆ keyPos()

QPoint KeyboardLayout::keyPos ( QString  keyId,
KeyboardUtils::KeyType *  type = nullptr 
)
private

Returns the position of the key (key - left to right, row - bottom to top, ).
Optionally gets key type.

◆ keyText()

QPair< QString, QString > KeyboardLayout::keyText ( QString  id,
bool *  isDead = nullptr 
)
private

Converts key ID (e. g. "backslash" or "bracketleft") to unicode representation of the key (key text and readable text that should be displayed on the keyboard).

◆ loadLayout()

void KeyboardLayout::loadLayout ( QString  rawData,
QString  variantName 
)
private

Loads keyboard layout from the given text.

◆ nestedData()

QString KeyboardLayout::nestedData ( int *  pos,
QString  data,
QString  startToken,
QString  endToken 
)
private

Returns text nested in brackets.

◆ parse()

QVariantList KeyboardLayout::parse ( QString  data)
private

Reads keyboard layout configuration.

Property Documentation

◆ layoutId

QString KeyboardLayout::layoutId
readwrite

The layout ID, for example "de" for the German keyboard.

◆ rowB

KeyboardRow KeyboardLayout::rowB
read

Row B (shift, backslash, y/z, x, c, etc.)

◆ rowC

KeyboardRow KeyboardLayout::rowC
read

Row C (caps lock, a, s, d, f, etc.)

◆ rowD

KeyboardRow KeyboardLayout::rowD
read

Row D (tab, q, w, e, r, t, z/y, etc.)

◆ rowE

KeyboardRow KeyboardLayout::rowE
read

Row E (tilde, 1, 2, 3, 4, 5, etc.)

◆ variant

QString KeyboardLayout::variant
readwrite

The layout variant, for example "basic" or "qwerty".


The documentation for this class was generated from the following files: