-rw-r--r-- | inputmethods/multikey/keyboard.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp index 3e43978..d0cfa51 100644 --- a/inputmethods/multikey/keyboard.cpp +++ b/inputmethods/multikey/keyboard.cpp | |||
@@ -425,97 +425,98 @@ void Keyboard::timerEvent(QTimerEvent* e) | |||
425 | } | 425 | } |
426 | */ | 426 | */ |
427 | 427 | ||
428 | void Keyboard::repeat() | 428 | void Keyboard::repeat() |
429 | { | 429 | { |
430 | 430 | ||
431 | repeatTimer->start( 200 ); | 431 | repeatTimer->start( 200 ); |
432 | emit key( unicode, 0, modifiers, true, true ); | 432 | emit key( unicode, 0, modifiers, true, true ); |
433 | } | 433 | } |
434 | 434 | ||
435 | void Keyboard::clearHighlight() | 435 | void Keyboard::clearHighlight() |
436 | { | 436 | { |
437 | if ( pressedKeyRow >= 0 && pressedKeyCol >= 0) { | 437 | if ( pressedKeyRow >= 0 && pressedKeyCol >= 0) { |
438 | int tmpRow = pressedKeyRow; | 438 | int tmpRow = pressedKeyRow; |
439 | int tmpCol = pressedKeyCol; | 439 | int tmpCol = pressedKeyCol; |
440 | 440 | ||
441 | pressedKeyRow = -1; | 441 | pressedKeyRow = -1; |
442 | pressedKeyCol = -1; | 442 | pressedKeyCol = -1; |
443 | 443 | ||
444 | QPainter p(this); | 444 | QPainter p(this); |
445 | drawKeyboard(p, tmpRow, tmpCol); | 445 | drawKeyboard(p, tmpRow, tmpCol); |
446 | } | 446 | } |
447 | } | 447 | } |
448 | 448 | ||
449 | 449 | ||
450 | /* Keyboard::sizeHint {{{1 */ | 450 | /* Keyboard::sizeHint {{{1 */ |
451 | QSize Keyboard::sizeHint() const | 451 | QSize Keyboard::sizeHint() const |
452 | { | 452 | { |
453 | QFontMetrics fm=fontMetrics(); | 453 | QFontMetrics fm=fontMetrics(); |
454 | int keyHeight = fm.lineSpacing(); | 454 | int keyHeight = fm.lineSpacing(); |
455 | 455 | ||
456 | return QSize( 240, keyHeight * 5 + (usePicks ? picks->sizeHint().height() : 0) + 1); | 456 | return QSize( 240, keyHeight * 5 + (usePicks ? picks->sizeHint().height() : 0) + 1); |
457 | } | 457 | } |
458 | 458 | ||
459 | 459 | ||
460 | void Keyboard::resetState() | 460 | void Keyboard::resetState() |
461 | { | 461 | { |
462 | schar = mchar = echar = 0; | 462 | schar = mchar = echar = 0; |
463 | picks->resetState(); | 463 | picks->resetState(); |
464 | } | 464 | } |
465 | 465 | ||
466 | /* korean input functions {{{1 | 466 | /* korean input functions {{{1 |
467 | * | 467 | * |
468 | * TODO | 468 | * TODO |
469 | * one major problem with this implementation is that you can't move the | 469 | * one major problem with this implementation is that you can't move the |
470 | * cursor after inputing korean chars, otherwise it will eat up and replace | 470 | * cursor after inputing korean chars, otherwise it will eat up and replace |
471 | * the char before the cursor you move to. fix that | 471 | * the char before the cursor you move to. fix that |
472 | * | 472 | * |
473 | * make a kor/eng swaping key | 473 | * make backspace delete one single char, not the whole thing if still |
474 | * editing. | ||
474 | * | 475 | * |
475 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | 476 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
476 | * | 477 | * |
477 | * how korean input works | 478 | * how korean input works |
478 | * | 479 | * |
479 | * all following chars means unicode char value and are in hex | 480 | * all following chars means unicode char value and are in hex |
480 | * | 481 | * |
481 | * ÃÊÀ½ = schar (start char) | 482 | * ÃÊÀ½ = schar (start char) |
482 | * ÁßÀ½ = mchar (middle char) | 483 | * ÁßÀ½ = mchar (middle char) |
483 | * ³¡À½ = echar (end char) | 484 | * ³¡À½ = echar (end char) |
484 | * | 485 | * |
485 | * there are 19 schars. unicode position is at 1100 - 1112 | 486 | * there are 19 schars. unicode position is at 1100 - 1112 |
486 | * there are 21 mchars. unicode position is at 1161 - 1175 | 487 | * there are 21 mchars. unicode position is at 1161 - 1175 |
487 | * there are 27 echars. unicode position is at 11a8 - 11c2 | 488 | * there are 27 echars. unicode position is at 11a8 - 11c2 |
488 | * | 489 | * |
489 | * the map with everything combined is at ac00 - d7a3 | 490 | * the map with everything combined is at ac00 - d7a3 |
490 | * | 491 | * |
491 | */ | 492 | */ |
492 | 493 | ||
493 | ushort Keyboard::parseKoreanInput (ushort c) { | 494 | ushort Keyboard::parseKoreanInput (ushort c) { |
494 | 495 | ||
495 | if ((c != 0 && (c < 0x1100 || 0x11c2 < c) && (c < 0xac00 || 0xd7a3 < c)) | 496 | if ((c != 0 && (c < 0x1100 || 0x11c2 < c) && (c < 0xac00 || 0xd7a3 < c)) |
496 | || | 497 | || |
497 | (c == 0 && qkeycode != Qt::Key_Shift && Qt::Key_CapsLock != qkeycode | 498 | (c == 0 && qkeycode != Qt::Key_Shift && Qt::Key_CapsLock != qkeycode |
498 | && qkeycode != Qt::Key_Control && qkeycode != Qt::Key_Alt)) { | 499 | && qkeycode != Qt::Key_Control && qkeycode != Qt::Key_Alt)) { |
499 | 500 | ||
500 | schar = 0, mchar = 0, echar = 0; | 501 | schar = 0, mchar = 0, echar = 0; |
501 | return c; | 502 | return c; |
502 | } | 503 | } |
503 | 504 | ||
504 | if ( 0x1100 <= c && c <= 0x1112 ) { // schar or echar was input | 505 | if ( 0x1100 <= c && c <= 0x1112 ) { // schar or echar was input |
505 | 506 | ||
506 | if (schar == 0 || (schar != 0 && mchar == 0)) { | 507 | if (schar == 0 || (schar != 0 && mchar == 0)) { |
507 | schar = c; mchar = 0; echar = 0; | 508 | schar = c; mchar = 0; echar = 0; |
508 | return c; | 509 | return c; |
509 | } | 510 | } |
510 | else if (mchar != 0) { | 511 | else if (mchar != 0) { |
511 | 512 | ||
512 | if (echar == 0) { | 513 | if (echar == 0) { |
513 | 514 | ||
514 | if (!(echar = constoe(c))) { | 515 | if (!(echar = constoe(c))) { |
515 | 516 | ||
516 | schar = c; mchar = 0; echar = 0; | 517 | schar = c; mchar = 0; echar = 0; |
517 | return c; | 518 | return c; |
518 | } | 519 | } |
519 | 520 | ||
520 | } | 521 | } |
521 | else { // must figure out what the echar is | 522 | else { // must figure out what the echar is |
@@ -725,98 +726,97 @@ ushort Keyboard::constoe(const ushort c) { | |||
725 | case 0x1106: return 0x11b7; | 726 | case 0x1106: return 0x11b7; |
726 | case 0x1107: return 0x11b8; | 727 | case 0x1107: return 0x11b8; |
727 | case 0x1109: return 0x11ba; | 728 | case 0x1109: return 0x11ba; |
728 | case 0x110a: return 0x11bb; | 729 | case 0x110a: return 0x11bb; |
729 | case 0x110b: return 0x11bc; | 730 | case 0x110b: return 0x11bc; |
730 | case 0x110c: return 0x11bd; | 731 | case 0x110c: return 0x11bd; |
731 | case 0x110e: return 0x11be; | 732 | case 0x110e: return 0x11be; |
732 | case 0x110f: return 0x11bf; | 733 | case 0x110f: return 0x11bf; |
733 | case 0x1110: return 0x11c0; | 734 | case 0x1110: return 0x11c0; |
734 | case 0x1111: return 0x11c1; | 735 | case 0x1111: return 0x11c1; |
735 | case 0x1112: return 0x11c2; | 736 | case 0x1112: return 0x11c2; |
736 | default: return 0; | 737 | default: return 0; |
737 | 738 | ||
738 | } | 739 | } |
739 | 740 | ||
740 | } else { //echar to schar | 741 | } else { //echar to schar |
741 | 742 | ||
742 | switch (c) { | 743 | switch (c) { |
743 | case 0x11a8: return 0x1100; | 744 | case 0x11a8: return 0x1100; |
744 | case 0x11a9: return 0x1101; | 745 | case 0x11a9: return 0x1101; |
745 | case 0x11ab: return 0x1102; | 746 | case 0x11ab: return 0x1102; |
746 | case 0x11ae: return 0x1103; | 747 | case 0x11ae: return 0x1103; |
747 | case 0x11af: return 0x1105; | 748 | case 0x11af: return 0x1105; |
748 | case 0x11b7: return 0x1106; | 749 | case 0x11b7: return 0x1106; |
749 | case 0x11b8: return 0x1107; | 750 | case 0x11b8: return 0x1107; |
750 | case 0x11ba: return 0x1109; | 751 | case 0x11ba: return 0x1109; |
751 | case 0x11bb: return 0x110a; | 752 | case 0x11bb: return 0x110a; |
752 | case 0x11bc: return 0x110b; | 753 | case 0x11bc: return 0x110b; |
753 | case 0x11bd: return 0x110c; | 754 | case 0x11bd: return 0x110c; |
754 | case 0x11be: return 0x110e; | 755 | case 0x11be: return 0x110e; |
755 | case 0x11bf: return 0x110f; | 756 | case 0x11bf: return 0x110f; |
756 | case 0x11c0: return 0x1110; | 757 | case 0x11c0: return 0x1110; |
757 | case 0x11c1: return 0x1111; | 758 | case 0x11c1: return 0x1111; |
758 | case 0x11c2: return 0x1112; | 759 | case 0x11c2: return 0x1112; |
759 | default: return 0; | 760 | default: return 0; |
760 | 761 | ||
761 | } | 762 | } |
762 | 763 | ||
763 | } | 764 | } |
764 | } | 765 | } |
765 | 766 | ||
766 | 767 | ||
767 | // Keys::Keys {{{1 | 768 | // Keys::Keys {{{1 |
768 | 769 | ||
769 | Keys::Keys() { | 770 | Keys::Keys() { |
770 | 771 | ||
771 | Config config("locale"); | 772 | Config config("locale"); |
772 | config.setGroup( "Language" ); | 773 | config.setGroup( "Language" ); |
773 | QString l = config.readEntry( "Language" ); | 774 | QString l = config.readEntry( "Language" , "en" ); |
774 | if(l.isEmpty()) l = "en"; | ||
775 | 775 | ||
776 | QString key_map = QPEApplication::qpeDir() + "/share/multikey/" | 776 | QString key_map = QPEApplication::qpeDir() + "/share/multikey/" |
777 | + /* l // testing korean for now */ | 777 | + /* l // testing korean for now */ |
778 | + "ko.keymap"; | 778 | + "ko.keymap"; |
779 | 779 | ||
780 | setKeysFromFile(key_map); | 780 | setKeysFromFile(key_map); |
781 | } | 781 | } |
782 | 782 | ||
783 | Keys::Keys(const char * filename) { | 783 | Keys::Keys(const char * filename) { |
784 | 784 | ||
785 | setKeysFromFile(filename); | 785 | setKeysFromFile(filename); |
786 | } | 786 | } |
787 | 787 | ||
788 | // Keys::setKeysFromFile {{{2 | 788 | // Keys::setKeysFromFile {{{2 |
789 | void Keys::setKeysFromFile(const char * filename) { | 789 | void Keys::setKeysFromFile(const char * filename) { |
790 | 790 | ||
791 | QFile f(filename); | 791 | QFile f(filename); |
792 | 792 | ||
793 | if (f.open(IO_ReadOnly)) { | 793 | if (f.open(IO_ReadOnly)) { |
794 | 794 | ||
795 | QTextStream t(&f); | 795 | QTextStream t(&f); |
796 | int row; | 796 | int row; |
797 | int qcode; | 797 | int qcode; |
798 | ushort unicode; | 798 | ushort unicode; |
799 | int width; | 799 | int width; |
800 | QString buf; | 800 | QString buf; |
801 | QString comment; | 801 | QString comment; |
802 | char * xpm[256]; //couldnt be larger than that... could it? | 802 | char * xpm[256]; //couldnt be larger than that... could it? |
803 | QPixmap *xpm2pix = 0; | 803 | QPixmap *xpm2pix = 0; |
804 | 804 | ||
805 | buf = t.readLine(); | 805 | buf = t.readLine(); |
806 | while (buf) { | 806 | while (buf) { |
807 | 807 | ||
808 | if (buf.contains(QRegExp("^\\d+\\s+[0-1a-fx]+", FALSE, FALSE))) { | 808 | if (buf.contains(QRegExp("^\\d+\\s+[0-1a-fx]+", FALSE, FALSE))) { |
809 | // no $1 type referencing!!! this implementation of regexp sucks | 809 | // no $1 type referencing!!! this implementation of regexp sucks |
810 | 810 | ||
811 | // dont know of any sscanf() type funcs in Qt lib | 811 | // dont know of any sscanf() type funcs in Qt lib |
812 | QTextStream tmp (buf, IO_ReadOnly); | 812 | QTextStream tmp (buf, IO_ReadOnly); |
813 | tmp >> row >> qcode >> unicode >> width >> comment; | 813 | tmp >> row >> qcode >> unicode >> width >> comment; |
814 | 814 | ||
815 | buf = t.readLine(); | 815 | buf = t.readLine(); |
816 | int xpmLineCount = 0; | 816 | int xpmLineCount = 0; |
817 | xpm2pix = 0; | 817 | xpm2pix = 0; |
818 | 818 | ||
819 | // erase blank space | 819 | // erase blank space |
820 | while (buf.contains(QRegExp("^\\s*$")) && buf) buf = t.readLine(); | 820 | while (buf.contains(QRegExp("^\\s*$")) && buf) buf = t.readLine(); |
821 | 821 | ||
822 | while (buf.contains(QRegExp("^\\s*\".*\""))) { | 822 | while (buf.contains(QRegExp("^\\s*\".*\""))) { |