author | hash <hash> | 2002-08-12 07:55:58 (UTC) |
---|---|---|
committer | hash <hash> | 2002-08-12 07:55:58 (UTC) |
commit | 1e045c5b7b5278b4a5925ba878cbdbdea9d03e1d (patch) (unidiff) | |
tree | 9687a824bde2de00bd1b42c34988acd778660b9a | |
parent | 895a6e1cebade986110758c57cafdadd942a63ff (diff) | |
download | opie-1e045c5b7b5278b4a5925ba878cbdbdea9d03e1d.zip opie-1e045c5b7b5278b4a5925ba878cbdbdea9d03e1d.tar.gz opie-1e045c5b7b5278b4a5925ba878cbdbdea9d03e1d.tar.bz2 |
uses langauge setting to choose keymap
-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 | |||
@@ -1,194 +1,193 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
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 | } |
115 | for (int i=0; i<(int)s.length(); i++) { | 114 | for (int i=0; i<(int)s.length(); i++) { |
116 | parent->emitKey( s[i].unicode(), 0, 0, true, false ); | 115 | parent->emitKey( s[i].unicode(), 0, 0, true, false ); |
117 | parent->emitKey( s[i].unicode(), 0, 0, false, false ); | 116 | parent->emitKey( s[i].unicode(), 0, 0, false, false ); |
118 | } | 117 | } |
119 | parent->emitKey( 0, Qt::Key_Space, 0, true, false ); | 118 | parent->emitKey( 0, Qt::Key_Space, 0, true, false ); |
120 | parent->emitKey( 0, Qt::Key_Space, 0, false, false ); | 119 | parent->emitKey( 0, Qt::Key_Space, 0, false, false ); |
121 | backspaces = 0; | 120 | backspaces = 0; |
122 | #endif | 121 | #endif |
123 | } | 122 | } |
124 | 123 | ||
125 | 124 | ||
126 | 125 | ||
127 | 126 | ||
128 | /* Keyboard::paintEvent {{{1 */ | 127 | /* Keyboard::paintEvent {{{1 */ |
129 | void Keyboard::paintEvent(QPaintEvent* e) | 128 | void Keyboard::paintEvent(QPaintEvent* e) |
130 | { | 129 | { |
131 | QPainter painter(this); | 130 | QPainter painter(this); |
132 | painter.setClipRect(e->rect()); | 131 | painter.setClipRect(e->rect()); |
133 | drawKeyboard( painter ); | 132 | drawKeyboard( painter ); |
134 | picks->dc->draw( &painter ); | 133 | picks->dc->draw( &painter ); |
135 | } | 134 | } |
136 | 135 | ||
137 | 136 | ||
138 | /* Keyboard::drawKeyboard {{{1 */ | 137 | /* Keyboard::drawKeyboard {{{1 */ |
139 | 138 | ||
140 | void Keyboard::drawKeyboard(QPainter &p, int row, int col) | 139 | void Keyboard::drawKeyboard(QPainter &p, int row, int col) |
141 | { | 140 | { |
142 | QColor keycolor = | 141 | QColor keycolor = |
143 | QColor(240,240,240); | 142 | QColor(240,240,240); |
144 | QColor keycolor_pressed = QColor(171,183,198); | 143 | QColor keycolor_pressed = QColor(171,183,198); |
145 | QColor keycolor_lines = QColor(138,148,160); | 144 | QColor keycolor_lines = QColor(138,148,160); |
146 | QColor textcolor = QColor(43,54,68); | 145 | QColor textcolor = QColor(43,54,68); |
147 | 146 | ||
148 | 147 | ||
149 | if (row != -1 && col != -1) { //just redraw one key | 148 | if (row != -1 && col != -1) { //just redraw one key |
150 | 149 | ||
151 | int x = 0; | 150 | int x = 0; |
152 | for (int i = 0; i < col; i++) { | 151 | for (int i = 0; i < col; i++) { |
153 | 152 | ||
154 | x += keys.width(row, i) * defaultKeyWidth; | 153 | x += keys.width(row, i) * defaultKeyWidth; |
155 | } | 154 | } |
156 | int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); | 155 | int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); |
157 | 156 | ||
158 | int keyWidth = keys.width(row, col); | 157 | int keyWidth = keys.width(row, col); |
159 | 158 | ||
160 | p.fillRect(x + 1, y + 1, | 159 | p.fillRect(x + 1, y + 1, |
161 | keyWidth * defaultKeyWidth - 1, keyHeight - 1, | 160 | keyWidth * defaultKeyWidth - 1, keyHeight - 1, |
162 | pressed || keys.pressed(row, col) ? keycolor_pressed : keycolor); | 161 | pressed || keys.pressed(row, col) ? keycolor_pressed : keycolor); |
163 | 162 | ||
164 | QPixmap *pix = keys.pix(row,col); | 163 | QPixmap *pix = keys.pix(row,col); |
165 | 164 | ||
166 | ushort c = keys.uni(row, col); | 165 | ushort c = keys.uni(row, col); |
167 | 166 | ||
168 | if (!pix) { | 167 | if (!pix) { |
169 | p.setPen(textcolor); | 168 | p.setPen(textcolor); |
170 | p.drawText(x, y, | 169 | p.drawText(x, y, |
171 | defaultKeyWidth * keyWidth, keyHeight, | 170 | defaultKeyWidth * keyWidth, keyHeight, |
172 | AlignCenter, ((shift || lock) && keys.shift(c)) ? (QChar)keys.shift(c) : (QChar)c); | 171 | AlignCenter, ((shift || lock) && keys.shift(c)) ? (QChar)keys.shift(c) : (QChar)c); |
173 | } | 172 | } |
174 | else | 173 | else |
175 | // center the image in the middle of the key | 174 | // center the image in the middle of the key |
176 | p.drawPixmap( x + (defaultKeyWidth * keyWidth - pix->width())/2, | 175 | p.drawPixmap( x + (defaultKeyWidth * keyWidth - pix->width())/2, |
177 | y + (keyHeight - pix->height())/2 + 1, | 176 | y + (keyHeight - pix->height())/2 + 1, |
178 | *pix ); | 177 | *pix ); |
179 | 178 | ||
180 | // this fixes the problem that the very right end of the board's vertical line | 179 | // this fixes the problem that the very right end of the board's vertical line |
181 | // gets painted over, because it's one pixel shorter than all other keys | 180 | // gets painted over, because it's one pixel shorter than all other keys |
182 | p.setPen(keycolor_lines); | 181 | p.setPen(keycolor_lines); |
183 | p.drawLine(width() - 1, 0, width() - 1, height()); | 182 | p.drawLine(width() - 1, 0, width() - 1, height()); |
184 | 183 | ||
185 | } else { | 184 | } else { |
186 | 185 | ||
187 | 186 | ||
188 | p.fillRect(0, 0, width(), height(), keycolor); | 187 | p.fillRect(0, 0, width(), height(), keycolor); |
189 | 188 | ||
190 | for (row = 1; row <= 5; row++) { | 189 | for (row = 1; row <= 5; row++) { |
191 | 190 | ||
192 | int x = 0; | 191 | int x = 0; |
193 | int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); | 192 | int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); |
194 | 193 | ||
@@ -649,258 +648,257 @@ ushort Keyboard::parseKoreanInput (ushort c) { | |||
649 | prev = combineKoreanChars(schar, mchar, 0x11af); | 648 | prev = combineKoreanChars(schar, mchar, 0x11af); |
650 | schar = 0x1106; | 649 | schar = 0x1106; |
651 | break; | 650 | break; |
652 | case 0x11b2: | 651 | case 0x11b2: |
653 | prev = combineKoreanChars(schar, mchar, 0x11af); | 652 | prev = combineKoreanChars(schar, mchar, 0x11af); |
654 | schar = 0x1107; | 653 | schar = 0x1107; |
655 | break; | 654 | break; |
656 | case 0x11b3: | 655 | case 0x11b3: |
657 | prev = combineKoreanChars(schar, mchar, 0x11af); | 656 | prev = combineKoreanChars(schar, mchar, 0x11af); |
658 | schar = 0x1109; | 657 | schar = 0x1109; |
659 | break; | 658 | break; |
660 | case 0x11b4: | 659 | case 0x11b4: |
661 | prev = combineKoreanChars(schar, mchar, 0x11af); | 660 | prev = combineKoreanChars(schar, mchar, 0x11af); |
662 | schar = 0x1110; | 661 | schar = 0x1110; |
663 | break; | 662 | break; |
664 | case 0x11b9: | 663 | case 0x11b9: |
665 | prev = combineKoreanChars(schar, mchar, 0x11b8); | 664 | prev = combineKoreanChars(schar, mchar, 0x11b8); |
666 | schar = 0x1109; | 665 | schar = 0x1109; |
667 | break; | 666 | break; |
668 | /* | 667 | /* |
669 | case 0x11bb: | 668 | case 0x11bb: |
670 | prev = combineKoreanChars(schar, mchar, 0x11ba); | 669 | prev = combineKoreanChars(schar, mchar, 0x11ba); |
671 | schar = 0x1109; | 670 | schar = 0x1109; |
672 | break; | 671 | break; |
673 | */ | 672 | */ |
674 | default: | 673 | default: |
675 | 674 | ||
676 | if (constoe(echar)) { | 675 | if (constoe(echar)) { |
677 | 676 | ||
678 | prev = combineKoreanChars(schar, mchar, 0); | 677 | prev = combineKoreanChars(schar, mchar, 0); |
679 | schar = constoe(echar); | 678 | schar = constoe(echar); |
680 | } | 679 | } |
681 | break; | 680 | break; |
682 | } | 681 | } |
683 | 682 | ||
684 | emit key( prev, prev, 0, true, false ); | 683 | emit key( prev, prev, 0, true, false ); |
685 | 684 | ||
686 | mchar = c; echar = 0; | 685 | mchar = c; echar = 0; |
687 | 686 | ||
688 | return combineKoreanChars(schar, mchar, 0); | 687 | return combineKoreanChars(schar, mchar, 0); |
689 | 688 | ||
690 | } | 689 | } |
691 | else { | 690 | else { |
692 | schar = 0; mchar = 0; echar = 0; | 691 | schar = 0; mchar = 0; echar = 0; |
693 | return c; | 692 | return c; |
694 | } | 693 | } |
695 | 694 | ||
696 | } | 695 | } |
697 | else /*if (c == ' ')*/ return c; | 696 | else /*if (c == ' ')*/ return c; |
698 | 697 | ||
699 | 698 | ||
700 | // and now... finally delete previous char, and return new char | 699 | // and now... finally delete previous char, and return new char |
701 | emit key( 8, Qt::Key_Backspace, 0, true, false ); | 700 | emit key( 8, Qt::Key_Backspace, 0, true, false ); |
702 | 701 | ||
703 | 702 | ||
704 | return combineKoreanChars( schar, mchar, echar); | 703 | return combineKoreanChars( schar, mchar, echar); |
705 | 704 | ||
706 | } | 705 | } |
707 | 706 | ||
708 | ushort Keyboard::combineKoreanChars(const ushort s, const ushort m, const ushort e) { | 707 | ushort Keyboard::combineKoreanChars(const ushort s, const ushort m, const ushort e) { |
709 | 708 | ||
710 | return ((s - 0x1100) * 588) + ((m - 0x1161) * 28) + (e ? e - 0x11a7 : 0) + 0xac00; | 709 | return ((s - 0x1100) * 588) + ((m - 0x1161) * 28) + (e ? e - 0x11a7 : 0) + 0xac00; |
711 | 710 | ||
712 | } | 711 | } |
713 | 712 | ||
714 | ushort Keyboard::constoe(const ushort c) { | 713 | ushort Keyboard::constoe(const ushort c) { |
715 | 714 | ||
716 | // converts schars to echars if possible | 715 | // converts schars to echars if possible |
717 | 716 | ||
718 | if (0x1100 <= c && c <= 0x1112) { // schar to echar | 717 | if (0x1100 <= c && c <= 0x1112) { // schar to echar |
719 | 718 | ||
720 | switch (c) { | 719 | switch (c) { |
721 | case 0x1100: return 0x11a8; | 720 | case 0x1100: return 0x11a8; |
722 | case 0x1101: return 0x11a9; | 721 | case 0x1101: return 0x11a9; |
723 | case 0x1102: return 0x11ab; | 722 | case 0x1102: return 0x11ab; |
724 | case 0x1103: return 0x11ae; | 723 | case 0x1103: return 0x11ae; |
725 | case 0x1105: return 0x11af; | 724 | case 0x1105: return 0x11af; |
726 | case 0x1106: return 0x11b7; | 725 | case 0x1106: return 0x11b7; |
727 | case 0x1107: return 0x11b8; | 726 | case 0x1107: return 0x11b8; |
728 | case 0x1109: return 0x11ba; | 727 | case 0x1109: return 0x11ba; |
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()]; |
827 | 825 | ||
828 | int j = 0; | 826 | int j = 0; |
829 | for (ushort i = 0; i < xpmBuf.length(); i++) { | 827 | for (ushort i = 0; i < xpmBuf.length(); i++) { |
830 | if (xpmBuf[i].latin1() != '"') { | 828 | if (xpmBuf[i].latin1() != '"') { |
831 | 829 | ||
832 | ((char *)xpm[xpmLineCount])[j] = xpmBuf.at(i).latin1(); | 830 | ((char *)xpm[xpmLineCount])[j] = xpmBuf.at(i).latin1(); |
833 | j++; | 831 | j++; |
834 | } | 832 | } |
835 | 833 | ||
836 | } | 834 | } |
837 | // have to close that facker up | 835 | // have to close that facker up |
838 | ((char *)xpm[xpmLineCount])[j] = '\0'; | 836 | ((char *)xpm[xpmLineCount])[j] = '\0'; |
839 | 837 | ||
840 | xpmLineCount++; | 838 | xpmLineCount++; |
841 | buf = t.readLine(); | 839 | buf = t.readLine(); |
842 | } | 840 | } |
843 | if (xpmLineCount) { | 841 | if (xpmLineCount) { |
844 | 842 | ||
845 | xpm2pix = new QPixmap((const char **)xpm); | 843 | xpm2pix = new QPixmap((const char **)xpm); |
846 | for (int i = 0; i < xpmLineCount; i++) | 844 | for (int i = 0; i < xpmLineCount; i++) |
847 | 845 | ||
848 | delete [] (xpm[i]); | 846 | delete [] (xpm[i]); |
849 | 847 | ||
850 | } | 848 | } |
851 | setKey(row, qcode, unicode, width, xpm2pix); | 849 | setKey(row, qcode, unicode, width, xpm2pix); |
852 | } | 850 | } |
853 | else if (buf.contains(QRegExp("^[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { | 851 | else if (buf.contains(QRegExp("^[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { |
854 | 852 | ||
855 | QTextStream tmp (buf, IO_ReadOnly); | 853 | QTextStream tmp (buf, IO_ReadOnly); |
856 | ushort lower, shift; | 854 | ushort lower, shift; |
857 | tmp >> lower >> shift; | 855 | tmp >> lower >> shift; |
858 | 856 | ||
859 | shiftMap.insert(lower, shift); | 857 | shiftMap.insert(lower, shift); |
860 | 858 | ||
861 | buf = t.readLine(); | 859 | buf = t.readLine(); |
862 | } | 860 | } |
863 | else if (buf.contains(QRegExp("^\\s*#"))) { | 861 | else if (buf.contains(QRegExp("^\\s*#"))) { |
864 | 862 | ||
865 | buf = t.readLine(); | 863 | buf = t.readLine(); |
866 | 864 | ||
867 | } else { // blank line, or garbage | 865 | } else { // blank line, or garbage |
868 | 866 | ||
869 | buf = t.readLine(); | 867 | buf = t.readLine(); |
870 | 868 | ||
871 | } | 869 | } |
872 | 870 | ||
873 | } | 871 | } |
874 | f.close(); | 872 | f.close(); |
875 | } | 873 | } |
876 | 874 | ||
877 | } | 875 | } |
878 | 876 | ||
879 | // Keys::setKey {{{2 | 877 | // Keys::setKey {{{2 |
880 | void Keys::setKey(const int row, const int qcode, const ushort unicode, | 878 | void Keys::setKey(const int row, const int qcode, const ushort unicode, |
881 | const int width, QPixmap *pix) { | 879 | const int width, QPixmap *pix) { |
882 | 880 | ||
883 | Key * key; | 881 | Key * key; |
884 | key = new Key; | 882 | key = new Key; |
885 | key->qcode = qcode; | 883 | key->qcode = qcode; |
886 | key->unicode = unicode; | 884 | key->unicode = unicode; |
887 | key->width = width; | 885 | key->width = width; |
888 | 886 | ||
889 | // share key->pressed between same keys | 887 | // share key->pressed between same keys |
890 | bool found = 0; | 888 | bool found = 0; |
891 | for (int i = 1; i <= 5; i++) { | 889 | for (int i = 1; i <= 5; i++) { |
892 | for (unsigned int j = 0; j < keys[i].count(); j++) | 890 | for (unsigned int j = 0; j < keys[i].count(); j++) |
893 | if (keys[i].at(j)->qcode == qcode && keys[i].at(j)->unicode == unicode) { | 891 | if (keys[i].at(j)->qcode == qcode && keys[i].at(j)->unicode == unicode) { |
894 | 892 | ||
895 | key->pressed = keys[i].at(j)->pressed; | 893 | key->pressed = keys[i].at(j)->pressed; |
896 | found = 1; | 894 | found = 1; |
897 | } | 895 | } |
898 | 896 | ||
899 | } | 897 | } |
900 | if (!found) { | 898 | if (!found) { |
901 | 899 | ||
902 | key->pressed = new bool; | 900 | key->pressed = new bool; |
903 | *(key->pressed) = 0; | 901 | *(key->pressed) = 0; |
904 | } | 902 | } |
905 | 903 | ||
906 | key->pix = pix; | 904 | key->pix = pix; |