summaryrefslogtreecommitdiff
path: root/inputmethods
Unidiff
Diffstat (limited to 'inputmethods') (more/less context) (show whitespace changes)
-rw-r--r--inputmethods/multikey/keyboard.cpp19
-rw-r--r--inputmethods/multikey/keyboard.h6
2 files changed, 13 insertions, 12 deletions
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp
index e3d3928..3f6f73b 100644
--- a/inputmethods/multikey/keyboard.cpp
+++ b/inputmethods/multikey/keyboard.cpp
@@ -132,166 +132,167 @@ void KeyboardConfig::generateText(const QString &s)
132 for (int i=0; i<(int)backspaces; i++) { 132 for (int i=0; i<(int)backspaces; i++) {
133 parent->emitKey( 0, Qt::Key_Backspace, 0, true, false ); 133 parent->emitKey( 0, Qt::Key_Backspace, 0, true, false );
134 parent->emitKey( 0, Qt::Key_Backspace, 0, false, false ); 134 parent->emitKey( 0, Qt::Key_Backspace, 0, false, false );
135 } 135 }
136 for (int i=0; i<(int)s.length(); i++) { 136 for (int i=0; i<(int)s.length(); i++) {
137 parent->emitKey( s[i].unicode(), 0, 0, true, false ); 137 parent->emitKey( s[i].unicode(), 0, 0, true, false );
138 parent->emitKey( s[i].unicode(), 0, 0, false, false ); 138 parent->emitKey( s[i].unicode(), 0, 0, false, false );
139 } 139 }
140 parent->emitKey( 0, Qt::Key_Space, 0, true, false ); 140 parent->emitKey( 0, Qt::Key_Space, 0, true, false );
141 parent->emitKey( 0, Qt::Key_Space, 0, false, false ); 141 parent->emitKey( 0, Qt::Key_Space, 0, false, false );
142 backspaces = 0; 142 backspaces = 0;
143#endif 143#endif
144} 144}
145 145
146 146
147 147
148 148
149/* Keyboard::paintEvent {{{1 */ 149/* Keyboard::paintEvent {{{1 */
150void Keyboard::paintEvent(QPaintEvent* e) 150void Keyboard::paintEvent(QPaintEvent* e)
151{ 151{
152 QPainter painter(this); 152 QPainter painter(this);
153 painter.setClipRect(e->rect()); 153 painter.setClipRect(e->rect());
154 drawKeyboard( painter ); 154 drawKeyboard( painter );
155 picks->dc->draw( &painter ); 155 picks->dc->draw( &painter );
156} 156}
157 157
158 158
159/* Keyboard::drawKeyboard {{{1 */ 159/* Keyboard::drawKeyboard {{{1 */
160 160
161void Keyboard::drawKeyboard(QPainter &p, int row, int col) 161void Keyboard::drawKeyboard(QPainter &p, int row, int col)
162{ 162{
163 163
164 164
165 if (row != -1 && col != -1) { //just redraw one key 165 if (row != -1 && col != -1) { //just redraw one key
166 166
167 int x = 0; 167 int x = 0;
168 for (int i = 0; i < col; i++) { 168 for (int i = 0; i < col; i++) {
169 169
170 x += keys->width(row, i) * defaultKeyWidth; 170 x += keys->width(row, i) * defaultKeyWidth;
171 } 171 }
172 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); 172 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0);
173 173
174 int keyWidth = keys->width(row, col); 174 int keyWidth = keys->width(row, col);
175 175
176 p.fillRect(x + 1, y + 1, 176 p.fillRect(x + 1, y + 1,
177 keyWidth * defaultKeyWidth - 1, keyHeight - 1, 177 keyWidth * defaultKeyWidth - 1, keyHeight - 1,
178 pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor); 178 pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor);
179 179
180 QPixmap *pix = keys->pix(row,col); 180 QImage *pix = keys->pix(row,col);
181 181
182 ushort c = keys->uni(row, col); 182 ushort c = keys->uni(row, col);
183 183
184 p.setPen(textcolor); 184 p.setPen(textcolor);
185 if (!pix) { 185 if (!pix) {
186 if (shift || lock) 186 if (shift || lock)
187 c = keys->shift(c); 187 c = keys->shift(c);
188 if (meta) { 188 if (meta) {
189 189
190 c = keys->meta(c); 190 c = keys->meta(c);
191 } 191 }
192 p.drawText(x, y, 192 p.drawText(x, y,
193 defaultKeyWidth * keyWidth + 3, keyHeight, 193 defaultKeyWidth * keyWidth + 3, keyHeight,
194 AlignCenter, (QChar)c); 194 AlignCenter, (QChar)c);
195 } 195 }
196 else 196 else
197 // center the image in the middle of the key 197 // center the image in the middle of the key
198 p.drawPixmap( x + (defaultKeyWidth * keyWidth - pix->width())/2, 198 p.drawImage( x + (defaultKeyWidth * keyWidth - pix->width())/2,
199 y + (keyHeight - pix->height())/2 + 1, 199 y + (keyHeight - pix->height())/2 + 1,
200 *pix ); 200 *pix );
201 201
202 // this fixes the problem that the very right end of the board's vertical line 202 // this fixes the problem that the very right end of the board's vertical line
203 // gets painted over, because it's one pixel shorter than all other keys 203 // gets painted over, because it's one pixel shorter than all other keys
204 p.setPen(keycolor_lines); 204 p.setPen(keycolor_lines);
205 p.drawLine(width() - 1, 0, width() - 1, height()); 205 p.drawLine(width() - 1, 0, width() - 1, height());
206 206
207 } else { 207 } else {
208 208
209 209
210 p.fillRect(0, 0, width(), height(), keycolor); 210 p.fillRect(0, 0, width(), height(), keycolor);
211 211
212 for (row = 1; row <= 5; row++) { 212 for (row = 1; row <= 5; row++) {
213 213
214 int x = 0; 214 int x = 0;
215 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); 215 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0);
216 216
217 p.setPen(keycolor_lines); 217 p.setPen(keycolor_lines);
218 p.drawLine(x, y, x + width(), y); 218 p.drawLine(x, y, x + width(), y);
219 219
220 for (int col = 0; col < keys->numKeys(row); col++) { 220 for (int col = 0; col < keys->numKeys(row); col++) {
221 221
222 QPixmap *pix = keys->pix(row, col); 222 QImage *pix = keys->pix(row, col);
223 int keyWidth = keys->width(row, col); 223 int keyWidth = keys->width(row, col);
224 224
225 225
226 int keyWidthPix = defaultKeyWidth * keyWidth; 226 int keyWidthPix = defaultKeyWidth * keyWidth;
227 227
228 if (keys->pressed(row, col)) 228 if (keys->pressed(row, col))
229 p.fillRect(x+1, y+1, keyWidthPix - 1, 229 p.fillRect(x+1, y+1, keyWidthPix - 1,
230 keyHeight - 1, keycolor_pressed); 230 keyHeight - 1, keycolor_pressed);
231 231
232 ushort c = keys->uni(row, col); 232 ushort c = keys->uni(row, col);
233 233
234 p.setPen(textcolor); 234 p.setPen(textcolor);
235 if (!pix) { 235 if (!pix) {
236 if ((shift || lock) && keys->shift(c)) 236 if ((shift || lock) && keys->shift(c))
237 c = keys->shift(c); 237 c = keys->shift(c);
238 else if (meta && keys->meta(c)) 238 else if (meta && keys->meta(c))
239 c = keys->meta(c); 239 c = keys->meta(c);
240 240
241 p.drawText(x, y, 241 p.drawText(x, y,
242 keyWidthPix + 3, keyHeight, 242 keyWidthPix + 3, keyHeight,
243 AlignCenter, (QChar)c); 243 AlignCenter, (QChar)c);
244 } 244 }
245 else { 245 else {
246 // center the image in the middle of the key 246 // center the image in the middle of the key
247 p.drawPixmap( x + (keyWidthPix - pix->width())/2, 247 pix->setColor(1, textcolor.rgb());
248 p.drawImage( x + (keyWidthPix - pix->width())/2,
248 y + (keyHeight - pix->height())/2 + 1, 249 y + (keyHeight - pix->height())/2 + 1,
249 QPixmap(*pix) ); 250 QImage(*pix) );
250 } 251 }
251 252
252 p.setPen(keycolor_lines); 253 p.setPen(keycolor_lines);
253 p.drawLine(x, y, x, y + keyHeight); 254 p.drawLine(x, y, x, y + keyHeight);
254 255
255 x += keyWidthPix; 256 x += keyWidthPix;
256 } 257 }
257 258
258 259
259 } 260 }
260 p.setPen(keycolor_lines); 261 p.setPen(keycolor_lines);
261 p.drawLine(0, height() - 1, width(), height() - 1); 262 p.drawLine(0, height() - 1, width(), height() - 1);
262 p.drawLine(width() - 1, 0, width() - 1, height()); 263 p.drawLine(width() - 1, 0, width() - 1, height());
263 } 264 }
264 265
265} 266}
266 267
267 268
268/* Keyboard::mousePressEvent {{{1 */ 269/* Keyboard::mousePressEvent {{{1 */
269void Keyboard::mousePressEvent(QMouseEvent *e) 270void Keyboard::mousePressEvent(QMouseEvent *e)
270{ 271{
271 int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1; 272 int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1;
272 if (row > 5) row = 5; 273 if (row > 5) row = 5;
273 274
274 // figure out the column 275 // figure out the column
275 int col = 0; 276 int col = 0;
276 for (int w = 0; e->x() >= w; col++) 277 for (int w = 0; e->x() >= w; col++)
277 if (col < keys->numKeys(row)) // it segfaults if it trys to read past numKeys 278 if (col < keys->numKeys(row)) // it segfaults if it trys to read past numKeys
278 w += keys->width(row,col) * defaultKeyWidth; 279 w += keys->width(row,col) * defaultKeyWidth;
279 else break; 280 else break;
280 281
281 if (col <= 0) return; 282 if (col <= 0) return;
282 283
283 col --; // rewind one... 284 col --; // rewind one...
284 285
285 qkeycode = keys->qcode(row, col); 286 qkeycode = keys->qcode(row, col);
286 unicode = keys->uni(row, col); 287 unicode = keys->uni(row, col);
287 288
288 // might need to repaint if two or more of the same keys. 289 // might need to repaint if two or more of the same keys.
289 // should be faster if just paint one key even though multiple keys exist. 290 // should be faster if just paint one key even though multiple keys exist.
290 bool need_repaint = FALSE; 291 bool need_repaint = FALSE;
291 292
292 if (unicode == 0) { // either Qt char, or nothing 293 if (unicode == 0) { // either Qt char, or nothing
293 294
294 if (qkeycode == Qt::Key_F1) { // toggle the pickboard 295 if (qkeycode == Qt::Key_F1) { // toggle the pickboard
295 296
296 if ( configdlg ) { 297 if ( configdlg ) {
297 delete (ConfigDlg *) configdlg; 298 delete (ConfigDlg *) configdlg;
@@ -999,266 +1000,266 @@ ushort Keyboard::constoe(const ushort c) {
999 } 1000 }
1000} 1001}
1001 1002
1002 1003
1003// Keys::Keys {{{1 1004// Keys::Keys {{{1
1004 1005
1005Keys::Keys() { 1006Keys::Keys() {
1006 1007
1007 Config *config = new Config ("multikey"); 1008 Config *config = new Config ("multikey");
1008 config->setGroup( "keymaps" ); 1009 config->setGroup( "keymaps" );
1009 QString map = config->readEntry( "current" ); 1010 QString map = config->readEntry( "current" );
1010 delete config; 1011 delete config;
1011 1012
1012 if (map.isNull() || !(QFile(map).exists())) { 1013 if (map.isNull() || !(QFile(map).exists())) {
1013 1014
1014 Config *config = new Config("locale"); 1015 Config *config = new Config("locale");
1015 config->setGroup( "Language" ); 1016 config->setGroup( "Language" );
1016 QString l = config->readEntry( "Language" , "en" ); 1017 QString l = config->readEntry( "Language" , "en" );
1017 delete config; 1018 delete config;
1018 1019
1019 map = QPEApplication::qpeDir() + "/share/multikey/" 1020 map = QPEApplication::qpeDir() + "/share/multikey/"
1020 + l + ".keymap"; 1021 + l + ".keymap";
1021 1022
1022 } 1023 }
1023 1024
1024 setKeysFromFile(map); 1025 setKeysFromFile(map);
1025} 1026}
1026 1027
1027Keys::Keys(const char * filename) { 1028Keys::Keys(const char * filename) {
1028 1029
1029 setKeysFromFile(filename); 1030 setKeysFromFile(filename);
1030} 1031}
1031 1032
1032// Keys::setKeysFromFile {{{2 1033// Keys::setKeysFromFile {{{2
1033void Keys::setKeysFromFile(const char * filename) { 1034void Keys::setKeysFromFile(const char * filename) {
1034 1035
1035 QFile f(filename); 1036 QFile f(filename);
1036 1037
1037 if (f.open(IO_ReadOnly)) { 1038 if (f.open(IO_ReadOnly)) {
1038 1039
1039 QTextStream t(&f); 1040 QTextStream t(&f);
1040 int row; 1041 int row;
1041 int qcode; 1042 int qcode;
1042 ushort unicode; 1043 ushort unicode;
1043 int width; 1044 int width;
1044 QString buf; 1045 QString buf;
1045 QString comment; 1046 QString comment;
1046 char * xpm[256]; //couldnt be larger than that... could it? 1047 char * xpm[256]; //couldnt be larger than that... could it?
1047 QPixmap *xpm2pix = 0; 1048 QImage *xpm2pix = 0;
1048 1049
1049 buf = t.readLine(); 1050 buf = t.readLine();
1050 while (buf) { 1051 while (buf) {
1051 1052
1052 // get rid of comments 1053 // get rid of comments
1053 buf.replace(QRegExp("#.*$", FALSE, FALSE), ""); 1054 buf.replace(QRegExp("#.*$", FALSE, FALSE), "");
1054 1055
1055 // key definition 1056 // key definition
1056 if (buf.contains(QRegExp("^\\d+\\s+[0-1a-fx]+", FALSE, FALSE))) { 1057 if (buf.contains(QRegExp("^\\d+\\s+[0-1a-fx]+", FALSE, FALSE))) {
1057 // no $1 type referencing!!! this implementation of regexp sucks 1058 // no $1 type referencing!!! this implementation of regexp sucks
1058 1059
1059 // dont know of any sscanf() type funcs in Qt lib 1060 // dont know of any sscanf() type funcs in Qt lib
1060 QTextStream tmp (buf, IO_ReadOnly); 1061 QTextStream tmp (buf, IO_ReadOnly);
1061 tmp >> row >> qcode >> unicode >> width >> comment; 1062 tmp >> row >> qcode >> unicode >> width >> comment;
1062 1063
1063 buf = t.readLine(); 1064 buf = t.readLine();
1064 int xpmLineCount = 0; 1065 int xpmLineCount = 0;
1065 xpm2pix = 0; 1066 xpm2pix = 0;
1066 1067
1067 // erase blank space 1068 // erase blank space
1068 while (buf.contains(QRegExp("^\\s*$")) && buf) buf = t.readLine(); 1069 while (buf.contains(QRegExp("^\\s*$")) && buf) buf = t.readLine();
1069 1070
1070 while (buf.contains(QRegExp("^\\s*\".*\""))) { 1071 while (buf.contains(QRegExp("^\\s*\".*\""))) {
1071 1072
1072 QString xpmBuf = buf.stripWhiteSpace(); 1073 QString xpmBuf = buf.stripWhiteSpace();
1073 1074
1074 xpm[xpmLineCount] = new char [xpmBuf.length()]; 1075 xpm[xpmLineCount] = new char [xpmBuf.length()];
1075 1076
1076 int j = 0; 1077 int j = 0;
1077 for (ushort i = 0; i < xpmBuf.length(); i++) { 1078 for (ushort i = 0; i < xpmBuf.length(); i++) {
1078 if (xpmBuf[i].latin1() != '"') { 1079 if (xpmBuf[i].latin1() != '"') {
1079 1080
1080 ((char *)xpm[xpmLineCount])[j] = xpmBuf.at(i).latin1(); 1081 ((char *)xpm[xpmLineCount])[j] = xpmBuf.at(i).latin1();
1081 j++; 1082 j++;
1082 } 1083 }
1083 1084
1084 } 1085 }
1085 // have to close that facker up 1086 // have to close that facker up
1086 ((char *)xpm[xpmLineCount])[j] = '\0'; 1087 ((char *)xpm[xpmLineCount])[j] = '\0';
1087 1088
1088 xpmLineCount++; 1089 xpmLineCount++;
1089 buf = t.readLine(); 1090 buf = t.readLine();
1090 } 1091 }
1091 if (xpmLineCount) { 1092 if (xpmLineCount) {
1092 1093
1093 xpm2pix = new QPixmap((const char **)xpm); 1094 xpm2pix = new QImage((const char **)xpm);
1094 for (int i = 0; i < xpmLineCount; i++) 1095 for (int i = 0; i < xpmLineCount; i++)
1095 1096
1096 delete [] (xpm[i]); 1097 delete [] (xpm[i]);
1097 1098
1098 } 1099 }
1099 setKey(row, qcode, unicode, width, xpm2pix); 1100 setKey(row, qcode, unicode, width, xpm2pix);
1100 } 1101 }
1101 1102
1102 // shift map 1103 // shift map
1103 else if (buf.contains(QRegExp("^[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { 1104 else if (buf.contains(QRegExp("^[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) {
1104 1105
1105 QTextStream tmp (buf, IO_ReadOnly); 1106 QTextStream tmp (buf, IO_ReadOnly);
1106 ushort lower, shift; 1107 ushort lower, shift;
1107 tmp >> lower >> shift; 1108 tmp >> lower >> shift;
1108 1109
1109 shiftMap.insert(lower, shift); 1110 shiftMap.insert(lower, shift);
1110 1111
1111 buf = t.readLine(); 1112 buf = t.readLine();
1112 } 1113 }
1113 1114
1114 // meta key map 1115 // meta key map
1115 else if (buf.contains(QRegExp("^\\s*m\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { 1116 else if (buf.contains(QRegExp("^\\s*m\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) {
1116 1117
1117 QTextStream tmp (buf, IO_ReadOnly); 1118 QTextStream tmp (buf, IO_ReadOnly);
1118 ushort lower, shift; 1119 ushort lower, shift;
1119 QChar m; 1120 QChar m;
1120 tmp >> m >> lower >> shift; 1121 tmp >> m >> lower >> shift;
1121 1122
1122 metaMap.insert(lower, shift); 1123 metaMap.insert(lower, shift);
1123 1124
1124 buf = t.readLine(); 1125 buf = t.readLine();
1125 } 1126 }
1126 1127
1127 // other variables like lang & title 1128 // other variables like lang & title
1128 else if (buf.contains(QRegExp("^\\s*[a-zA-Z]+\\s*=\\s*[a-zA-Z0-9/]+\\s*$", FALSE, FALSE))) { 1129 else if (buf.contains(QRegExp("^\\s*[a-zA-Z]+\\s*=\\s*[a-zA-Z0-9/]+\\s*$", FALSE, FALSE))) {
1129 1130
1130 QTextStream tmp (buf, IO_ReadOnly); 1131 QTextStream tmp (buf, IO_ReadOnly);
1131 QString name, equals, value; 1132 QString name, equals, value;
1132 1133
1133 tmp >> name >> equals >> value; 1134 tmp >> name >> equals >> value;
1134 1135
1135 if (name == "lang") { 1136 if (name == "lang") {
1136 1137
1137 lang = value; 1138 lang = value;
1138 1139
1139 } 1140 }
1140 1141
1141 buf = t.readLine(); 1142 buf = t.readLine();
1142 } 1143 }
1143 // comments 1144 // comments
1144 else if (buf.contains(QRegExp("^\\s*#"))) { 1145 else if (buf.contains(QRegExp("^\\s*#"))) {
1145 1146
1146 buf = t.readLine(); 1147 buf = t.readLine();
1147 1148
1148 } else { // blank line, or garbage 1149 } else { // blank line, or garbage
1149 1150
1150 buf = t.readLine(); 1151 buf = t.readLine();
1151 1152
1152 } 1153 }
1153 1154
1154 } 1155 }
1155 f.close(); 1156 f.close();
1156 } 1157 }
1157 1158
1158} 1159}
1159 1160
1160// Keys::setKey {{{2 1161// Keys::setKey {{{2
1161void Keys::setKey(const int row, const int qcode, const ushort unicode, 1162void Keys::setKey(const int row, const int qcode, const ushort unicode,
1162 const int width, QPixmap *pix) { 1163 const int width, QImage *pix) {
1163 1164
1164 Key * key; 1165 Key * key;
1165 key = new Key; 1166 key = new Key;
1166 key->qcode = qcode; 1167 key->qcode = qcode;
1167 key->unicode = unicode; 1168 key->unicode = unicode;
1168 key->width = width; 1169 key->width = width;
1169 1170
1170 // share key->pressed between same keys 1171 // share key->pressed between same keys
1171 bool found = 0; 1172 bool found = 0;
1172 for (int i = 1; i <= 5; i++) { 1173 for (int i = 1; i <= 5; i++) {
1173 for (unsigned int j = 0; j < keys[i].count(); j++) 1174 for (unsigned int j = 0; j < keys[i].count(); j++)
1174 if (keys[i].at(j)->qcode == qcode && keys[i].at(j)->unicode == unicode) { 1175 if (keys[i].at(j)->qcode == qcode && keys[i].at(j)->unicode == unicode) {
1175 1176
1176 key->pressed = keys[i].at(j)->pressed; 1177 key->pressed = keys[i].at(j)->pressed;
1177 found = 1; 1178 found = 1;
1178 } 1179 }
1179 1180
1180 } 1181 }
1181 if (!found) { 1182 if (!found) {
1182 1183
1183 key->pressed = new bool; 1184 key->pressed = new bool;
1184 *(key->pressed) = 0; 1185 *(key->pressed) = 0;
1185 } 1186 }
1186 1187
1187 key->pix = pix; 1188 key->pix = pix;
1188 1189
1189 1190
1190 keys[row].append(key); 1191 keys[row].append(key);
1191} 1192}
1192 1193
1193// Keys::~Keys {{{2 1194// Keys::~Keys {{{2
1194Keys::~Keys() { 1195Keys::~Keys() {
1195 1196
1196 for (int i = 1; i <= 5; i++) 1197 for (int i = 1; i <= 5; i++)
1197 for (unsigned int j = 0; j < keys[i].count(); j++) 1198 for (unsigned int j = 0; j < keys[i].count(); j++)
1198 delete keys[i].at(j); 1199 delete keys[i].at(j);
1199 1200
1200} 1201}
1201 1202
1202// Keys:: other functions {{{2 1203// Keys:: other functions {{{2
1203int Keys::width(const int row, const int col) { 1204int Keys::width(const int row, const int col) {
1204 1205
1205 return keys[row].at(col)->width; 1206 return keys[row].at(col)->width;
1206 1207
1207} 1208}
1208ushort Keys::uni(const int row, const int col) { 1209ushort Keys::uni(const int row, const int col) {
1209 1210
1210 return keys[row].at(col)->unicode; 1211 return keys[row].at(col)->unicode;
1211 1212
1212} 1213}
1213 1214
1214int Keys::qcode(const int row, const int col) { 1215int Keys::qcode(const int row, const int col) {
1215 1216
1216 return keys[row].at(col)->qcode; 1217 return keys[row].at(col)->qcode;
1217} 1218}
1218 1219
1219QPixmap *Keys::pix(const int row, const int col) { 1220QImage *Keys::pix(const int row, const int col) {
1220 1221
1221 return keys[row].at(col)->pix; 1222 return keys[row].at(col)->pix;
1222 1223
1223} 1224}
1224bool Keys::pressed(const int row, const int col) { 1225bool Keys::pressed(const int row, const int col) {
1225 1226
1226 return *(keys[row].at(col)->pressed); 1227 return *(keys[row].at(col)->pressed);
1227} 1228}
1228 1229
1229int Keys::numKeys(const int row) { 1230int Keys::numKeys(const int row) {
1230 1231
1231 return keys[row].count(); 1232 return keys[row].count();
1232} 1233}
1233 1234
1234void Keys::setPressed(const int row, const int col, const bool pressed) { 1235void Keys::setPressed(const int row, const int col, const bool pressed) {
1235 1236
1236 *(keys[row].at(col)->pressed) = pressed; 1237 *(keys[row].at(col)->pressed) = pressed;
1237} 1238}
1238 1239
1239ushort Keys::shift(const ushort uni) { 1240ushort Keys::shift(const ushort uni) {
1240 1241
1241 if (shiftMap[uni]) { 1242 if (shiftMap[uni]) {
1242 1243
1243 return shiftMap[uni]; 1244 return shiftMap[uni];
1244 } 1245 }
1245 else 1246 else
1246 return 0; 1247 return 0;
1247 1248
1248} 1249}
1249 1250
1250ushort Keys::meta(const ushort uni) { 1251ushort Keys::meta(const ushort uni) {
1251 1252
1252 if (metaMap[uni]) { 1253 if (metaMap[uni]) {
1253 1254
1254 return metaMap[uni]; 1255 return metaMap[uni];
1255 } 1256 }
1256 else 1257 else
1257 return 0; 1258 return 0;
1258 1259
1259} 1260}
1260 1261
1261bool *Keys::pressedPtr(const int row, const int col) { 1262bool *Keys::pressedPtr(const int row, const int col) {
1262 1263
1263 return keys[row].at(col)->pressed; 1264 return keys[row].at(col)->pressed;
1264} 1265}
diff --git a/inputmethods/multikey/keyboard.h b/inputmethods/multikey/keyboard.h
index b692975..1aa7a35 100644
--- a/inputmethods/multikey/keyboard.h
+++ b/inputmethods/multikey/keyboard.h
@@ -18,115 +18,115 @@
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
26class QTimer; 26class QTimer;
27 27
28class KeyboardConfig : public DictFilterConfig 28class KeyboardConfig : public DictFilterConfig
29{ 29{
30public: 30public:
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; }
36private: 36private:
37 int backspaces; 37 int backspaces;
38}; 38};
39 39
40 40
41class KeyboardPicks : public PickboardPicks 41class KeyboardPicks : public PickboardPicks
42{ 42{
43 Q_OBJECT 43 Q_OBJECT
44public: 44public:
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
53class Keys { 53class Keys {
54public: 54public:
55 55
56 Keys(); 56 Keys();
57 Keys(const char * filename); 57 Keys(const char * filename);
58 ~Keys(); 58 ~Keys();
59 ushort uni(const int row, const int col); 59 ushort uni(const int row, const int col);
60 int qcode(const int row, const int col); 60 int qcode(const int row, const int col);
61 int width(const int row, const int col); 61 int width(const int row, const int col);
62 bool pressed(const int row, const int col); 62 bool pressed(const int row, const int col);
63 bool *pressedPtr(const int row, const int col); 63 bool *pressedPtr(const int row, const int col);
64 ushort shift(const ushort); 64 ushort shift(const ushort);
65 ushort meta(const ushort); 65 ushort meta(const ushort);
66 QPixmap *pix(const int row, const int col); 66 QImage *pix(const int row, const int col);
67 int numKeys(const int row); 67 int numKeys(const int row);
68 void setKeysFromFile(const char *filename); 68 void setKeysFromFile(const char *filename);
69 void setKey(const int row, const int qcode, const ushort unicode, 69 void setKey(const int row, const int qcode, const ushort unicode,
70 const int width, QPixmap *pix); 70 const int width, QImage *pix);
71 void setPressed(const int row, const int col, const bool pressed); 71 void setPressed(const int row, const int col, const bool pressed);
72 QString lang; 72 QString lang;
73 QString label; 73 QString label;
74 74
75private: 75private:
76 76
77 typedef struct Key { 77 typedef struct Key {
78 int qcode; // are qt key codes just unicode values? 78 int qcode; // are qt key codes just unicode values?
79 ushort unicode; 79 ushort unicode;
80 int width; // not pixels but relative key width. normal key is 2 80 int width; // not pixels but relative key width. normal key is 2
81 81
82 // only needed for keys like ctrl that can have multiple keys pressed at once 82 // only needed for keys like ctrl that can have multiple keys pressed at once
83 bool *pressed; 83 bool *pressed;
84 QPixmap *pix; 84 QImage *pix;
85 }; 85 };
86 86
87 QList<Key> keys[6]; 87 QList<Key> keys[6];
88 QMap<ushort,ushort> shiftMap; 88 QMap<ushort,ushort> shiftMap;
89 QMap<ushort,ushort> metaMap; 89 QMap<ushort,ushort> metaMap;
90 90
91}; 91};
92 92
93class Keyboard : public QFrame 93class Keyboard : public QFrame
94{ 94{
95 Q_OBJECT 95 Q_OBJECT
96public: 96public:
97 Keyboard( QWidget* parent=0, const char* name=0, WFlags f=0 ); 97 Keyboard( QWidget* parent=0, const char* name=0, WFlags f=0 );
98 ~Keyboard(); 98 ~Keyboard();
99 99
100 void resetState(); 100 void resetState();
101 101
102 void mousePressEvent(QMouseEvent*); 102 void mousePressEvent(QMouseEvent*);
103 void mouseReleaseEvent(QMouseEvent*); 103 void mouseReleaseEvent(QMouseEvent*);
104 void resizeEvent(QResizeEvent*); 104 void resizeEvent(QResizeEvent*);
105 void paintEvent(QPaintEvent* e); 105 void paintEvent(QPaintEvent* e);
106 //void timerEvent(QTimerEvent* e); 106 //void timerEvent(QTimerEvent* e);
107 void drawKeyboard( QPainter &p, int row = -1, int col = -1); 107 void drawKeyboard( QPainter &p, int row = -1, int col = -1);
108 108
109 QSize sizeHint() const; 109 QSize sizeHint() const;
110 110
111signals: 111signals:
112 void key( ushort scancode, ushort unicode, ushort modifiers, bool, bool ); 112 void key( ushort scancode, ushort unicode, ushort modifiers, bool, bool );
113 113
114private slots: 114private slots:
115 void repeat(); 115 void repeat();
116 void togglePickboard(bool on_off); 116 void togglePickboard(bool on_off);
117 void toggleRepeat(bool on_off); 117 void toggleRepeat(bool on_off);
118 void setMapToDefault(); 118 void setMapToDefault();
119 void setMapToFile(QString map); 119 void setMapToFile(QString map);
120 120
121 // used to redraw keyboard after edited colors 121 // used to redraw keyboard after edited colors
122 void reloadKeyboard(); 122 void reloadKeyboard();
123 123
124private: 124private:
125 int getKey( int &w, int j = -1 ); 125 int getKey( int &w, int j = -1 );
126 void clearHighlight(); 126 void clearHighlight();
127 127
128 bool *shift; 128 bool *shift;
129 bool *lock; 129 bool *lock;
130 bool *ctrl; 130 bool *ctrl;
131 bool *alt; 131 bool *alt;
132 bool *meta; 132 bool *meta;