Diffstat (limited to 'inputmethods/multikey/keyboard.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | inputmethods/multikey/keyboard.cpp | 148 |
1 files changed, 147 insertions, 1 deletions
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp index 28d5cab..1dd8ca1 100644 --- a/inputmethods/multikey/keyboard.cpp +++ b/inputmethods/multikey/keyboard.cpp | |||
@@ -42,5 +42,5 @@ | |||
42 | Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : | 42 | Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : |
43 | QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), alt(0), | 43 | QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), alt(0), |
44 | meta(0), circumflex(0), diaeresis(0), | 44 | meta(0), circumflex(0), diaeresis(0), baccent(0), accent(0), |
45 | useLargeKeys(TRUE), usePicks(0), useRepeat(0), | 45 | useLargeKeys(TRUE), usePicks(0), useRepeat(0), |
46 | pressedKeyRow(-1), pressedKeyCol(-1), | 46 | pressedKeyRow(-1), pressedKeyCol(-1), |
@@ -191,4 +191,8 @@ void Keyboard::drawKeyboard(QPainter &p, int row, int col) | |||
191 | else if (diaeresis && keys->diaeresis(keys->shift(c))) | 191 | else if (diaeresis && keys->diaeresis(keys->shift(c))) |
192 | c = keys->diaeresis(keys->shift(c)); | 192 | c = keys->diaeresis(keys->shift(c)); |
193 | else if (baccent && keys->baccent(keys->shift(c))) | ||
194 | c = keys->baccent(keys->shift(c)); | ||
195 | else if (accent && keys->accent(keys->shift(c))) | ||
196 | c = keys->accent(keys->shift(c)); | ||
193 | else if (meta && keys->meta(keys->shift(c))) | 197 | else if (meta && keys->meta(keys->shift(c))) |
194 | c = keys->meta(keys->shift(c)); | 198 | c = keys->meta(keys->shift(c)); |
@@ -200,4 +204,8 @@ void Keyboard::drawKeyboard(QPainter &p, int row, int col) | |||
200 | else if (circumflex && keys->circumflex(c)) | 204 | else if (circumflex && keys->circumflex(c)) |
201 | c = keys->circumflex(c); | 205 | c = keys->circumflex(c); |
206 | else if (baccent && keys->baccent(c)) | ||
207 | c = keys->baccent(c); | ||
208 | else if (accent && keys->accent(c)) | ||
209 | c = keys->accent(c); | ||
202 | else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) { | 210 | else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) { |
203 | 211 | ||
@@ -261,4 +269,8 @@ void Keyboard::drawKeyboard(QPainter &p, int row, int col) | |||
261 | else if (diaeresis && keys->diaeresis(keys->shift(c))) | 269 | else if (diaeresis && keys->diaeresis(keys->shift(c))) |
262 | c = keys->diaeresis(keys->shift(c)); | 270 | c = keys->diaeresis(keys->shift(c)); |
271 | else if (baccent && keys->baccent(keys->shift(c))) | ||
272 | c = keys->baccent(keys->shift(c)); | ||
273 | else if (accent && keys->accent(keys->shift(c))) | ||
274 | c = keys->accent(keys->shift(c)); | ||
263 | else if (meta && keys->meta(keys->shift(c))) | 275 | else if (meta && keys->meta(keys->shift(c))) |
264 | c = keys->meta(keys->shift(c)); | 276 | c = keys->meta(keys->shift(c)); |
@@ -270,4 +282,8 @@ void Keyboard::drawKeyboard(QPainter &p, int row, int col) | |||
270 | else if (circumflex && keys->circumflex(c)) | 282 | else if (circumflex && keys->circumflex(c)) |
271 | c = keys->circumflex(c); | 283 | c = keys->circumflex(c); |
284 | else if (baccent && keys->baccent(c)) | ||
285 | c = keys->baccent(c); | ||
286 | else if (accent && keys->accent(c)) | ||
287 | c = keys->accent(c); | ||
272 | else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) { | 288 | else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) { |
273 | 289 | ||
@@ -347,4 +363,39 @@ void Keyboard::mousePressEvent(QMouseEvent *e) | |||
347 | } | 363 | } |
348 | 364 | ||
365 | // Back accent character support | ||
366 | |||
367 | if (unicode == 0x60) { | ||
368 | |||
369 | unicode = 0; | ||
370 | if (shift || lock) { | ||
371 | |||
372 | // circumblex | ||
373 | qkeycode = 0x2000; | ||
374 | } | ||
375 | else { | ||
376 | |||
377 | // back accent | ||
378 | qkeycode = 0x2002; | ||
379 | } | ||
380 | } | ||
381 | |||
382 | // Accent character support | ||
383 | |||
384 | if (unicode == 0xb4) { | ||
385 | |||
386 | unicode = 0; | ||
387 | if (shift || lock) { | ||
388 | |||
389 | // diaeresis | ||
390 | qkeycode = 0x2001; | ||
391 | } | ||
392 | else { | ||
393 | |||
394 | // accent | ||
395 | qkeycode = 0x2003; | ||
396 | } | ||
397 | } | ||
398 | |||
399 | |||
349 | if (unicode == 0) { // either Qt char, or nothing | 400 | if (unicode == 0) { // either Qt char, or nothing |
350 | 401 | ||
@@ -473,4 +524,6 @@ void Keyboard::mousePressEvent(QMouseEvent *e) | |||
473 | if (circumflex) { *circumflex = 0; circumflex = 0; } | 524 | if (circumflex) { *circumflex = 0; circumflex = 0; } |
474 | if (diaeresis) { *diaeresis = 0; diaeresis = 0; } | 525 | if (diaeresis) { *diaeresis = 0; diaeresis = 0; } |
526 | if (baccent) { *baccent = 0; baccent = 0; } | ||
527 | if (accent) { *accent = 0; accent = 0; } | ||
475 | 528 | ||
476 | // dont need to emit this key... acts same as alt | 529 | // dont need to emit this key... acts same as alt |
@@ -552,4 +605,48 @@ void Keyboard::mousePressEvent(QMouseEvent *e) | |||
552 | 605 | ||
553 | qkeycode = 0; | 606 | qkeycode = 0; |
607 | |||
608 | // Back accent | ||
609 | } else if (qkeycode == 0x2002) { | ||
610 | need_repaint = TRUE; | ||
611 | |||
612 | if (baccent) { | ||
613 | |||
614 | *baccent = 0; | ||
615 | baccent = 0; | ||
616 | |||
617 | } else { | ||
618 | |||
619 | baccent = keys->pressedPtr(row, col); | ||
620 | *baccent = true; | ||
621 | } | ||
622 | |||
623 | |||
624 | if (shift) { *shift = 0; shift = 0; } | ||
625 | if (meta) { *meta = 0; meta = 0; } | ||
626 | if (accent) { *accent = 0; accent = 0; } | ||
627 | |||
628 | qkeycode = 0; | ||
629 | |||
630 | // Accent | ||
631 | } else if (qkeycode == 0x2003) { | ||
632 | need_repaint = TRUE; | ||
633 | |||
634 | if (accent) { | ||
635 | |||
636 | *accent = 0; | ||
637 | accent = 0; | ||
638 | |||
639 | } else { | ||
640 | |||
641 | accent = keys->pressedPtr(row, col); | ||
642 | *accent = true; | ||
643 | } | ||
644 | |||
645 | |||
646 | if (shift) { *shift = 0; shift = 0; } | ||
647 | if (meta) { *meta = 0; meta = 0; } | ||
648 | if (baccent) { *baccent = 0; } | ||
649 | |||
650 | qkeycode = 0; | ||
554 | } | 651 | } |
555 | 652 | ||
@@ -565,4 +662,8 @@ void Keyboard::mousePressEvent(QMouseEvent *e) | |||
565 | else if (diaeresis && keys->diaeresis(keys->shift(unicode))) | 662 | else if (diaeresis && keys->diaeresis(keys->shift(unicode))) |
566 | unicode = keys->diaeresis(keys->shift(unicode)); | 663 | unicode = keys->diaeresis(keys->shift(unicode)); |
664 | else if (baccent && keys->baccent(keys->shift(unicode))) | ||
665 | unicode = keys->baccent(keys->shift(unicode)); | ||
666 | else if (accent && keys->accent(keys->shift(unicode))) | ||
667 | unicode = keys->accent(keys->shift(unicode)); | ||
567 | else if (meta && keys->meta(keys->shift(unicode))) | 668 | else if (meta && keys->meta(keys->shift(unicode))) |
568 | unicode = keys->meta(keys->shift(unicode)); | 669 | unicode = keys->meta(keys->shift(unicode)); |
@@ -580,4 +681,10 @@ void Keyboard::mousePressEvent(QMouseEvent *e) | |||
580 | unicode = keys->diaeresis(unicode); | 681 | unicode = keys->diaeresis(unicode); |
581 | } | 682 | } |
683 | else if (baccent && keys->baccent(unicode)) { | ||
684 | unicode = keys->baccent(unicode); | ||
685 | } | ||
686 | else if (accent && keys->accent(unicode)) { | ||
687 | unicode = keys->accent(unicode); | ||
688 | } | ||
582 | } | 689 | } |
583 | 690 | ||
@@ -734,4 +841,6 @@ void Keyboard::resetState() | |||
734 | if (circumflex) { *circumflex = 0; circumflex = 0; } | 841 | if (circumflex) { *circumflex = 0; circumflex = 0; } |
735 | if (diaeresis) { *diaeresis = 0; diaeresis = 0; } | 842 | if (diaeresis) { *diaeresis = 0; diaeresis = 0; } |
843 | if (baccent) { *baccent = 0; baccent = 0; } | ||
844 | if (accent) { *accent = 0; accent = 0; } | ||
736 | 845 | ||
737 | schar = mchar = echar = 0; | 846 | schar = mchar = echar = 0; |
@@ -1341,4 +1450,29 @@ void Keys::setKeysFromFile(const char * filename) { | |||
1341 | buf = t.readLine(); | 1450 | buf = t.readLine(); |
1342 | } | 1451 | } |
1452 | // back accent | ||
1453 | else if (buf.contains(QRegExp("^\\s*b\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { | ||
1454 | |||
1455 | QTextStream tmp (buf, IO_ReadOnly); | ||
1456 | ushort lower, shift; | ||
1457 | QChar d; | ||
1458 | tmp >> d >> lower >> shift; | ||
1459 | |||
1460 | baccentMap.insert(lower, shift); | ||
1461 | |||
1462 | qDebug ("Estoy añadiendo %i con %i", lower, shift); | ||
1463 | buf = t.readLine(); | ||
1464 | } | ||
1465 | // accent | ||
1466 | else if (buf.contains(QRegExp("^\\s*a\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { | ||
1467 | |||
1468 | QTextStream tmp (buf, IO_ReadOnly); | ||
1469 | ushort lower, shift; | ||
1470 | QChar d; | ||
1471 | tmp >> d >> lower >> shift; | ||
1472 | |||
1473 | accentMap.insert(lower, shift); | ||
1474 | |||
1475 | buf = t.readLine(); | ||
1476 | } | ||
1343 | 1477 | ||
1344 | // other variables like lang & title | 1478 | // other variables like lang & title |
@@ -1490,4 +1624,16 @@ ushort Keys::diaeresis(const ushort uni) { | |||
1490 | } | 1624 | } |
1491 | 1625 | ||
1626 | ushort Keys::baccent(const ushort uni) { | ||
1627 | |||
1628 | if(baccentMap[uni]) return baccentMap[uni]; | ||
1629 | else return 0; | ||
1630 | } | ||
1631 | |||
1632 | ushort Keys::accent(const ushort uni) { | ||
1633 | |||
1634 | if(accentMap[uni]) return accentMap[uni]; | ||
1635 | else return 0; | ||
1636 | } | ||
1637 | |||
1492 | bool *Keys::pressedPtr(const int row, const int col) { | 1638 | bool *Keys::pressedPtr(const int row, const int col) { |
1493 | 1639 | ||