-rw-r--r-- | inputmethods/multikey/keyboard.cpp | 10 | ||||
-rw-r--r-- | inputmethods/multikey/keyboard.h | 1 |
2 files changed, 11 insertions, 0 deletions
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp index b71f929..671868c 100644 --- a/inputmethods/multikey/keyboard.cpp +++ b/inputmethods/multikey/keyboard.cpp | |||
@@ -996,48 +996,58 @@ void Keys::setKey(const int row, const int qcode, const ushort unicode, | |||
996 | key->width = width; | 996 | key->width = width; |
997 | 997 | ||
998 | // share key->pressed between same keys | 998 | // share key->pressed between same keys |
999 | bool found = 0; | 999 | bool found = 0; |
1000 | for (int i = 1; i <= 5; i++) { | 1000 | for (int i = 1; i <= 5; i++) { |
1001 | for (unsigned int j = 0; j < keys[i].count(); j++) | 1001 | for (unsigned int j = 0; j < keys[i].count(); j++) |
1002 | if (keys[i].at(j)->qcode == qcode && keys[i].at(j)->unicode == unicode) { | 1002 | if (keys[i].at(j)->qcode == qcode && keys[i].at(j)->unicode == unicode) { |
1003 | 1003 | ||
1004 | key->pressed = keys[i].at(j)->pressed; | 1004 | key->pressed = keys[i].at(j)->pressed; |
1005 | found = 1; | 1005 | found = 1; |
1006 | } | 1006 | } |
1007 | 1007 | ||
1008 | } | 1008 | } |
1009 | if (!found) { | 1009 | if (!found) { |
1010 | 1010 | ||
1011 | key->pressed = new bool; | 1011 | key->pressed = new bool; |
1012 | *(key->pressed) = 0; | 1012 | *(key->pressed) = 0; |
1013 | } | 1013 | } |
1014 | 1014 | ||
1015 | key->pix = pix; | 1015 | key->pix = pix; |
1016 | 1016 | ||
1017 | 1017 | ||
1018 | keys[row].append(key); | 1018 | keys[row].append(key); |
1019 | } | 1019 | } |
1020 | |||
1021 | // Keys::~Keys {{{2 | ||
1022 | Keys::~Keys() { | ||
1023 | |||
1024 | for (int i = 1; i <= 5; i++) | ||
1025 | for (unsigned int j = 0; j < keys[i].count(); j++) | ||
1026 | delete keys[i].at(j); | ||
1027 | |||
1028 | } | ||
1029 | |||
1020 | // Keys:: other functions {{{2 | 1030 | // Keys:: other functions {{{2 |
1021 | int Keys::width(const int row, const int col) { | 1031 | int Keys::width(const int row, const int col) { |
1022 | 1032 | ||
1023 | return keys[row].at(col)->width; | 1033 | return keys[row].at(col)->width; |
1024 | 1034 | ||
1025 | } | 1035 | } |
1026 | ushort Keys::uni(const int row, const int col) { | 1036 | ushort Keys::uni(const int row, const int col) { |
1027 | 1037 | ||
1028 | return keys[row].at(col)->unicode; | 1038 | return keys[row].at(col)->unicode; |
1029 | 1039 | ||
1030 | } | 1040 | } |
1031 | 1041 | ||
1032 | int Keys::qcode(const int row, const int col) { | 1042 | int Keys::qcode(const int row, const int col) { |
1033 | 1043 | ||
1034 | return keys[row].at(col)->qcode; | 1044 | return keys[row].at(col)->qcode; |
1035 | } | 1045 | } |
1036 | 1046 | ||
1037 | QPixmap *Keys::pix(const int row, const int col) { | 1047 | QPixmap *Keys::pix(const int row, const int col) { |
1038 | 1048 | ||
1039 | return keys[row].at(col)->pix; | 1049 | return keys[row].at(col)->pix; |
1040 | 1050 | ||
1041 | } | 1051 | } |
1042 | bool Keys::pressed(const int row, const int col) { | 1052 | bool Keys::pressed(const int row, const int col) { |
1043 | 1053 | ||
diff --git a/inputmethods/multikey/keyboard.h b/inputmethods/multikey/keyboard.h index 8ca50ea..400edc0 100644 --- a/inputmethods/multikey/keyboard.h +++ b/inputmethods/multikey/keyboard.h | |||
@@ -34,48 +34,49 @@ public: | |||
34 | void incBackspaces() { backspaces++; } | 34 | void incBackspaces() { backspaces++; } |
35 | void resetBackspaces() { backspaces = 0; } | 35 | void resetBackspaces() { backspaces = 0; } |
36 | private: | 36 | private: |
37 | int backspaces; | 37 | int backspaces; |
38 | }; | 38 | }; |
39 | 39 | ||
40 | 40 | ||
41 | class KeyboardPicks : public PickboardPicks | 41 | class KeyboardPicks : public PickboardPicks |
42 | { | 42 | { |
43 | Q_OBJECT | 43 | Q_OBJECT |
44 | public: | 44 | public: |
45 | KeyboardPicks(QWidget* parent=0, const char* name=0, WFlags f=0) | 45 | KeyboardPicks(QWidget* parent=0, const char* name=0, WFlags f=0) |
46 | : PickboardPicks(parent, name, f) { } | 46 | : PickboardPicks(parent, name, f) { } |
47 | void initialise(); | 47 | void initialise(); |
48 | virtual QSize sizeHint() const; | 48 | virtual QSize sizeHint() const; |
49 | KeyboardConfig *dc; | 49 | KeyboardConfig *dc; |
50 | }; | 50 | }; |
51 | 51 | ||
52 | 52 | ||
53 | class Keys { | 53 | class Keys { |
54 | public: | 54 | public: |
55 | 55 | ||
56 | Keys(); | 56 | Keys(); |
57 | Keys(const char * filename); | 57 | Keys(const char * filename); |
58 | ~Keys(); | ||
58 | ushort uni(const int row, const int col); | 59 | ushort uni(const int row, const int col); |
59 | int qcode(const int row, const int col); | 60 | int qcode(const int row, const int col); |
60 | int width(const int row, const int col); | 61 | int width(const int row, const int col); |
61 | bool pressed(const int row, const int col); | 62 | bool pressed(const int row, const int col); |
62 | bool *pressedPtr(const int row, const int col); | 63 | bool *pressedPtr(const int row, const int col); |
63 | ushort shift(const ushort); | 64 | ushort shift(const ushort); |
64 | QPixmap *pix(const int row, const int col); | 65 | QPixmap *pix(const int row, const int col); |
65 | int numKeys(const int row); | 66 | int numKeys(const int row); |
66 | void setKeysFromFile(const char *filename); | 67 | void setKeysFromFile(const char *filename); |
67 | void setKey(const int row, const int qcode, const ushort unicode, | 68 | void setKey(const int row, const int qcode, const ushort unicode, |
68 | const int width, QPixmap *pix); | 69 | const int width, QPixmap *pix); |
69 | void setPressed(const int row, const int col, const bool pressed); | 70 | void setPressed(const int row, const int col, const bool pressed); |
70 | QString lang; | 71 | QString lang; |
71 | QString title; | 72 | QString title; |
72 | 73 | ||
73 | private: | 74 | private: |
74 | 75 | ||
75 | typedef struct Key { | 76 | typedef struct Key { |
76 | int qcode; // are qt key codes just unicode values? | 77 | int qcode; // are qt key codes just unicode values? |
77 | ushort unicode; | 78 | ushort unicode; |
78 | int width; // not pixels but relative key width. normal key is 2 | 79 | int width; // not pixels but relative key width. normal key is 2 |
79 | 80 | ||
80 | // only needed for keys like ctrl that can have multiple keys pressed at once | 81 | // only needed for keys like ctrl that can have multiple keys pressed at once |
81 | bool *pressed; | 82 | bool *pressed; |