-rw-r--r-- | inputmethods/multikey/keyboard.cpp | 98 | ||||
-rw-r--r-- | inputmethods/multikey/keyboard.h | 3 |
2 files changed, 93 insertions, 8 deletions
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp index 7098a6b..74c99c7 100644 --- a/inputmethods/multikey/keyboard.cpp +++ b/inputmethods/multikey/keyboard.cpp | |||
@@ -43,4 +43,4 @@ | |||
43 | Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : | 43 | Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : |
44 | QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), | 44 | QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), alt(0), meta(0), |
45 | alt(0), useLargeKeys(TRUE), usePicks(0), useRepeat(0), pressedKeyRow(-1), pressedKeyCol(-1), | 45 | useLargeKeys(TRUE), usePicks(0), useRepeat(0), pressedKeyRow(-1), pressedKeyCol(-1), |
46 | unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0), | 46 | unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0), |
@@ -184,6 +184,13 @@ void Keyboard::drawKeyboard(QPainter &p, int row, int col) | |||
184 | p.setPen(textcolor); | 184 | p.setPen(textcolor); |
185 | if (!pix) | 185 | if (!pix) { |
186 | if (shift || lock) | ||
187 | c = keys->shift(c); | ||
188 | if (meta) { | ||
189 | |||
190 | c = keys->meta(c); | ||
191 | } | ||
186 | p.drawText(x, y, | 192 | p.drawText(x, y, |
187 | defaultKeyWidth * keyWidth, keyHeight, | 193 | defaultKeyWidth * keyWidth + 3, keyHeight, |
188 | AlignCenter, ((shift || lock) && keys->shift(c)) ? (QChar)keys->shift(c) : (QChar)c); | 194 | AlignCenter, (QChar)c); |
195 | } | ||
189 | else | 196 | else |
@@ -227,6 +234,10 @@ void Keyboard::drawKeyboard(QPainter &p, int row, int col) | |||
227 | if (!pix) { | 234 | if (!pix) { |
228 | p.setPen(textcolor); | 235 | if ((shift || lock) && keys->shift(c)) |
236 | c = keys->shift(c); | ||
237 | else if (meta && keys->meta(c)) | ||
238 | c = keys->meta(c); | ||
239 | |||
229 | p.drawText(x, y, | 240 | p.drawText(x, y, |
230 | keyWidthPix, keyHeight, | 241 | defaultKeyWidth * keyWidth + 3, keyHeight, |
231 | AlignCenter, ((shift || lock) && keys->shift(c)) ? (QChar)keys->shift(c) : (QChar)c); | 242 | AlignCenter, (QChar)c); |
232 | } | 243 | } |
@@ -346,2 +357,7 @@ void Keyboard::mousePressEvent(QMouseEvent *e) | |||
346 | } | 357 | } |
358 | if (meta) { | ||
359 | |||
360 | *meta = 0; | ||
361 | meta = 0; | ||
362 | } | ||
347 | 363 | ||
@@ -362,3 +378,37 @@ void Keyboard::mousePressEvent(QMouseEvent *e) | |||
362 | } | 378 | } |
379 | if (meta) { | ||
380 | |||
381 | *meta = 0; | ||
382 | meta = 0; | ||
383 | } | ||
384 | |||
385 | } else if (qkeycode == Qt::Key_Meta) { | ||
386 | need_repaint = TRUE; | ||
387 | |||
388 | if (meta) { | ||
389 | *meta = 0; | ||
390 | meta = 0; | ||
391 | |||
392 | } else { | ||
393 | |||
394 | meta = keys->pressedPtr(row, col); | ||
395 | need_repaint = TRUE; | ||
396 | *meta = !keys->pressed(row, col); | ||
397 | } | ||
398 | |||
399 | if (shift) { | ||
400 | |||
401 | *shift = 0; | ||
402 | shift = 0; | ||
403 | |||
404 | } | ||
405 | if (lock) { | ||
406 | |||
407 | *lock = 0; | ||
408 | lock = 0; | ||
409 | |||
410 | } | ||
363 | 411 | ||
412 | // dont need to emit this key... acts same as alt | ||
413 | qkeycode = 0; | ||
364 | } | 414 | } |
@@ -370,2 +420,5 @@ void Keyboard::mousePressEvent(QMouseEvent *e) | |||
370 | } | 420 | } |
421 | if (meta && keys->meta(unicode)) { | ||
422 | unicode = keys->meta(unicode); | ||
423 | } | ||
371 | } | 424 | } |
@@ -449,2 +502,7 @@ void Keyboard::mouseReleaseEvent(QMouseEvent*) | |||
449 | 502 | ||
503 | } else if (meta && unicode != 0) { | ||
504 | |||
505 | *meta = 0; | ||
506 | meta = 0; | ||
507 | repaint(FALSE); | ||
450 | } | 508 | } |
@@ -1048,2 +1106,15 @@ void Keys::setKeysFromFile(const char * filename) { | |||
1048 | 1106 | ||
1107 | // meta key map | ||
1108 | else if (buf.contains(QRegExp("^\\s*m\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { | ||
1109 | |||
1110 | QTextStream tmp (buf, IO_ReadOnly); | ||
1111 | ushort lower, shift; | ||
1112 | QChar m; | ||
1113 | tmp >> m >> lower >> shift; | ||
1114 | |||
1115 | metaMap.insert(lower, shift); | ||
1116 | |||
1117 | buf = t.readLine(); | ||
1118 | } | ||
1119 | |||
1049 | // other variables like lang & title | 1120 | // other variables like lang & title |
@@ -1171,2 +1242,13 @@ ushort Keys::shift(const ushort uni) { | |||
1171 | 1242 | ||
1243 | ushort Keys::meta(const ushort uni) { | ||
1244 | |||
1245 | if (metaMap[uni]) { | ||
1246 | |||
1247 | return metaMap[uni]; | ||
1248 | } | ||
1249 | else | ||
1250 | return 0; | ||
1251 | |||
1252 | } | ||
1253 | |||
1172 | bool *Keys::pressedPtr(const int row, const int col) { | 1254 | bool *Keys::pressedPtr(const int row, const int col) { |
diff --git a/inputmethods/multikey/keyboard.h b/inputmethods/multikey/keyboard.h index dc50e55..b692975 100644 --- a/inputmethods/multikey/keyboard.h +++ b/inputmethods/multikey/keyboard.h | |||
@@ -64,2 +64,3 @@ public: | |||
64 | ushort shift(const ushort); | 64 | ushort shift(const ushort); |
65 | ushort meta(const ushort); | ||
65 | QPixmap *pix(const int row, const int col); | 66 | QPixmap *pix(const int row, const int col); |
@@ -87,2 +88,3 @@ private: | |||
87 | QMap<ushort,ushort> shiftMap; | 88 | QMap<ushort,ushort> shiftMap; |
89 | QMap<ushort,ushort> metaMap; | ||
88 | 90 | ||
@@ -129,2 +131,3 @@ private: | |||
129 | bool *alt; | 131 | bool *alt; |
132 | bool *meta; | ||
130 | uint useLargeKeys:1; | 133 | uint useLargeKeys:1; |