Diffstat (limited to 'inputmethods/multikey/keyboard.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | inputmethods/multikey/keyboard.cpp | 323 |
1 files changed, 277 insertions, 46 deletions
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp index 4747f59..28d5cab 100644 --- a/inputmethods/multikey/keyboard.cpp +++ b/inputmethods/multikey/keyboard.cpp | |||
@@ -39,10 +39,12 @@ | |||
39 | 39 | ||
40 | 40 | ||
41 | /* Keyboard::Keyboard {{{1 */ | 41 | /* Keyboard::Keyboard {{{1 */ |
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), meta(0), | 43 | QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), alt(0), |
44 | useLargeKeys(TRUE), usePicks(0), useRepeat(0), pressedKeyRow(-1), pressedKeyCol(-1), | 44 | meta(0), circumflex(0), diaeresis(0), |
45 | useLargeKeys(TRUE), usePicks(0), useRepeat(0), | ||
46 | pressedKeyRow(-1), pressedKeyCol(-1), | ||
45 | unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0), | 47 | unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0), |
46 | configdlg(0) | 48 | configdlg(0) |
47 | 49 | ||
48 | { | 50 | { |
@@ -94,9 +96,9 @@ Keyboard::~Keyboard() { | |||
94 | void Keyboard::resizeEvent(QResizeEvent*) | 96 | void Keyboard::resizeEvent(QResizeEvent*) |
95 | { | 97 | { |
96 | int ph = picks->sizeHint().height(); | 98 | int ph = picks->sizeHint().height(); |
97 | picks->setGeometry( 0, 0, width(), ph ); | 99 | picks->setGeometry( 0, 0, width(), ph ); |
98 | keyHeight = (height()-(usePicks ? ph : 0))/5; | 100 | keyHeight = (height()-(usePicks ? ph : 0))/keys->rows(); |
99 | 101 | ||
100 | int nk; // number of keys? | 102 | int nk; // number of keys? |
101 | if ( useLargeKeys ) { | 103 | if ( useLargeKeys ) { |
102 | nk = 15; | 104 | nk = 15; |
@@ -181,14 +183,34 @@ void Keyboard::drawKeyboard(QPainter &p, int row, int col) | |||
181 | ushort c = keys->uni(row, col); | 183 | ushort c = keys->uni(row, col); |
182 | 184 | ||
183 | p.setPen(textcolor); | 185 | p.setPen(textcolor); |
184 | if (!pix) { | 186 | if (!pix) { |
185 | if (shift || lock) | 187 | if ((shift || lock) && keys->shift(c)) |
186 | c = keys->shift(c); | 188 | |
187 | if (meta) { | 189 | if (circumflex && keys->circumflex(keys->shift(c))) |
190 | c = keys->circumflex(keys->shift(c)); | ||
191 | else if (diaeresis && keys->diaeresis(keys->shift(c))) | ||
192 | c = keys->diaeresis(keys->shift(c)); | ||
193 | else if (meta && keys->meta(keys->shift(c))) | ||
194 | c = keys->meta(keys->shift(c)); | ||
195 | else | ||
196 | c = keys->shift(c); | ||
188 | 197 | ||
198 | else if (meta && keys->meta(c)) | ||
189 | c = keys->meta(c); | 199 | c = keys->meta(c); |
200 | else if (circumflex && keys->circumflex(c)) | ||
201 | c = keys->circumflex(c); | ||
202 | else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) { | ||
203 | |||
204 | // the diaeresis key itself has to be in the diaeresisMap, | ||
205 | // or just do this to make it display the diaeresis char. | ||
206 | |||
207 | if (c == 0x2c6) | ||
208 | c = 0xa8; | ||
209 | else | ||
210 | c = keys->diaeresis(c); | ||
190 | } | 211 | } |
212 | |||
191 | p.drawText(x, y, | 213 | p.drawText(x, y, |
192 | defaultKeyWidth * keyWidth + 3, keyHeight, | 214 | defaultKeyWidth * keyWidth + 3, keyHeight, |
193 | AlignCenter, (QChar)c); | 215 | AlignCenter, (QChar)c); |
194 | } | 216 | } |
@@ -207,9 +229,9 @@ void Keyboard::drawKeyboard(QPainter &p, int row, int col) | |||
207 | 229 | ||
208 | 230 | ||
209 | p.fillRect(0, 0, width(), height(), keycolor); | 231 | p.fillRect(0, 0, width(), height(), keycolor); |
210 | 232 | ||
211 | for (row = 1; row <= 5; row++) { | 233 | for (row = 1; row <= keys->rows(); row++) { |
212 | 234 | ||
213 | int x = 0; | 235 | int x = 0; |
214 | int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); | 236 | int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); |
215 | 237 | ||
@@ -232,11 +254,29 @@ void Keyboard::drawKeyboard(QPainter &p, int row, int col) | |||
232 | 254 | ||
233 | p.setPen(textcolor); | 255 | p.setPen(textcolor); |
234 | if (!pix) { | 256 | if (!pix) { |
235 | if ((shift || lock) && keys->shift(c)) | 257 | if ((shift || lock) && keys->shift(c)) |
236 | c = keys->shift(c); | 258 | |
259 | if (circumflex && keys->circumflex(keys->shift(c))) | ||
260 | c = keys->circumflex(keys->shift(c)); | ||
261 | else if (diaeresis && keys->diaeresis(keys->shift(c))) | ||
262 | c = keys->diaeresis(keys->shift(c)); | ||
263 | else if (meta && keys->meta(keys->shift(c))) | ||
264 | c = keys->meta(keys->shift(c)); | ||
265 | else | ||
266 | c = keys->shift(c); | ||
267 | |||
237 | else if (meta && keys->meta(c)) | 268 | else if (meta && keys->meta(c)) |
238 | c = keys->meta(c); | 269 | c = keys->meta(c); |
270 | else if (circumflex && keys->circumflex(c)) | ||
271 | c = keys->circumflex(c); | ||
272 | else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) { | ||
273 | |||
274 | if (c == 0x2c6) | ||
275 | c = 0xa8; | ||
276 | else | ||
277 | c = keys->diaeresis(c); | ||
278 | } | ||
239 | 279 | ||
240 | p.drawText(x, y, | 280 | p.drawText(x, y, |
241 | keyWidthPix + 3, keyHeight, | 281 | keyWidthPix + 3, keyHeight, |
242 | AlignCenter, (QChar)c); | 282 | AlignCenter, (QChar)c); |
@@ -288,13 +328,31 @@ void Keyboard::mousePressEvent(QMouseEvent *e) | |||
288 | // might need to repaint if two or more of the same keys. | 328 | // 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. | 329 | // should be faster if just paint one key even though multiple keys exist. |
290 | bool need_repaint = FALSE; | 330 | bool need_repaint = FALSE; |
291 | 331 | ||
332 | // circumflex and diaeresis support | ||
333 | // messy to have this here, but too hard to implement any other method | ||
334 | if (unicode == 0x2c6) { | ||
335 | |||
336 | unicode = 0; | ||
337 | if (shift || lock) { | ||
338 | |||
339 | // diaeresis | ||
340 | qkeycode = 0x2001; | ||
341 | } | ||
342 | else { | ||
343 | |||
344 | // circumflex | ||
345 | qkeycode = 0x2000; | ||
346 | } | ||
347 | } | ||
348 | |||
292 | if (unicode == 0) { // either Qt char, or nothing | 349 | if (unicode == 0) { // either Qt char, or nothing |
293 | 350 | ||
294 | if (qkeycode == Qt::Key_F1) { // toggle the pickboard | 351 | if (qkeycode == Qt::Key_F1) { // toggle the pickboard |
295 | 352 | ||
296 | if ( configdlg ) { | 353 | if ( configdlg ) { |
354 | |||
297 | delete (ConfigDlg *) configdlg; | 355 | delete (ConfigDlg *) configdlg; |
298 | configdlg = 0; | 356 | configdlg = 0; |
299 | } | 357 | } |
300 | else { | 358 | else { |
@@ -308,8 +366,10 @@ void Keyboard::mousePressEvent(QMouseEvent *e) | |||
308 | connect(configdlg, SIGNAL(repeatToggled(bool)), | 366 | connect(configdlg, SIGNAL(repeatToggled(bool)), |
309 | this, SLOT(toggleRepeat(bool))); | 367 | this, SLOT(toggleRepeat(bool))); |
310 | connect(configdlg, SIGNAL(reloadKeyboard()), | 368 | connect(configdlg, SIGNAL(reloadKeyboard()), |
311 | this, SLOT(reloadKeyboard())); | 369 | this, SLOT(reloadKeyboard())); |
370 | connect(configdlg, SIGNAL(configDlgClosed()), | ||
371 | this, SLOT(cleanupConfigDlg())); | ||
312 | configdlg->showMaximized(); | 372 | configdlg->showMaximized(); |
313 | configdlg->show(); | 373 | configdlg->show(); |
314 | configdlg->raise(); | 374 | configdlg->raise(); |
315 | } | 375 | } |
@@ -358,13 +418,20 @@ void Keyboard::mousePressEvent(QMouseEvent *e) | |||
358 | *lock = 0; | 418 | *lock = 0; |
359 | lock = 0; | 419 | lock = 0; |
360 | } | 420 | } |
361 | } | 421 | } |
362 | if (meta) { | ||
363 | 422 | ||
364 | *meta = 0; | 423 | |
365 | meta = 0; | 424 | /* |
366 | } | 425 | * want to be able to hit circumflex/diaeresis -> shift |
426 | * to type in shifted circumflex/diaeresis chars. | ||
427 | * same thing with meta | ||
428 | |||
429 | if (meta) { *meta = 0; meta = 0; } | ||
430 | if (circumflex) { *circumflex = 0; circumflex = 0; } | ||
431 | if (diaeresis) { *diaeresis = 0; diaeresis = 0; } | ||
432 | |||
433 | */ | ||
367 | 434 | ||
368 | } else if (qkeycode == Qt::Key_CapsLock) { | 435 | } else if (qkeycode == Qt::Key_CapsLock) { |
369 | need_repaint = TRUE; | 436 | need_repaint = TRUE; |
370 | 437 | ||
@@ -373,19 +440,20 @@ void Keyboard::mousePressEvent(QMouseEvent *e) | |||
373 | lock = 0; | 440 | lock = 0; |
374 | } | 441 | } |
375 | else { | 442 | else { |
376 | lock = keys->pressedPtr(row, col);; | 443 | lock = keys->pressedPtr(row, col);; |
377 | *lock = 1; | 444 | *lock = true;; |
378 | if (shift) { | 445 | if (shift) { |
379 | *shift = 0; | 446 | *shift = 0; |
380 | shift = 0; | 447 | shift = 0; |
381 | } | 448 | } |
382 | } | 449 | } |
383 | if (meta) { | ||
384 | 450 | ||
385 | *meta = 0; | 451 | /* |
386 | meta = 0; | 452 | if (meta) { *meta = 0; meta = 0; } |
387 | } | 453 | if (circumflex) { *circumflex = 0; circumflex = 0; } |
454 | if (diaeresis) { *diaeresis = 0; diaeresis = 0; } | ||
455 | */ | ||
388 | 456 | ||
389 | } else if (qkeycode == Qt::Key_Meta) { | 457 | } else if (qkeycode == Qt::Key_Meta) { |
390 | need_repaint = TRUE; | 458 | need_repaint = TRUE; |
391 | 459 | ||
@@ -395,37 +463,123 @@ void Keyboard::mousePressEvent(QMouseEvent *e) | |||
395 | 463 | ||
396 | } else { | 464 | } else { |
397 | 465 | ||
398 | meta = keys->pressedPtr(row, col); | 466 | meta = keys->pressedPtr(row, col); |
399 | need_repaint = TRUE; | 467 | *meta = true; |
400 | *meta = !keys->pressed(row, col); | ||
401 | } | 468 | } |
402 | 469 | ||
403 | if (shift) { | 470 | // reset all the other keys |
471 | if (shift) { *shift = 0; shift = 0; } | ||
472 | if (lock) { *lock = 0; lock = 0; } | ||
473 | if (circumflex) { *circumflex = 0; circumflex = 0; } | ||
474 | if (diaeresis) { *diaeresis = 0; diaeresis = 0; } | ||
404 | 475 | ||
405 | *shift = 0; | 476 | // dont need to emit this key... acts same as alt |
406 | shift = 0; | 477 | qkeycode = 0; |
478 | |||
479 | // circumflex | ||
480 | } else if (qkeycode == 0x2000) { | ||
481 | need_repaint = TRUE; | ||
482 | |||
483 | if (circumflex) { | ||
484 | |||
485 | *circumflex = 0; | ||
486 | circumflex = 0; | ||
487 | |||
488 | } else { | ||
407 | 489 | ||
490 | circumflex = keys->pressedPtr(row, col); | ||
491 | *circumflex = true; | ||
408 | } | 492 | } |
409 | if (lock) { | ||
410 | 493 | ||
411 | *lock = 0; | 494 | /* no need to turn off shift or lock if circumflex |
412 | lock = 0; | 495 | * keys are pressed |
496 | |||
497 | if (shift) { *shift = 0; shift = 0; } | ||
498 | if (lock) { *lock = 0; lock = 0; } | ||
499 | |||
500 | */ | ||
501 | |||
502 | // have to reset all the other keys | ||
503 | if (meta) { *meta = 0; meta = 0; } | ||
504 | if (diaeresis) { | ||
505 | |||
506 | // *diaeresis and *circumflex point to the same thing | ||
507 | // when diaeresis is enabled and you hit the circumflex | ||
508 | // since they are the same key, it should turn off the | ||
509 | // key | ||
510 | |||
511 | *diaeresis = 0; | ||
512 | diaeresis = 0; | ||
513 | circumflex = 0; | ||
514 | } | ||
515 | |||
516 | qkeycode = 0; | ||
413 | 517 | ||
518 | // diaeresis | ||
519 | } else if (qkeycode == 0x2001) { | ||
520 | need_repaint = TRUE; | ||
521 | |||
522 | if (diaeresis) { | ||
523 | |||
524 | *diaeresis = 0; | ||
525 | diaeresis = 0; | ||
526 | |||
527 | } else { | ||
528 | |||
529 | diaeresis = keys->pressedPtr(row, col); | ||
530 | *diaeresis = true; | ||
414 | } | 531 | } |
415 | 532 | ||
416 | // dont need to emit this key... acts same as alt | 533 | |
534 | if (shift) { *shift = 0; shift = 0; } | ||
535 | |||
536 | /* | ||
537 | * | ||
538 | if (lock) { *lock = 0; lock = 0; } | ||
539 | * | ||
540 | */ | ||
541 | |||
542 | if (meta) { *meta = 0; meta = 0; } | ||
543 | if (circumflex) { | ||
544 | |||
545 | // *circumflex = 0; | ||
546 | // | ||
547 | // same thing the diaeresis pointer points too | ||
548 | |||
549 | circumflex = 0; | ||
550 | } | ||
551 | |||
552 | |||
417 | qkeycode = 0; | 553 | qkeycode = 0; |
418 | } | 554 | } |
419 | 555 | ||
420 | } | 556 | } |
421 | else { // normal char | 557 | else { // normal char |
422 | if ((shift || lock) && keys->shift(unicode)) { | 558 | if ((shift || lock) && keys->shift(unicode)) { |
423 | unicode = keys->shift(unicode); | 559 | |
560 | // make diaeresis/circumflex -> shift input shifted | ||
561 | // diaeresis/circumflex chars | ||
562 | |||
563 | if (circumflex && keys->circumflex(keys->shift(unicode))) | ||
564 | unicode = keys->circumflex(keys->shift(unicode)); | ||
565 | else if (diaeresis && keys->diaeresis(keys->shift(unicode))) | ||
566 | unicode = keys->diaeresis(keys->shift(unicode)); | ||
567 | else if (meta && keys->meta(keys->shift(unicode))) | ||
568 | unicode = keys->meta(keys->shift(unicode)); | ||
569 | else | ||
570 | unicode = keys->shift(unicode); | ||
424 | } | 571 | } |
425 | if (meta && keys->meta(unicode)) { | 572 | else if (meta && keys->meta(unicode)) { |
426 | unicode = keys->meta(unicode); | 573 | unicode = keys->meta(unicode); |
427 | } | 574 | } |
575 | else if (circumflex && keys->circumflex(unicode)) { | ||
576 | unicode = keys->circumflex(unicode); | ||
577 | } | ||
578 | else if (diaeresis && keys->diaeresis(unicode)) { | ||
579 | |||
580 | unicode = keys->diaeresis(unicode); | ||
581 | } | ||
428 | } | 582 | } |
429 | 583 | ||
430 | // korean parsing | 584 | // korean parsing |
431 | if (keys->lang == "ko") { | 585 | if (keys->lang == "ko") { |
@@ -503,17 +657,24 @@ void Keyboard::mouseReleaseEvent(QMouseEvent*) | |||
503 | *shift = 0; // unpress shift key | 657 | *shift = 0; // unpress shift key |
504 | shift = 0; // reset the shift pointer | 658 | shift = 0; // reset the shift pointer |
505 | repaint(FALSE); | 659 | repaint(FALSE); |
506 | 660 | ||
507 | } else if (meta && unicode != 0) { | 661 | } |
662 | |||
663 | /* | ||
664 | * do not make the meta key release after being pressed | ||
665 | * | ||
666 | |||
667 | else if (meta && unicode != 0) { | ||
508 | 668 | ||
509 | *meta = 0; | 669 | *meta = 0; |
510 | meta = 0; | 670 | meta = 0; |
511 | repaint(FALSE); | 671 | repaint(FALSE); |
512 | } | 672 | } |
513 | else | ||
514 | 673 | ||
515 | clearHighlight(); | 674 | */ |
675 | |||
676 | else clearHighlight(); | ||
516 | } | 677 | } |
517 | 678 | ||
518 | /* Keyboard::timerEvent {{{1 */ | 679 | /* Keyboard::timerEvent {{{1 */ |
519 | 680 | ||
@@ -560,14 +721,20 @@ QSize Keyboard::sizeHint() const | |||
560 | { | 721 | { |
561 | QFontMetrics fm=fontMetrics(); | 722 | QFontMetrics fm=fontMetrics(); |
562 | int keyHeight = fm.lineSpacing() + 2; | 723 | int keyHeight = fm.lineSpacing() + 2; |
563 | 724 | ||
564 | return QSize( 240, keyHeight * 5 + (usePicks ? picks->sizeHint().height() : 0) + 1); | 725 | return QSize( 240, keyHeight * keys->rows() + (usePicks ? picks->sizeHint().height() : 0) + 1); |
565 | } | 726 | } |
566 | 727 | ||
567 | 728 | ||
568 | void Keyboard::resetState() | 729 | void Keyboard::resetState() |
569 | { | 730 | { |
731 | if (shift) { *shift = 0; shift = 0; } | ||
732 | if (lock) {*lock = 0; lock = 0; } | ||
733 | if (meta) { *meta = 0; meta = 0; } | ||
734 | if (circumflex) { *circumflex = 0; circumflex = 0; } | ||
735 | if (diaeresis) { *diaeresis = 0; diaeresis = 0; } | ||
736 | |||
570 | schar = mchar = echar = 0; | 737 | schar = mchar = echar = 0; |
571 | picks->resetState(); | 738 | picks->resetState(); |
572 | } | 739 | } |
573 | 740 | ||
@@ -603,8 +770,16 @@ void Keyboard::toggleRepeat(bool on) { | |||
603 | useRepeat = on; | 770 | useRepeat = on; |
604 | //cout << "setting useRepeat to: " << useRepeat << "\n"; | 771 | //cout << "setting useRepeat to: " << useRepeat << "\n"; |
605 | } | 772 | } |
606 | 773 | ||
774 | void Keyboard::cleanupConfigDlg() { | ||
775 | |||
776 | if ( configdlg ) { | ||
777 | delete (ConfigDlg *) configdlg; | ||
778 | configdlg = 0; | ||
779 | } | ||
780 | } | ||
781 | |||
607 | /* Keyboard::setMapTo ... {{{1 */ | 782 | /* Keyboard::setMapTo ... {{{1 */ |
608 | void Keyboard::setMapToDefault() { | 783 | void Keyboard::setMapToDefault() { |
609 | 784 | ||
610 | 785 | ||
@@ -613,22 +788,31 @@ void Keyboard::setMapToDefault() { | |||
613 | config->setGroup( "Language" ); | 788 | config->setGroup( "Language" ); |
614 | QString l = config->readEntry( "Language" , "en" ); | 789 | QString l = config->readEntry( "Language" , "en" ); |
615 | delete config; | 790 | delete config; |
616 | 791 | ||
617 | QString key_map = QPEApplication::qpeDir() + "/share/multikey/" | 792 | QString key_map = QPEApplication::qpeDir() + "share/multikey/" |
618 | + l + ".keymap"; | 793 | + l + ".keymap"; |
619 | 794 | ||
620 | /* save change to multikey config file */ | 795 | /* save change to multikey config file */ |
621 | config = new Config("multikey"); | 796 | config = new Config("multikey"); |
622 | config->setGroup ("keymaps"); | 797 | config->setGroup ("keymaps"); |
623 | config->writeEntry ("current", key_map); // default closed | 798 | config->writeEntry ("current", key_map); // default closed |
624 | delete config; | 799 | delete config; |
625 | 800 | ||
801 | int prevRows = keys->rows(); | ||
802 | |||
626 | delete keys; | 803 | delete keys; |
627 | keys = new Keys(key_map); | 804 | keys = new Keys(key_map); |
628 | 805 | ||
629 | // have to repaint the keyboard | 806 | // have to repaint the keyboard |
630 | repaint(FALSE); | 807 | if (prevRows != keys->rows()) { |
808 | |||
809 | QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); | ||
810 | QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); | ||
811 | |||
812 | } else repaint(FALSE); | ||
813 | |||
814 | resetState(); | ||
631 | } | 815 | } |
632 | 816 | ||
633 | void Keyboard::setMapToFile(QString map) { | 817 | void Keyboard::setMapToFile(QString map) { |
634 | 818 | ||
@@ -638,16 +822,24 @@ void Keyboard::setMapToFile(QString map) { | |||
638 | config->writeEntry ("current", map); // default closed | 822 | config->writeEntry ("current", map); // default closed |
639 | 823 | ||
640 | delete config; | 824 | delete config; |
641 | 825 | ||
826 | int prevRows = keys->rows(); | ||
827 | |||
642 | delete keys; | 828 | delete keys; |
643 | if (QFile(map).exists()) | 829 | if (QFile(map).exists()) |
644 | keys = new Keys(map); | 830 | keys = new Keys(map); |
645 | else | 831 | else |
646 | keys = new Keys(); | 832 | keys = new Keys(); |
647 | 833 | ||
648 | repaint(FALSE); | 834 | if (keys->rows() != prevRows) { |
835 | |||
836 | QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); | ||
837 | QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); | ||
838 | } | ||
839 | else repaint(FALSE); | ||
649 | 840 | ||
841 | resetState(); | ||
650 | } | 842 | } |
651 | 843 | ||
652 | /* Keybaord::reloadKeyboard {{{1 */ | 844 | /* Keybaord::reloadKeyboard {{{1 */ |
653 | void Keyboard::reloadKeyboard() { | 845 | void Keyboard::reloadKeyboard() { |
@@ -1123,8 +1315,33 @@ void Keys::setKeysFromFile(const char * filename) { | |||
1123 | 1315 | ||
1124 | buf = t.readLine(); | 1316 | buf = t.readLine(); |
1125 | } | 1317 | } |
1126 | 1318 | ||
1319 | // circumflex | ||
1320 | else if (buf.contains(QRegExp("^\\s*c\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { | ||
1321 | |||
1322 | QTextStream tmp (buf, IO_ReadOnly); | ||
1323 | ushort lower, shift; | ||
1324 | QChar c; | ||
1325 | tmp >> c >> lower >> shift; | ||
1326 | |||
1327 | circumflexMap.insert(lower, shift); | ||
1328 | |||
1329 | buf = t.readLine(); | ||
1330 | } | ||
1331 | // diaeresis | ||
1332 | else if (buf.contains(QRegExp("^\\s*d\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { | ||
1333 | |||
1334 | QTextStream tmp (buf, IO_ReadOnly); | ||
1335 | ushort lower, shift; | ||
1336 | QChar d; | ||
1337 | tmp >> d >> lower >> shift; | ||
1338 | |||
1339 | diaeresisMap.insert(lower, shift); | ||
1340 | |||
1341 | buf = t.readLine(); | ||
1342 | } | ||
1343 | |||
1127 | // other variables like lang & title | 1344 | // other variables like lang & title |
1128 | else if (buf.contains(QRegExp("^\\s*[a-zA-Z]+\\s*=\\s*[a-zA-Z0-9/]+\\s*$", FALSE, FALSE))) { | 1345 | else if (buf.contains(QRegExp("^\\s*[a-zA-Z]+\\s*=\\s*[a-zA-Z0-9/]+\\s*$", FALSE, FALSE))) { |
1129 | 1346 | ||
1130 | QTextStream tmp (buf, IO_ReadOnly); | 1347 | QTextStream tmp (buf, IO_ReadOnly); |
@@ -1204,8 +1421,20 @@ int Keys::width(const int row, const int col) { | |||
1204 | 1421 | ||
1205 | return keys[row].at(col)->width; | 1422 | return keys[row].at(col)->width; |
1206 | 1423 | ||
1207 | } | 1424 | } |
1425 | |||
1426 | int Keys::rows() { | ||
1427 | |||
1428 | for (int i = 1; i <= 5; i++) { | ||
1429 | |||
1430 | if (keys[i].count() == 0) | ||
1431 | return i - 1; | ||
1432 | |||
1433 | } | ||
1434 | return 5; | ||
1435 | } | ||
1436 | |||
1208 | ushort Keys::uni(const int row, const int col) { | 1437 | ushort Keys::uni(const int row, const int col) { |
1209 | 1438 | ||
1210 | return keys[row].at(col)->unicode; | 1439 | return keys[row].at(col)->unicode; |
1211 | 1440 | ||
@@ -1237,26 +1466,28 @@ void Keys::setPressed(const int row, const int col, const bool pressed) { | |||
1237 | } | 1466 | } |
1238 | 1467 | ||
1239 | ushort Keys::shift(const ushort uni) { | 1468 | ushort Keys::shift(const ushort uni) { |
1240 | 1469 | ||
1241 | if (shiftMap[uni]) { | 1470 | if (shiftMap[uni]) return shiftMap[uni]; |
1471 | else return 0; | ||
1472 | } | ||
1242 | 1473 | ||
1243 | return shiftMap[uni]; | 1474 | ushort Keys::meta(const ushort uni) { |
1244 | } | ||
1245 | else | ||
1246 | return 0; | ||
1247 | 1475 | ||
1476 | if (metaMap[uni]) return metaMap[uni]; | ||
1477 | else return 0; | ||
1248 | } | 1478 | } |
1249 | 1479 | ||
1250 | ushort Keys::meta(const ushort uni) { | 1480 | ushort Keys::circumflex(const ushort uni) { |
1251 | 1481 | ||
1252 | if (metaMap[uni]) { | 1482 | if (circumflexMap[uni]) return circumflexMap[uni]; |
1483 | else return 0; | ||
1484 | } | ||
1253 | 1485 | ||
1254 | return metaMap[uni]; | 1486 | ushort Keys::diaeresis(const ushort uni) { |
1255 | } | ||
1256 | else | ||
1257 | return 0; | ||
1258 | 1487 | ||
1488 | if(diaeresisMap[uni]) return diaeresisMap[uni]; | ||
1489 | else return 0; | ||
1259 | } | 1490 | } |
1260 | 1491 | ||
1261 | bool *Keys::pressedPtr(const int row, const int col) { | 1492 | bool *Keys::pressedPtr(const int row, const int col) { |
1262 | 1493 | ||