-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 | |||
@@ -924,148 +924,158 @@ void Keys::setKeysFromFile(const char * filename) { | |||
924 | 924 | ||
925 | } | 925 | } |
926 | // have to close that facker up | 926 | // have to close that facker up |
927 | ((char *)xpm[xpmLineCount])[j] = '\0'; | 927 | ((char *)xpm[xpmLineCount])[j] = '\0'; |
928 | 928 | ||
929 | xpmLineCount++; | 929 | xpmLineCount++; |
930 | buf = t.readLine(); | 930 | buf = t.readLine(); |
931 | } | 931 | } |
932 | if (xpmLineCount) { | 932 | if (xpmLineCount) { |
933 | 933 | ||
934 | xpm2pix = new QPixmap((const char **)xpm); | 934 | xpm2pix = new QPixmap((const char **)xpm); |
935 | for (int i = 0; i < xpmLineCount; i++) | 935 | for (int i = 0; i < xpmLineCount; i++) |
936 | 936 | ||
937 | delete [] (xpm[i]); | 937 | delete [] (xpm[i]); |
938 | 938 | ||
939 | } | 939 | } |
940 | setKey(row, qcode, unicode, width, xpm2pix); | 940 | setKey(row, qcode, unicode, width, xpm2pix); |
941 | } | 941 | } |
942 | 942 | ||
943 | // shift map | 943 | // shift map |
944 | else if (buf.contains(QRegExp("^[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { | 944 | else if (buf.contains(QRegExp("^[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { |
945 | 945 | ||
946 | QTextStream tmp (buf, IO_ReadOnly); | 946 | QTextStream tmp (buf, IO_ReadOnly); |
947 | ushort lower, shift; | 947 | ushort lower, shift; |
948 | tmp >> lower >> shift; | 948 | tmp >> lower >> shift; |
949 | 949 | ||
950 | shiftMap.insert(lower, shift); | 950 | shiftMap.insert(lower, shift); |
951 | 951 | ||
952 | buf = t.readLine(); | 952 | buf = t.readLine(); |
953 | } | 953 | } |
954 | 954 | ||
955 | // other variables like lang & title | 955 | // other variables like lang & title |
956 | else if (buf.contains(QRegExp("^\\s*[a-zA-Z]+\\s*=\\s*[a-zA-Z0-9/]+\\s*$", FALSE, FALSE))) { | 956 | else if (buf.contains(QRegExp("^\\s*[a-zA-Z]+\\s*=\\s*[a-zA-Z0-9/]+\\s*$", FALSE, FALSE))) { |
957 | 957 | ||
958 | QTextStream tmp (buf, IO_ReadOnly); | 958 | QTextStream tmp (buf, IO_ReadOnly); |
959 | QString name, equals, value; | 959 | QString name, equals, value; |
960 | 960 | ||
961 | tmp >> name >> equals >> value; | 961 | tmp >> name >> equals >> value; |
962 | 962 | ||
963 | if (name == "lang") { | 963 | if (name == "lang") { |
964 | 964 | ||
965 | lang = value; | 965 | lang = value; |
966 | 966 | ||
967 | } | 967 | } |
968 | 968 | ||
969 | buf = t.readLine(); | 969 | buf = t.readLine(); |
970 | } | 970 | } |
971 | // comments | 971 | // comments |
972 | else if (buf.contains(QRegExp("^\\s*#"))) { | 972 | else if (buf.contains(QRegExp("^\\s*#"))) { |
973 | 973 | ||
974 | buf = t.readLine(); | 974 | buf = t.readLine(); |
975 | 975 | ||
976 | } else { // blank line, or garbage | 976 | } else { // blank line, or garbage |
977 | 977 | ||
978 | buf = t.readLine(); | 978 | buf = t.readLine(); |
979 | 979 | ||
980 | } | 980 | } |
981 | 981 | ||
982 | } | 982 | } |
983 | f.close(); | 983 | f.close(); |
984 | } | 984 | } |
985 | 985 | ||
986 | } | 986 | } |
987 | 987 | ||
988 | // Keys::setKey {{{2 | 988 | // Keys::setKey {{{2 |
989 | void Keys::setKey(const int row, const int qcode, const ushort unicode, | 989 | void Keys::setKey(const int row, const int qcode, const ushort unicode, |
990 | const int width, QPixmap *pix) { | 990 | const int width, QPixmap *pix) { |
991 | 991 | ||
992 | Key * key; | 992 | Key * key; |
993 | key = new Key; | 993 | key = new Key; |
994 | key->qcode = qcode; | 994 | key->qcode = qcode; |
995 | key->unicode = unicode; | 995 | key->unicode = 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 | ||
1044 | return *(keys[row].at(col)->pressed); | 1054 | return *(keys[row].at(col)->pressed); |
1045 | } | 1055 | } |
1046 | 1056 | ||
1047 | int Keys::numKeys(const int row) { | 1057 | int Keys::numKeys(const int row) { |
1048 | 1058 | ||
1049 | return keys[row].count(); | 1059 | return keys[row].count(); |
1050 | } | 1060 | } |
1051 | 1061 | ||
1052 | void Keys::setPressed(const int row, const int col, const bool pressed) { | 1062 | void Keys::setPressed(const int row, const int col, const bool pressed) { |
1053 | 1063 | ||
1054 | *(keys[row].at(col)->pressed) = pressed; | 1064 | *(keys[row].at(col)->pressed) = pressed; |
1055 | } | 1065 | } |
1056 | 1066 | ||
1057 | ushort Keys::shift(const ushort uni) { | 1067 | ushort Keys::shift(const ushort uni) { |
1058 | 1068 | ||
1059 | if (shiftMap[uni]) { | 1069 | if (shiftMap[uni]) { |
1060 | 1070 | ||
1061 | return shiftMap[uni]; | 1071 | return shiftMap[uni]; |
1062 | } | 1072 | } |
1063 | else | 1073 | else |
1064 | return 0; | 1074 | return 0; |
1065 | 1075 | ||
1066 | } | 1076 | } |
1067 | 1077 | ||
1068 | bool *Keys::pressedPtr(const int row, const int col) { | 1078 | bool *Keys::pressedPtr(const int row, const int col) { |
1069 | 1079 | ||
1070 | return keys[row].at(col)->pressed; | 1080 | return keys[row].at(col)->pressed; |
1071 | } | 1081 | } |
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 | |||
@@ -1,153 +1,154 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qframe.h> | 20 | #include <qframe.h> |
21 | #include <qmap.h> | 21 | #include <qmap.h> |
22 | #include "../pickboard/pickboardcfg.h" | 22 | #include "../pickboard/pickboardcfg.h" |
23 | #include "../pickboard/pickboardpicks.h" | 23 | #include "../pickboard/pickboardpicks.h" |
24 | #include "configdlg.h" | 24 | #include "configdlg.h" |
25 | 25 | ||
26 | class QTimer; | 26 | class QTimer; |
27 | 27 | ||
28 | class KeyboardConfig : public DictFilterConfig | 28 | class KeyboardConfig : public DictFilterConfig |
29 | { | 29 | { |
30 | public: | 30 | public: |
31 | KeyboardConfig(PickboardPicks* p) : DictFilterConfig(p), backspaces(0) { nrows = 1; } | 31 | KeyboardConfig(PickboardPicks* p) : DictFilterConfig(p), backspaces(0) { nrows = 1; } |
32 | virtual void generateText(const QString &s); | 32 | virtual void generateText(const QString &s); |
33 | void decBackspaces() { if (backspaces) backspaces--; } | 33 | void decBackspaces() { if (backspaces) backspaces--; } |
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; |
82 | QPixmap *pix; | 83 | QPixmap *pix; |
83 | }; | 84 | }; |
84 | 85 | ||
85 | QList<Key> keys[6]; | 86 | QList<Key> keys[6]; |
86 | QMap<ushort,ushort> shiftMap; | 87 | QMap<ushort,ushort> shiftMap; |
87 | 88 | ||
88 | }; | 89 | }; |
89 | 90 | ||
90 | class Keyboard : public QFrame | 91 | class Keyboard : public QFrame |
91 | { | 92 | { |
92 | Q_OBJECT | 93 | Q_OBJECT |
93 | public: | 94 | public: |
94 | Keyboard( QWidget* parent=0, const char* name=0, WFlags f=0 ); | 95 | Keyboard( QWidget* parent=0, const char* name=0, WFlags f=0 ); |
95 | ~Keyboard(); | 96 | ~Keyboard(); |
96 | 97 | ||
97 | void resetState(); | 98 | void resetState(); |
98 | 99 | ||
99 | void mousePressEvent(QMouseEvent*); | 100 | void mousePressEvent(QMouseEvent*); |
100 | void mouseReleaseEvent(QMouseEvent*); | 101 | void mouseReleaseEvent(QMouseEvent*); |
101 | void resizeEvent(QResizeEvent*); | 102 | void resizeEvent(QResizeEvent*); |
102 | void paintEvent(QPaintEvent* e); | 103 | void paintEvent(QPaintEvent* e); |
103 | //void timerEvent(QTimerEvent* e); | 104 | //void timerEvent(QTimerEvent* e); |
104 | void drawKeyboard( QPainter &p, int row = -1, int col = -1); | 105 | void drawKeyboard( QPainter &p, int row = -1, int col = -1); |
105 | 106 | ||
106 | QSize sizeHint() const; | 107 | QSize sizeHint() const; |
107 | 108 | ||
108 | signals: | 109 | signals: |
109 | void key( ushort scancode, ushort unicode, ushort modifiers, bool, bool ); | 110 | void key( ushort scancode, ushort unicode, ushort modifiers, bool, bool ); |
110 | 111 | ||
111 | private slots: | 112 | private slots: |
112 | void repeat(); | 113 | void repeat(); |
113 | void togglePickboard(bool on_off); | 114 | void togglePickboard(bool on_off); |
114 | void setMapToDefault(); | 115 | void setMapToDefault(); |
115 | void setMapToFile(QString file); | 116 | void setMapToFile(QString file); |
116 | 117 | ||
117 | private: | 118 | private: |
118 | int getKey( int &w, int j = -1 ); | 119 | int getKey( int &w, int j = -1 ); |
119 | void clearHighlight(); | 120 | void clearHighlight(); |
120 | 121 | ||
121 | bool *shift; | 122 | bool *shift; |
122 | bool *lock; | 123 | bool *lock; |
123 | bool *ctrl; | 124 | bool *ctrl; |
124 | bool *alt; | 125 | bool *alt; |
125 | uint useLargeKeys:1; | 126 | uint useLargeKeys:1; |
126 | uint usePicks:1; | 127 | uint usePicks:1; |
127 | 128 | ||
128 | int pressedKeyRow; | 129 | int pressedKeyRow; |
129 | int pressedKeyCol; | 130 | int pressedKeyCol; |
130 | 131 | ||
131 | KeyboardPicks *picks; | 132 | KeyboardPicks *picks; |
132 | 133 | ||
133 | int keyHeight; | 134 | int keyHeight; |
134 | int defaultKeyWidth; | 135 | int defaultKeyWidth; |
135 | int xoffs; | 136 | int xoffs; |
136 | 137 | ||
137 | int unicode; | 138 | int unicode; |
138 | int qkeycode; | 139 | int qkeycode; |
139 | int modifiers; | 140 | int modifiers; |
140 | 141 | ||
141 | int pressTid; | 142 | int pressTid; |
142 | bool pressed; | 143 | bool pressed; |
143 | 144 | ||
144 | Keys *keys; | 145 | Keys *keys; |
145 | 146 | ||
146 | /* for korean input */ | 147 | /* for korean input */ |
147 | ushort schar, mchar, echar; | 148 | ushort schar, mchar, echar; |
148 | ushort parseKoreanInput(ushort c); | 149 | ushort parseKoreanInput(ushort c); |
149 | ushort combineKoreanChars(const ushort s, const ushort m, const ushort e); | 150 | ushort combineKoreanChars(const ushort s, const ushort m, const ushort e); |
150 | ushort constoe(const ushort c); | 151 | ushort constoe(const ushort c); |
151 | 152 | ||
152 | QTimer *repeatTimer; | 153 | QTimer *repeatTimer; |
153 | 154 | ||