-rw-r--r-- | inputmethods/multikey/keyboard.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp index d0cfa51..8f4d562 100644 --- a/inputmethods/multikey/keyboard.cpp +++ b/inputmethods/multikey/keyboard.cpp | |||
@@ -17,98 +17,97 @@ | |||
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "keyboard.h" | 21 | #include "keyboard.h" |
22 | 22 | ||
23 | #include <qpe/global.h> | 23 | #include <qpe/global.h> |
24 | 24 | ||
25 | #include <qwindowsystem_qws.h> | 25 | #include <qwindowsystem_qws.h> |
26 | #include <qpainter.h> | 26 | #include <qpainter.h> |
27 | #include <qfontmetrics.h> | 27 | #include <qfontmetrics.h> |
28 | #include <qtimer.h> | 28 | #include <qtimer.h> |
29 | #include <qpe/qpeapplication.h> | 29 | #include <qpe/qpeapplication.h> |
30 | #include <qpe/config.h> | 30 | #include <qpe/config.h> |
31 | #include <ctype.h> | 31 | #include <ctype.h> |
32 | #include <qfile.h> | 32 | #include <qfile.h> |
33 | #include <qtextstream.h> | 33 | #include <qtextstream.h> |
34 | 34 | ||
35 | #include <sys/utsname.h> | 35 | #include <sys/utsname.h> |
36 | 36 | ||
37 | 37 | ||
38 | #define USE_SMALL_BACKSPACE | 38 | #define USE_SMALL_BACKSPACE |
39 | 39 | ||
40 | /* Keyboard::Keyboard {{{1 */ | 40 | /* Keyboard::Keyboard {{{1 */ |
41 | Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : | 41 | Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : |
42 | QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), | 42 | QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), |
43 | alt(0), useLargeKeys(TRUE), usePicks(0), pressedKeyRow(-1), pressedKeyCol(-1), | 43 | alt(0), useLargeKeys(TRUE), usePicks(0), pressedKeyRow(-1), pressedKeyCol(-1), |
44 | unicode(-1), qkeycode(0), modifiers(0), LANG("ko"), schar(0), mchar(0), echar(0) | 44 | unicode(-1), qkeycode(0), modifiers(0), LANG("ko"), schar(0), mchar(0), echar(0) |
45 | { | 45 | { |
46 | // get the default font | 46 | // get the default font |
47 | Config qpeConfig( "qpe" ); | 47 | Config qpeConfig( "qpe" ); |
48 | qpeConfig.setGroup( "Appearance" ); | 48 | qpeConfig.setGroup( "Appearance" ); |
49 | QString familyStr = qpeConfig.readEntry( "FontFamily", "fixed" ); | 49 | QString familyStr = qpeConfig.readEntry( "FontFamily", "fixed" ); |
50 | 50 | ||
51 | setFont( QFont( familyStr, 8 ) ); | 51 | setFont( QFont( familyStr, 8 ) ); |
52 | 52 | ||
53 | picks = new KeyboardPicks( this ); | 53 | picks = new KeyboardPicks( this ); |
54 | picks->setFont( QFont( familyStr, 8 ) ); | 54 | picks->setFont( QFont( familyStr, 8 ) ); |
55 | picks->initialise(); | 55 | picks->initialise(); |
56 | if (usePicks) { | 56 | if (usePicks) { |
57 | 57 | ||
58 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), | 58 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), |
59 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); | 59 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); |
60 | 60 | ||
61 | } else picks->hide(); | 61 | } else picks->hide(); |
62 | 62 | ||
63 | Config config("locale"); | 63 | Config config("locale"); |
64 | config.setGroup( "Language" ); | 64 | config.setGroup( "Language" ); |
65 | //LANG = config.readEntry( "Language", "en" ); | 65 | LANG = config.readEntry( "Language", "en" ); |
66 | LANG = "ko"; | ||
67 | 66 | ||
68 | repeatTimer = new QTimer( this ); | 67 | repeatTimer = new QTimer( this ); |
69 | connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); | 68 | connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); |
70 | 69 | ||
71 | } | 70 | } |
72 | 71 | ||
73 | /* Keyboard::resizeEvent {{{1 */ | 72 | /* Keyboard::resizeEvent {{{1 */ |
74 | void Keyboard::resizeEvent(QResizeEvent*) | 73 | void Keyboard::resizeEvent(QResizeEvent*) |
75 | { | 74 | { |
76 | int ph = picks->sizeHint().height(); | 75 | int ph = picks->sizeHint().height(); |
77 | picks->setGeometry( 0, 0, width(), ph ); | 76 | picks->setGeometry( 0, 0, width(), ph ); |
78 | keyHeight = (height()-(usePicks ? ph : 0))/5; | 77 | keyHeight = (height()-(usePicks ? ph : 0))/5; |
79 | 78 | ||
80 | int nk; // number of keys? | 79 | int nk; // number of keys? |
81 | if ( useLargeKeys ) { | 80 | if ( useLargeKeys ) { |
82 | nk = 15; | 81 | nk = 15; |
83 | } else { | 82 | } else { |
84 | nk = 19; | 83 | nk = 19; |
85 | } | 84 | } |
86 | defaultKeyWidth = (width()/nk)/2; | 85 | defaultKeyWidth = (width()/nk)/2; |
87 | xoffs = (width()-defaultKeyWidth*nk)/2; // empty key spaces? | 86 | xoffs = (width()-defaultKeyWidth*nk)/2; // empty key spaces? |
88 | 87 | ||
89 | } | 88 | } |
90 | 89 | ||
91 | /* KeyboardPicks::initialize {{{1 */ | 90 | /* KeyboardPicks::initialize {{{1 */ |
92 | void KeyboardPicks::initialise() | 91 | void KeyboardPicks::initialise() |
93 | { | 92 | { |
94 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); | 93 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); |
95 | mode = 0; | 94 | mode = 0; |
96 | dc = new KeyboardConfig(this); | 95 | dc = new KeyboardConfig(this); |
97 | configs.append(dc); | 96 | configs.append(dc); |
98 | } | 97 | } |
99 | 98 | ||
100 | /* KeyboardPicks::sizeHint {{{1 */ | 99 | /* KeyboardPicks::sizeHint {{{1 */ |
101 | QSize KeyboardPicks::sizeHint() const | 100 | QSize KeyboardPicks::sizeHint() const |
102 | { | 101 | { |
103 | return QSize(240,fontMetrics().lineSpacing()); | 102 | return QSize(240,fontMetrics().lineSpacing()); |
104 | } | 103 | } |
105 | 104 | ||
106 | 105 | ||
107 | /* KeyboardConfig::generateText {{{1 */ | 106 | /* KeyboardConfig::generateText {{{1 */ |
108 | void KeyboardConfig::generateText(const QString &s) | 107 | void KeyboardConfig::generateText(const QString &s) |
109 | { | 108 | { |
110 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 109 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
111 | for (int i=0; i<(int)backspaces; i++) { | 110 | for (int i=0; i<(int)backspaces; i++) { |
112 | parent->emitKey( 0, Qt::Key_Backspace, 0, true, false ); | 111 | parent->emitKey( 0, Qt::Key_Backspace, 0, true, false ); |
113 | parent->emitKey( 0, Qt::Key_Backspace, 0, false, false ); | 112 | parent->emitKey( 0, Qt::Key_Backspace, 0, false, false ); |
114 | } | 113 | } |
@@ -729,98 +728,97 @@ ushort Keyboard::constoe(const ushort c) { | |||
729 | case 0x110a: return 0x11bb; | 728 | case 0x110a: return 0x11bb; |
730 | case 0x110b: return 0x11bc; | 729 | case 0x110b: return 0x11bc; |
731 | case 0x110c: return 0x11bd; | 730 | case 0x110c: return 0x11bd; |
732 | case 0x110e: return 0x11be; | 731 | case 0x110e: return 0x11be; |
733 | case 0x110f: return 0x11bf; | 732 | case 0x110f: return 0x11bf; |
734 | case 0x1110: return 0x11c0; | 733 | case 0x1110: return 0x11c0; |
735 | case 0x1111: return 0x11c1; | 734 | case 0x1111: return 0x11c1; |
736 | case 0x1112: return 0x11c2; | 735 | case 0x1112: return 0x11c2; |
737 | default: return 0; | 736 | default: return 0; |
738 | 737 | ||
739 | } | 738 | } |
740 | 739 | ||
741 | } else { //echar to schar | 740 | } else { //echar to schar |
742 | 741 | ||
743 | switch (c) { | 742 | switch (c) { |
744 | case 0x11a8: return 0x1100; | 743 | case 0x11a8: return 0x1100; |
745 | case 0x11a9: return 0x1101; | 744 | case 0x11a9: return 0x1101; |
746 | case 0x11ab: return 0x1102; | 745 | case 0x11ab: return 0x1102; |
747 | case 0x11ae: return 0x1103; | 746 | case 0x11ae: return 0x1103; |
748 | case 0x11af: return 0x1105; | 747 | case 0x11af: return 0x1105; |
749 | case 0x11b7: return 0x1106; | 748 | case 0x11b7: return 0x1106; |
750 | case 0x11b8: return 0x1107; | 749 | case 0x11b8: return 0x1107; |
751 | case 0x11ba: return 0x1109; | 750 | case 0x11ba: return 0x1109; |
752 | case 0x11bb: return 0x110a; | 751 | case 0x11bb: return 0x110a; |
753 | case 0x11bc: return 0x110b; | 752 | case 0x11bc: return 0x110b; |
754 | case 0x11bd: return 0x110c; | 753 | case 0x11bd: return 0x110c; |
755 | case 0x11be: return 0x110e; | 754 | case 0x11be: return 0x110e; |
756 | case 0x11bf: return 0x110f; | 755 | case 0x11bf: return 0x110f; |
757 | case 0x11c0: return 0x1110; | 756 | case 0x11c0: return 0x1110; |
758 | case 0x11c1: return 0x1111; | 757 | case 0x11c1: return 0x1111; |
759 | case 0x11c2: return 0x1112; | 758 | case 0x11c2: return 0x1112; |
760 | default: return 0; | 759 | default: return 0; |
761 | 760 | ||
762 | } | 761 | } |
763 | 762 | ||
764 | } | 763 | } |
765 | } | 764 | } |
766 | 765 | ||
767 | 766 | ||
768 | // Keys::Keys {{{1 | 767 | // Keys::Keys {{{1 |
769 | 768 | ||
770 | Keys::Keys() { | 769 | Keys::Keys() { |
771 | 770 | ||
772 | Config config("locale"); | 771 | Config config("locale"); |
773 | config.setGroup( "Language" ); | 772 | config.setGroup( "Language" ); |
774 | QString l = config.readEntry( "Language" , "en" ); | 773 | QString l = config.readEntry( "Language" , "en" ); |
775 | 774 | ||
776 | QString key_map = QPEApplication::qpeDir() + "/share/multikey/" | 775 | QString key_map = QPEApplication::qpeDir() + "/share/multikey/" |
777 | + /* l // testing korean for now */ | 776 | + l + ".keymap"; |
778 | + "ko.keymap"; | ||
779 | 777 | ||
780 | setKeysFromFile(key_map); | 778 | setKeysFromFile(key_map); |
781 | } | 779 | } |
782 | 780 | ||
783 | Keys::Keys(const char * filename) { | 781 | Keys::Keys(const char * filename) { |
784 | 782 | ||
785 | setKeysFromFile(filename); | 783 | setKeysFromFile(filename); |
786 | } | 784 | } |
787 | 785 | ||
788 | // Keys::setKeysFromFile {{{2 | 786 | // Keys::setKeysFromFile {{{2 |
789 | void Keys::setKeysFromFile(const char * filename) { | 787 | void Keys::setKeysFromFile(const char * filename) { |
790 | 788 | ||
791 | QFile f(filename); | 789 | QFile f(filename); |
792 | 790 | ||
793 | if (f.open(IO_ReadOnly)) { | 791 | if (f.open(IO_ReadOnly)) { |
794 | 792 | ||
795 | QTextStream t(&f); | 793 | QTextStream t(&f); |
796 | int row; | 794 | int row; |
797 | int qcode; | 795 | int qcode; |
798 | ushort unicode; | 796 | ushort unicode; |
799 | int width; | 797 | int width; |
800 | QString buf; | 798 | QString buf; |
801 | QString comment; | 799 | QString comment; |
802 | char * xpm[256]; //couldnt be larger than that... could it? | 800 | char * xpm[256]; //couldnt be larger than that... could it? |
803 | QPixmap *xpm2pix = 0; | 801 | QPixmap *xpm2pix = 0; |
804 | 802 | ||
805 | buf = t.readLine(); | 803 | buf = t.readLine(); |
806 | while (buf) { | 804 | while (buf) { |
807 | 805 | ||
808 | if (buf.contains(QRegExp("^\\d+\\s+[0-1a-fx]+", FALSE, FALSE))) { | 806 | if (buf.contains(QRegExp("^\\d+\\s+[0-1a-fx]+", FALSE, FALSE))) { |
809 | // no $1 type referencing!!! this implementation of regexp sucks | 807 | // no $1 type referencing!!! this implementation of regexp sucks |
810 | 808 | ||
811 | // dont know of any sscanf() type funcs in Qt lib | 809 | // dont know of any sscanf() type funcs in Qt lib |
812 | QTextStream tmp (buf, IO_ReadOnly); | 810 | QTextStream tmp (buf, IO_ReadOnly); |
813 | tmp >> row >> qcode >> unicode >> width >> comment; | 811 | tmp >> row >> qcode >> unicode >> width >> comment; |
814 | 812 | ||
815 | buf = t.readLine(); | 813 | buf = t.readLine(); |
816 | int xpmLineCount = 0; | 814 | int xpmLineCount = 0; |
817 | xpm2pix = 0; | 815 | xpm2pix = 0; |
818 | 816 | ||
819 | // erase blank space | 817 | // erase blank space |
820 | while (buf.contains(QRegExp("^\\s*$")) && buf) buf = t.readLine(); | 818 | while (buf.contains(QRegExp("^\\s*$")) && buf) buf = t.readLine(); |
821 | 819 | ||
822 | while (buf.contains(QRegExp("^\\s*\".*\""))) { | 820 | while (buf.contains(QRegExp("^\\s*\".*\""))) { |
823 | 821 | ||
824 | QString xpmBuf = buf.stripWhiteSpace(); | 822 | QString xpmBuf = buf.stripWhiteSpace(); |
825 | 823 | ||
826 | xpm[xpmLineCount] = new char [xpmBuf.length()]; | 824 | xpm[xpmLineCount] = new char [xpmBuf.length()]; |