author | hash <hash> | 2002-08-22 08:09:57 (UTC) |
---|---|---|
committer | hash <hash> | 2002-08-22 08:09:57 (UTC) |
commit | 2ff3290b552c575ff7222df29235651968f484aa (patch) (unidiff) | |
tree | 15819ac788483336b90ececf5f5f635081c98c97 /inputmethods/multikey | |
parent | 8eee5a5dc6a43ed3cdd77095c3a91128fe76589e (diff) | |
download | opie-2ff3290b552c575ff7222df29235651968f484aa.zip opie-2ff3290b552c575ff7222df29235651968f484aa.tar.gz opie-2ff3290b552c575ff7222df29235651968f484aa.tar.bz2 |
coloring problem
-rw-r--r-- | inputmethods/multikey/keyboard.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp index 89937cf..e3d3928 100644 --- a/inputmethods/multikey/keyboard.cpp +++ b/inputmethods/multikey/keyboard.cpp | |||
@@ -1,1026 +1,1028 @@ | |||
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 | #include "configdlg.h" | 22 | #include "configdlg.h" |
23 | 23 | ||
24 | #include <qpe/global.h> | 24 | #include <qpe/global.h> |
25 | #include <qpe/qcopenvelope_qws.h> | 25 | #include <qpe/qcopenvelope_qws.h> |
26 | 26 | ||
27 | #include <qwindowsystem_qws.h> | 27 | #include <qwindowsystem_qws.h> |
28 | #include <qpainter.h> | 28 | #include <qpainter.h> |
29 | #include <qfontmetrics.h> | 29 | #include <qfontmetrics.h> |
30 | #include <qtimer.h> | 30 | #include <qtimer.h> |
31 | #include <qpe/qpeapplication.h> | 31 | #include <qpe/qpeapplication.h> |
32 | #include <qpe/config.h> | 32 | #include <qpe/config.h> |
33 | #include <ctype.h> | 33 | #include <ctype.h> |
34 | #include <qfile.h> | 34 | #include <qfile.h> |
35 | #include <qtextstream.h> | 35 | #include <qtextstream.h> |
36 | #include <qstringlist.h> | 36 | #include <qstringlist.h> |
37 | #include <iostream.h> | 37 | #include <iostream.h> |
38 | 38 | ||
39 | #include <sys/utsname.h> | 39 | #include <sys/utsname.h> |
40 | 40 | ||
41 | 41 | ||
42 | /* Keyboard::Keyboard {{{1 */ | 42 | /* Keyboard::Keyboard {{{1 */ |
43 | Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : | 43 | Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : |
44 | QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), alt(0), meta(0), | 44 | QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), alt(0), meta(0), |
45 | useLargeKeys(TRUE), usePicks(0), useRepeat(0), pressedKeyRow(-1), pressedKeyCol(-1), | 45 | useLargeKeys(TRUE), usePicks(0), useRepeat(0), pressedKeyRow(-1), pressedKeyCol(-1), |
46 | unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0), | 46 | unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0), |
47 | configdlg(0) | 47 | configdlg(0) |
48 | 48 | ||
49 | { | 49 | { |
50 | 50 | ||
51 | // get the default font | 51 | // get the default font |
52 | Config *config = new Config( "qpe" ); | 52 | Config *config = new Config( "qpe" ); |
53 | config->setGroup( "Appearance" ); | 53 | config->setGroup( "Appearance" ); |
54 | QString familyStr = config->readEntry( "FontFamily", "fixed" ); | 54 | QString familyStr = config->readEntry( "FontFamily", "fixed" ); |
55 | delete config; | 55 | delete config; |
56 | 56 | ||
57 | config = new Config("multikey"); | 57 | config = new Config("multikey"); |
58 | config->setGroup ("general"); | 58 | config->setGroup ("general"); |
59 | usePicks = config->readBoolEntry ("usePickboard", "0"); // default closed | 59 | usePicks = config->readBoolEntry ("usePickboard", "0"); // default closed |
60 | useRepeat = config->readBoolEntry ("useRepeat", "1"); | 60 | useRepeat = config->readBoolEntry ("useRepeat", "1"); |
61 | delete config; | 61 | delete config; |
62 | 62 | ||
63 | 63 | ||
64 | setFont( QFont( familyStr, 10 ) ); | 64 | setFont( QFont( familyStr, 10 ) ); |
65 | 65 | ||
66 | picks = new KeyboardPicks( this ); | 66 | picks = new KeyboardPicks( this ); |
67 | picks->setFont( QFont( familyStr, 10 ) ); | 67 | picks->setFont( QFont( familyStr, 10 ) ); |
68 | picks->initialise(); | 68 | picks->initialise(); |
69 | if (usePicks) { | 69 | if (usePicks) { |
70 | 70 | ||
71 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), | 71 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), |
72 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); | 72 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); |
73 | 73 | ||
74 | } else picks->hide(); | 74 | } else picks->hide(); |
75 | 75 | ||
76 | loadKeyboardColors(); | 76 | loadKeyboardColors(); |
77 | 77 | ||
78 | keys = new Keys(); | 78 | keys = new Keys(); |
79 | 79 | ||
80 | repeatTimer = new QTimer( this ); | 80 | repeatTimer = new QTimer( this ); |
81 | connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); | 81 | connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); |
82 | 82 | ||
83 | } | 83 | } |
84 | 84 | ||
85 | Keyboard::~Keyboard() { | 85 | Keyboard::~Keyboard() { |
86 | 86 | ||
87 | if ( configdlg ) { | 87 | if ( configdlg ) { |
88 | delete (ConfigDlg *) configdlg; | 88 | delete (ConfigDlg *) configdlg; |
89 | configdlg = 0; | 89 | configdlg = 0; |
90 | } | 90 | } |
91 | 91 | ||
92 | } | 92 | } |
93 | 93 | ||
94 | /* Keyboard::resizeEvent {{{1 */ | 94 | /* Keyboard::resizeEvent {{{1 */ |
95 | void Keyboard::resizeEvent(QResizeEvent*) | 95 | void Keyboard::resizeEvent(QResizeEvent*) |
96 | { | 96 | { |
97 | int ph = picks->sizeHint().height(); | 97 | int ph = picks->sizeHint().height(); |
98 | picks->setGeometry( 0, 0, width(), ph ); | 98 | picks->setGeometry( 0, 0, width(), ph ); |
99 | keyHeight = (height()-(usePicks ? ph : 0))/5; | 99 | keyHeight = (height()-(usePicks ? ph : 0))/5; |
100 | 100 | ||
101 | int nk; // number of keys? | 101 | int nk; // number of keys? |
102 | if ( useLargeKeys ) { | 102 | if ( useLargeKeys ) { |
103 | nk = 15; | 103 | nk = 15; |
104 | } else { | 104 | } else { |
105 | nk = 19; | 105 | nk = 19; |
106 | } | 106 | } |
107 | defaultKeyWidth = (width()/nk)/2; | 107 | defaultKeyWidth = (width()/nk)/2; |
108 | xoffs = (width()-defaultKeyWidth*nk)/2; // empty key spaces? | 108 | xoffs = (width()-defaultKeyWidth*nk)/2; // empty key spaces? |
109 | 109 | ||
110 | } | 110 | } |
111 | 111 | ||
112 | /* KeyboardPicks::initialize {{{1 */ | 112 | /* KeyboardPicks::initialize {{{1 */ |
113 | void KeyboardPicks::initialise() | 113 | void KeyboardPicks::initialise() |
114 | { | 114 | { |
115 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); | 115 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); |
116 | mode = 0; | 116 | mode = 0; |
117 | dc = new KeyboardConfig(this); | 117 | dc = new KeyboardConfig(this); |
118 | configs.append(dc); | 118 | configs.append(dc); |
119 | } | 119 | } |
120 | 120 | ||
121 | /* KeyboardPicks::sizeHint {{{1 */ | 121 | /* KeyboardPicks::sizeHint {{{1 */ |
122 | QSize KeyboardPicks::sizeHint() const | 122 | QSize KeyboardPicks::sizeHint() const |
123 | { | 123 | { |
124 | return QSize(240,fontMetrics().lineSpacing()); | 124 | return QSize(240,fontMetrics().lineSpacing()); |
125 | } | 125 | } |
126 | 126 | ||
127 | 127 | ||
128 | /* KeyboardConfig::generateText {{{1 */ | 128 | /* KeyboardConfig::generateText {{{1 */ |
129 | void KeyboardConfig::generateText(const QString &s) | 129 | void KeyboardConfig::generateText(const QString &s) |
130 | { | 130 | { |
131 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 131 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
132 | for (int i=0; i<(int)backspaces; i++) { | 132 | for (int i=0; i<(int)backspaces; i++) { |
133 | parent->emitKey( 0, Qt::Key_Backspace, 0, true, false ); | 133 | parent->emitKey( 0, Qt::Key_Backspace, 0, true, false ); |
134 | parent->emitKey( 0, Qt::Key_Backspace, 0, false, false ); | 134 | parent->emitKey( 0, Qt::Key_Backspace, 0, false, false ); |
135 | } | 135 | } |
136 | for (int i=0; i<(int)s.length(); i++) { | 136 | for (int i=0; i<(int)s.length(); i++) { |
137 | parent->emitKey( s[i].unicode(), 0, 0, true, false ); | 137 | parent->emitKey( s[i].unicode(), 0, 0, true, false ); |
138 | parent->emitKey( s[i].unicode(), 0, 0, false, false ); | 138 | parent->emitKey( s[i].unicode(), 0, 0, false, false ); |
139 | } | 139 | } |
140 | parent->emitKey( 0, Qt::Key_Space, 0, true, false ); | 140 | parent->emitKey( 0, Qt::Key_Space, 0, true, false ); |
141 | parent->emitKey( 0, Qt::Key_Space, 0, false, false ); | 141 | parent->emitKey( 0, Qt::Key_Space, 0, false, false ); |
142 | backspaces = 0; | 142 | backspaces = 0; |
143 | #endif | 143 | #endif |
144 | } | 144 | } |
145 | 145 | ||
146 | 146 | ||
147 | 147 | ||
148 | 148 | ||
149 | /* Keyboard::paintEvent {{{1 */ | 149 | /* Keyboard::paintEvent {{{1 */ |
150 | void Keyboard::paintEvent(QPaintEvent* e) | 150 | void Keyboard::paintEvent(QPaintEvent* e) |
151 | { | 151 | { |
152 | QPainter painter(this); | 152 | QPainter painter(this); |
153 | painter.setClipRect(e->rect()); | 153 | painter.setClipRect(e->rect()); |
154 | drawKeyboard( painter ); | 154 | drawKeyboard( painter ); |
155 | picks->dc->draw( &painter ); | 155 | picks->dc->draw( &painter ); |
156 | } | 156 | } |
157 | 157 | ||
158 | 158 | ||
159 | /* Keyboard::drawKeyboard {{{1 */ | 159 | /* Keyboard::drawKeyboard {{{1 */ |
160 | 160 | ||
161 | void Keyboard::drawKeyboard(QPainter &p, int row, int col) | 161 | void Keyboard::drawKeyboard(QPainter &p, int row, int col) |
162 | { | 162 | { |
163 | 163 | ||
164 | 164 | ||
165 | if (row != -1 && col != -1) { //just redraw one key | 165 | if (row != -1 && col != -1) { //just redraw one key |
166 | 166 | ||
167 | int x = 0; | 167 | int x = 0; |
168 | for (int i = 0; i < col; i++) { | 168 | for (int i = 0; i < col; i++) { |
169 | 169 | ||
170 | x += keys->width(row, i) * defaultKeyWidth; | 170 | x += keys->width(row, i) * defaultKeyWidth; |
171 | } | 171 | } |
172 | int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); | 172 | int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); |
173 | 173 | ||
174 | int keyWidth = keys->width(row, col); | 174 | int keyWidth = keys->width(row, col); |
175 | 175 | ||
176 | p.fillRect(x + 1, y + 1, | 176 | p.fillRect(x + 1, y + 1, |
177 | keyWidth * defaultKeyWidth - 1, keyHeight - 1, | 177 | keyWidth * defaultKeyWidth - 1, keyHeight - 1, |
178 | pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor); | 178 | pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor); |
179 | 179 | ||
180 | QPixmap *pix = keys->pix(row,col); | 180 | QPixmap *pix = keys->pix(row,col); |
181 | 181 | ||
182 | ushort c = keys->uni(row, col); | 182 | ushort c = keys->uni(row, col); |
183 | 183 | ||
184 | p.setPen(textcolor); | 184 | p.setPen(textcolor); |
185 | if (!pix) { | 185 | if (!pix) { |
186 | if (shift || lock) | 186 | if (shift || lock) |
187 | c = keys->shift(c); | 187 | c = keys->shift(c); |
188 | if (meta) { | 188 | if (meta) { |
189 | 189 | ||
190 | c = keys->meta(c); | 190 | c = keys->meta(c); |
191 | } | 191 | } |
192 | p.drawText(x, y, | 192 | p.drawText(x, y, |
193 | defaultKeyWidth * keyWidth + 3, keyHeight, | 193 | defaultKeyWidth * keyWidth + 3, keyHeight, |
194 | AlignCenter, (QChar)c); | 194 | AlignCenter, (QChar)c); |
195 | } | 195 | } |
196 | else | 196 | else |
197 | // center the image in the middle of the key | 197 | // center the image in the middle of the key |
198 | p.drawPixmap( x + (defaultKeyWidth * keyWidth - pix->width())/2, | 198 | p.drawPixmap( x + (defaultKeyWidth * keyWidth - pix->width())/2, |
199 | y + (keyHeight - pix->height())/2 + 1, | 199 | y + (keyHeight - pix->height())/2 + 1, |
200 | *pix ); | 200 | *pix ); |
201 | 201 | ||
202 | // this fixes the problem that the very right end of the board's vertical line | 202 | // this fixes the problem that the very right end of the board's vertical line |
203 | // gets painted over, because it's one pixel shorter than all other keys | 203 | // gets painted over, because it's one pixel shorter than all other keys |
204 | p.setPen(keycolor_lines); | 204 | p.setPen(keycolor_lines); |
205 | p.drawLine(width() - 1, 0, width() - 1, height()); | 205 | p.drawLine(width() - 1, 0, width() - 1, height()); |
206 | 206 | ||
207 | } else { | 207 | } else { |
208 | 208 | ||
209 | 209 | ||
210 | p.fillRect(0, 0, width(), height(), keycolor); | 210 | p.fillRect(0, 0, width(), height(), keycolor); |
211 | 211 | ||
212 | for (row = 1; row <= 5; row++) { | 212 | for (row = 1; row <= 5; row++) { |
213 | 213 | ||
214 | int x = 0; | 214 | int x = 0; |
215 | int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); | 215 | int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); |
216 | 216 | ||
217 | p.setPen(keycolor_lines); | 217 | p.setPen(keycolor_lines); |
218 | p.drawLine(x, y, x + width(), y); | 218 | p.drawLine(x, y, x + width(), y); |
219 | 219 | ||
220 | for (int col = 0; col < keys->numKeys(row); col++) { | 220 | for (int col = 0; col < keys->numKeys(row); col++) { |
221 | 221 | ||
222 | QPixmap *pix = keys->pix(row, col); | 222 | QPixmap *pix = keys->pix(row, col); |
223 | int keyWidth = keys->width(row, col); | 223 | int keyWidth = keys->width(row, col); |
224 | 224 | ||
225 | 225 | ||
226 | int keyWidthPix = defaultKeyWidth * keyWidth; | 226 | int keyWidthPix = defaultKeyWidth * keyWidth; |
227 | 227 | ||
228 | if (keys->pressed(row, col)) | 228 | if (keys->pressed(row, col)) |
229 | p.fillRect(x+1, y+1, keyWidthPix - 1, | 229 | p.fillRect(x+1, y+1, keyWidthPix - 1, |
230 | keyHeight - 1, keycolor_pressed); | 230 | keyHeight - 1, keycolor_pressed); |
231 | 231 | ||
232 | ushort c = keys->uni(row, col); | 232 | ushort c = keys->uni(row, col); |
233 | 233 | ||
234 | p.setPen(textcolor); | ||
234 | if (!pix) { | 235 | if (!pix) { |
235 | if ((shift || lock) && keys->shift(c)) | 236 | if ((shift || lock) && keys->shift(c)) |
236 | c = keys->shift(c); | 237 | c = keys->shift(c); |
237 | else if (meta && keys->meta(c)) | 238 | else if (meta && keys->meta(c)) |
238 | c = keys->meta(c); | 239 | c = keys->meta(c); |
239 | 240 | ||
240 | p.drawText(x, y, | 241 | p.drawText(x, y, |
241 | defaultKeyWidth * keyWidth + 3, keyHeight, | 242 | keyWidthPix + 3, keyHeight, |
242 | AlignCenter, (QChar)c); | 243 | AlignCenter, (QChar)c); |
243 | } | 244 | } |
244 | else { | 245 | else { |
245 | // center the image in the middle of the key | 246 | // center the image in the middle of the key |
246 | p.drawPixmap( x + (keyWidthPix - pix->width())/2, | 247 | p.drawPixmap( x + (keyWidthPix - pix->width())/2, |
247 | y + (keyHeight - pix->height())/2 + 1, | 248 | y + (keyHeight - pix->height())/2 + 1, |
248 | QPixmap(*pix) ); | 249 | QPixmap(*pix) ); |
249 | } | 250 | } |
250 | 251 | ||
251 | p.setPen(keycolor_lines); | 252 | p.setPen(keycolor_lines); |
252 | p.drawLine(x, y, x, y + keyHeight); | 253 | p.drawLine(x, y, x, y + keyHeight); |
253 | 254 | ||
254 | x += keyWidthPix; | 255 | x += keyWidthPix; |
255 | } | 256 | } |
256 | 257 | ||
257 | 258 | ||
258 | } | 259 | } |
260 | p.setPen(keycolor_lines); | ||
259 | p.drawLine(0, height() - 1, width(), height() - 1); | 261 | p.drawLine(0, height() - 1, width(), height() - 1); |
260 | p.drawLine(width() - 1, 0, width() - 1, height()); | 262 | p.drawLine(width() - 1, 0, width() - 1, height()); |
261 | } | 263 | } |
262 | 264 | ||
263 | } | 265 | } |
264 | 266 | ||
265 | 267 | ||
266 | /* Keyboard::mousePressEvent {{{1 */ | 268 | /* Keyboard::mousePressEvent {{{1 */ |
267 | void Keyboard::mousePressEvent(QMouseEvent *e) | 269 | void Keyboard::mousePressEvent(QMouseEvent *e) |
268 | { | 270 | { |
269 | int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1; | 271 | int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1; |
270 | if (row > 5) row = 5; | 272 | if (row > 5) row = 5; |
271 | 273 | ||
272 | // figure out the column | 274 | // figure out the column |
273 | int col = 0; | 275 | int col = 0; |
274 | for (int w = 0; e->x() >= w; col++) | 276 | for (int w = 0; e->x() >= w; col++) |
275 | if (col < keys->numKeys(row)) // it segfaults if it trys to read past numKeys | 277 | if (col < keys->numKeys(row)) // it segfaults if it trys to read past numKeys |
276 | w += keys->width(row,col) * defaultKeyWidth; | 278 | w += keys->width(row,col) * defaultKeyWidth; |
277 | else break; | 279 | else break; |
278 | 280 | ||
279 | if (col <= 0) return; | 281 | if (col <= 0) return; |
280 | 282 | ||
281 | col --; // rewind one... | 283 | col --; // rewind one... |
282 | 284 | ||
283 | qkeycode = keys->qcode(row, col); | 285 | qkeycode = keys->qcode(row, col); |
284 | unicode = keys->uni(row, col); | 286 | unicode = keys->uni(row, col); |
285 | 287 | ||
286 | // might need to repaint if two or more of the same keys. | 288 | // might need to repaint if two or more of the same keys. |
287 | // should be faster if just paint one key even though multiple keys exist. | 289 | // should be faster if just paint one key even though multiple keys exist. |
288 | bool need_repaint = FALSE; | 290 | bool need_repaint = FALSE; |
289 | 291 | ||
290 | if (unicode == 0) { // either Qt char, or nothing | 292 | if (unicode == 0) { // either Qt char, or nothing |
291 | 293 | ||
292 | if (qkeycode == Qt::Key_F1) { // toggle the pickboard | 294 | if (qkeycode == Qt::Key_F1) { // toggle the pickboard |
293 | 295 | ||
294 | if ( configdlg ) { | 296 | if ( configdlg ) { |
295 | delete (ConfigDlg *) configdlg; | 297 | delete (ConfigDlg *) configdlg; |
296 | configdlg = 0; | 298 | configdlg = 0; |
297 | } | 299 | } |
298 | else { | 300 | else { |
299 | configdlg = new ConfigDlg (); | 301 | configdlg = new ConfigDlg (); |
300 | connect(configdlg, SIGNAL(setMapToDefault()), | 302 | connect(configdlg, SIGNAL(setMapToDefault()), |
301 | this, SLOT(setMapToDefault())); | 303 | this, SLOT(setMapToDefault())); |
302 | connect(configdlg, SIGNAL(setMapToFile(QString)), | 304 | connect(configdlg, SIGNAL(setMapToFile(QString)), |
303 | this, SLOT(setMapToFile(QString))); | 305 | this, SLOT(setMapToFile(QString))); |
304 | connect(configdlg, SIGNAL(pickboardToggled(bool)), | 306 | connect(configdlg, SIGNAL(pickboardToggled(bool)), |
305 | this, SLOT(togglePickboard(bool))); | 307 | this, SLOT(togglePickboard(bool))); |
306 | connect(configdlg, SIGNAL(repeatToggled(bool)), | 308 | connect(configdlg, SIGNAL(repeatToggled(bool)), |
307 | this, SLOT(toggleRepeat(bool))); | 309 | this, SLOT(toggleRepeat(bool))); |
308 | connect(configdlg, SIGNAL(reloadKeyboard()), | 310 | connect(configdlg, SIGNAL(reloadKeyboard()), |
309 | this, SLOT(reloadKeyboard())); | 311 | this, SLOT(reloadKeyboard())); |
310 | configdlg->showMaximized(); | 312 | configdlg->showMaximized(); |
311 | configdlg->show(); | 313 | configdlg->show(); |
312 | configdlg->raise(); | 314 | configdlg->raise(); |
313 | } | 315 | } |
314 | 316 | ||
315 | } else if (qkeycode == Qt::Key_Control) { | 317 | } else if (qkeycode == Qt::Key_Control) { |
316 | need_repaint = TRUE; | 318 | need_repaint = TRUE; |
317 | 319 | ||
318 | if (ctrl) { | 320 | if (ctrl) { |
319 | 321 | ||
320 | *ctrl = 0; | 322 | *ctrl = 0; |
321 | ctrl = 0; | 323 | ctrl = 0; |
322 | 324 | ||
323 | } else { | 325 | } else { |
324 | 326 | ||
325 | ctrl = keys->pressedPtr(row, col); | 327 | ctrl = keys->pressedPtr(row, col); |
326 | need_repaint = TRUE; | 328 | need_repaint = TRUE; |
327 | *ctrl = !keys->pressed(row, col); | 329 | *ctrl = !keys->pressed(row, col); |
328 | 330 | ||
329 | } | 331 | } |
330 | 332 | ||
331 | } else if (qkeycode == Qt::Key_Alt) { | 333 | } else if (qkeycode == Qt::Key_Alt) { |
332 | need_repaint = TRUE; | 334 | need_repaint = TRUE; |
333 | 335 | ||
334 | if (alt) { | 336 | if (alt) { |
335 | *alt = 0; | 337 | *alt = 0; |
336 | alt = 0; | 338 | alt = 0; |
337 | 339 | ||
338 | } else { | 340 | } else { |
339 | 341 | ||
340 | alt = keys->pressedPtr(row, col); | 342 | alt = keys->pressedPtr(row, col); |
341 | need_repaint = TRUE; | 343 | need_repaint = TRUE; |
342 | *alt = !keys->pressed(row, col); | 344 | *alt = !keys->pressed(row, col); |
343 | } | 345 | } |
344 | 346 | ||
345 | } else if (qkeycode == Qt::Key_Shift) { | 347 | } else if (qkeycode == Qt::Key_Shift) { |
346 | need_repaint = TRUE; | 348 | need_repaint = TRUE; |
347 | 349 | ||
348 | if (shift) { | 350 | if (shift) { |
349 | *shift = 0; | 351 | *shift = 0; |
350 | shift = 0; | 352 | shift = 0; |
351 | } | 353 | } |
352 | else { | 354 | else { |
353 | shift = keys->pressedPtr(row, col); | 355 | shift = keys->pressedPtr(row, col); |
354 | *shift = 1; | 356 | *shift = 1; |
355 | if (lock) { | 357 | if (lock) { |
356 | *lock = 0; | 358 | *lock = 0; |
357 | lock = 0; | 359 | lock = 0; |
358 | } | 360 | } |
359 | } | 361 | } |
360 | if (meta) { | 362 | if (meta) { |
361 | 363 | ||
362 | *meta = 0; | 364 | *meta = 0; |
363 | meta = 0; | 365 | meta = 0; |
364 | } | 366 | } |
365 | 367 | ||
366 | } else if (qkeycode == Qt::Key_CapsLock) { | 368 | } else if (qkeycode == Qt::Key_CapsLock) { |
367 | need_repaint = TRUE; | 369 | need_repaint = TRUE; |
368 | 370 | ||
369 | if (lock) { | 371 | if (lock) { |
370 | *lock = 0; | 372 | *lock = 0; |
371 | lock = 0; | 373 | lock = 0; |
372 | } | 374 | } |
373 | else { | 375 | else { |
374 | lock = keys->pressedPtr(row, col);; | 376 | lock = keys->pressedPtr(row, col);; |
375 | *lock = 1; | 377 | *lock = 1; |
376 | if (shift) { | 378 | if (shift) { |
377 | *shift = 0; | 379 | *shift = 0; |
378 | shift = 0; | 380 | shift = 0; |
379 | } | 381 | } |
380 | } | 382 | } |
381 | if (meta) { | 383 | if (meta) { |
382 | 384 | ||
383 | *meta = 0; | 385 | *meta = 0; |
384 | meta = 0; | 386 | meta = 0; |
385 | } | 387 | } |
386 | 388 | ||
387 | } else if (qkeycode == Qt::Key_Meta) { | 389 | } else if (qkeycode == Qt::Key_Meta) { |
388 | need_repaint = TRUE; | 390 | need_repaint = TRUE; |
389 | 391 | ||
390 | if (meta) { | 392 | if (meta) { |
391 | *meta = 0; | 393 | *meta = 0; |
392 | meta = 0; | 394 | meta = 0; |
393 | 395 | ||
394 | } else { | 396 | } else { |
395 | 397 | ||
396 | meta = keys->pressedPtr(row, col); | 398 | meta = keys->pressedPtr(row, col); |
397 | need_repaint = TRUE; | 399 | need_repaint = TRUE; |
398 | *meta = !keys->pressed(row, col); | 400 | *meta = !keys->pressed(row, col); |
399 | } | 401 | } |
400 | 402 | ||
401 | if (shift) { | 403 | if (shift) { |
402 | 404 | ||
403 | *shift = 0; | 405 | *shift = 0; |
404 | shift = 0; | 406 | shift = 0; |
405 | 407 | ||
406 | } | 408 | } |
407 | if (lock) { | 409 | if (lock) { |
408 | 410 | ||
409 | *lock = 0; | 411 | *lock = 0; |
410 | lock = 0; | 412 | lock = 0; |
411 | 413 | ||
412 | } | 414 | } |
413 | 415 | ||
414 | // dont need to emit this key... acts same as alt | 416 | // dont need to emit this key... acts same as alt |
415 | qkeycode = 0; | 417 | qkeycode = 0; |
416 | } | 418 | } |
417 | 419 | ||
418 | } | 420 | } |
419 | else { // normal char | 421 | else { // normal char |
420 | if ((shift || lock) && keys->shift(unicode)) { | 422 | if ((shift || lock) && keys->shift(unicode)) { |
421 | unicode = keys->shift(unicode); | 423 | unicode = keys->shift(unicode); |
422 | } | 424 | } |
423 | if (meta && keys->meta(unicode)) { | 425 | if (meta && keys->meta(unicode)) { |
424 | unicode = keys->meta(unicode); | 426 | unicode = keys->meta(unicode); |
425 | } | 427 | } |
426 | } | 428 | } |
427 | 429 | ||
428 | // korean parsing | 430 | // korean parsing |
429 | if (keys->lang == "ko") { | 431 | if (keys->lang == "ko") { |
430 | 432 | ||
431 | unicode = parseKoreanInput(unicode); | 433 | unicode = parseKoreanInput(unicode); |
432 | } | 434 | } |
433 | 435 | ||
434 | modifiers = (ctrl ? Qt::ControlButton : 0) | (alt ? Qt::AltButton : 0); | 436 | modifiers = (ctrl ? Qt::ControlButton : 0) | (alt ? Qt::AltButton : 0); |
435 | 437 | ||
436 | if ('A' <= unicode && unicode <= 'z' && modifiers) { | 438 | if ('A' <= unicode && unicode <= 'z' && modifiers) { |
437 | 439 | ||
438 | qkeycode = QChar(unicode).upper(); | 440 | qkeycode = QChar(unicode).upper(); |
439 | unicode = qkeycode - '@'; | 441 | unicode = qkeycode - '@'; |
440 | } | 442 | } |
441 | 443 | ||
442 | QWSServer::sendKeyEvent(unicode, qkeycode, modifiers, true, false); | 444 | QWSServer::sendKeyEvent(unicode, qkeycode, modifiers, true, false); |
443 | 445 | ||
444 | // pickboard stuff | 446 | // pickboard stuff |
445 | if (usePicks) { | 447 | if (usePicks) { |
446 | 448 | ||
447 | KeyboardConfig *dc = picks->dc; | 449 | KeyboardConfig *dc = picks->dc; |
448 | 450 | ||
449 | if (dc) { | 451 | if (dc) { |
450 | if (qkeycode == Qt::Key_Backspace) { | 452 | if (qkeycode == Qt::Key_Backspace) { |
451 | dc->input.remove(dc->input.last()); // remove last input | 453 | dc->input.remove(dc->input.last()); // remove last input |
452 | dc->decBackspaces(); | 454 | dc->decBackspaces(); |
453 | } else if ( qkeycode == Qt::Key_Return || QChar(unicode).isPunct() || QChar(unicode).isSpace() || unicode == 0) { | 455 | } else if ( qkeycode == Qt::Key_Return || QChar(unicode).isPunct() || QChar(unicode).isSpace() || unicode == 0) { |
454 | dc->input.clear(); | 456 | dc->input.clear(); |
455 | dc->resetBackspaces(); | 457 | dc->resetBackspaces(); |
456 | } else { | 458 | } else { |
457 | dc->add(QString(QChar(unicode))); | 459 | dc->add(QString(QChar(unicode))); |
458 | dc->incBackspaces(); | 460 | dc->incBackspaces(); |
459 | } | 461 | } |
460 | } | 462 | } |
461 | picks->repaint(); | 463 | picks->repaint(); |
462 | } | 464 | } |
463 | 465 | ||
464 | 466 | ||
465 | // painting | 467 | // painting |
466 | pressed = TRUE; | 468 | pressed = TRUE; |
467 | 469 | ||
468 | pressedKeyRow = row; | 470 | pressedKeyRow = row; |
469 | pressedKeyCol = col; | 471 | pressedKeyCol = col; |
470 | 472 | ||
471 | if (need_repaint) repaint(FALSE); | 473 | if (need_repaint) repaint(FALSE); |
472 | else { // just paint the one key pressed | 474 | else { // just paint the one key pressed |
473 | 475 | ||
474 | 476 | ||
475 | 477 | ||
476 | QPainter p(this); | 478 | QPainter p(this); |
477 | drawKeyboard(p, row, col); | 479 | drawKeyboard(p, row, col); |
478 | 480 | ||
479 | } | 481 | } |
480 | 482 | ||
481 | if (useRepeat) repeatTimer->start( 800 ); | 483 | if (useRepeat) repeatTimer->start( 800 ); |
482 | //pressTid = startTimer(80); | 484 | //pressTid = startTimer(80); |
483 | 485 | ||
484 | } | 486 | } |
485 | 487 | ||
486 | 488 | ||
487 | /* Keyboard::mouseReleaseEvent {{{1 */ | 489 | /* Keyboard::mouseReleaseEvent {{{1 */ |
488 | void Keyboard::mouseReleaseEvent(QMouseEvent*) | 490 | void Keyboard::mouseReleaseEvent(QMouseEvent*) |
489 | { | 491 | { |
490 | pressed = FALSE; | 492 | pressed = FALSE; |
491 | //if ( pressTid == 0 ) | 493 | //if ( pressTid == 0 ) |
492 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 494 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
493 | if ( unicode != -1 ) { | 495 | if ( unicode != -1 ) { |
494 | emit key( unicode, qkeycode, modifiers, false, false ); | 496 | emit key( unicode, qkeycode, modifiers, false, false ); |
495 | repeatTimer->stop(); | 497 | repeatTimer->stop(); |
496 | } | 498 | } |
497 | #endif | 499 | #endif |
498 | if (shift && unicode != 0) { | 500 | if (shift && unicode != 0) { |
499 | 501 | ||
500 | 502 | ||
501 | *shift = 0; // unpress shift key | 503 | *shift = 0; // unpress shift key |
502 | shift = 0; // reset the shift pointer | 504 | shift = 0; // reset the shift pointer |
503 | repaint(FALSE); | 505 | repaint(FALSE); |
504 | 506 | ||
505 | } else if (meta && unicode != 0) { | 507 | } else if (meta && unicode != 0) { |
506 | 508 | ||
507 | *meta = 0; | 509 | *meta = 0; |
508 | meta = 0; | 510 | meta = 0; |
509 | repaint(FALSE); | 511 | repaint(FALSE); |
510 | } | 512 | } |
511 | else | 513 | else |
512 | 514 | ||
513 | clearHighlight(); | 515 | clearHighlight(); |
514 | } | 516 | } |
515 | 517 | ||
516 | /* Keyboard::timerEvent {{{1 */ | 518 | /* Keyboard::timerEvent {{{1 */ |
517 | 519 | ||
518 | /* dont know what this does, but i think it is here so that if your screen | 520 | /* dont know what this does, but i think it is here so that if your screen |
519 | * sticks (like on an ipaq) then it will stop repeating if you click another | 521 | * sticks (like on an ipaq) then it will stop repeating if you click another |
520 | * key... but who knows what anything does in this thing anyway? | 522 | * key... but who knows what anything does in this thing anyway? |
521 | 523 | ||
522 | void Keyboard::timerEvent(QTimerEvent* e) | 524 | void Keyboard::timerEvent(QTimerEvent* e) |
523 | { | 525 | { |
524 | if ( e->timerId() == pressTid ) { | 526 | if ( e->timerId() == pressTid ) { |
525 | killTimer(pressTid); | 527 | killTimer(pressTid); |
526 | pressTid = 0; | 528 | pressTid = 0; |
527 | if ( !pressed ) | 529 | if ( !pressed ) |
528 | cout << "calling clearHighlight from timerEvent\n"; | 530 | cout << "calling clearHighlight from timerEvent\n"; |
529 | //clearHighlight(); | 531 | //clearHighlight(); |
530 | } | 532 | } |
531 | } | 533 | } |
532 | */ | 534 | */ |
533 | 535 | ||
534 | void Keyboard::repeat() | 536 | void Keyboard::repeat() |
535 | { | 537 | { |
536 | 538 | ||
537 | repeatTimer->start( 200 ); | 539 | repeatTimer->start( 200 ); |
538 | emit key( unicode, qkeycode, modifiers, true, true ); | 540 | emit key( unicode, qkeycode, modifiers, true, true ); |
539 | } | 541 | } |
540 | 542 | ||
541 | void Keyboard::clearHighlight() | 543 | void Keyboard::clearHighlight() |
542 | { | 544 | { |
543 | if ( pressedKeyRow >= 0 && pressedKeyCol >= 0) { | 545 | if ( pressedKeyRow >= 0 && pressedKeyCol >= 0) { |
544 | int tmpRow = pressedKeyRow; | 546 | int tmpRow = pressedKeyRow; |
545 | int tmpCol = pressedKeyCol; | 547 | int tmpCol = pressedKeyCol; |
546 | 548 | ||
547 | pressedKeyRow = -1; | 549 | pressedKeyRow = -1; |
548 | pressedKeyCol = -1; | 550 | pressedKeyCol = -1; |
549 | 551 | ||
550 | QPainter p(this); | 552 | QPainter p(this); |
551 | drawKeyboard(p, tmpRow, tmpCol); | 553 | drawKeyboard(p, tmpRow, tmpCol); |
552 | } | 554 | } |
553 | } | 555 | } |
554 | 556 | ||
555 | 557 | ||
556 | /* Keyboard::sizeHint {{{1 */ | 558 | /* Keyboard::sizeHint {{{1 */ |
557 | QSize Keyboard::sizeHint() const | 559 | QSize Keyboard::sizeHint() const |
558 | { | 560 | { |
559 | QFontMetrics fm=fontMetrics(); | 561 | QFontMetrics fm=fontMetrics(); |
560 | int keyHeight = fm.lineSpacing() + 2; | 562 | int keyHeight = fm.lineSpacing() + 2; |
561 | 563 | ||
562 | return QSize( 240, keyHeight * 5 + (usePicks ? picks->sizeHint().height() : 0) + 1); | 564 | return QSize( 240, keyHeight * 5 + (usePicks ? picks->sizeHint().height() : 0) + 1); |
563 | } | 565 | } |
564 | 566 | ||
565 | 567 | ||
566 | void Keyboard::resetState() | 568 | void Keyboard::resetState() |
567 | { | 569 | { |
568 | schar = mchar = echar = 0; | 570 | schar = mchar = echar = 0; |
569 | picks->resetState(); | 571 | picks->resetState(); |
570 | } | 572 | } |
571 | 573 | ||
572 | /* Keyboard::togglePickboard {{{1 */ | 574 | /* Keyboard::togglePickboard {{{1 */ |
573 | void Keyboard::togglePickboard(bool on_off) | 575 | void Keyboard::togglePickboard(bool on_off) |
574 | { | 576 | { |
575 | usePicks = on_off; | 577 | usePicks = on_off; |
576 | if (usePicks) { | 578 | if (usePicks) { |
577 | picks->show(); | 579 | picks->show(); |
578 | //move(x(), y() - picks->height()); // not required anymore because QCopChannel::send | 580 | //move(x(), y() - picks->height()); // not required anymore because QCopChannel::send |
579 | //adjustSize(); | 581 | //adjustSize(); |
580 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), | 582 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), |
581 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); | 583 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); |
582 | } else { | 584 | } else { |
583 | 585 | ||
584 | picks->hide(); | 586 | picks->hide(); |
585 | picks->resetState(); | 587 | picks->resetState(); |
586 | //move(x(), y() + picks->height()); | 588 | //move(x(), y() + picks->height()); |
587 | //adjustSize(); | 589 | //adjustSize(); |
588 | QObject::disconnect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), | 590 | QObject::disconnect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), |
589 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); | 591 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); |
590 | 592 | ||
591 | } | 593 | } |
592 | /* | 594 | /* |
593 | * this closes && opens the input method | 595 | * this closes && opens the input method |
594 | */ | 596 | */ |
595 | QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); | 597 | QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); |
596 | QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); | 598 | QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); |
597 | } | 599 | } |
598 | 600 | ||
599 | void Keyboard::toggleRepeat(bool on) { | 601 | void Keyboard::toggleRepeat(bool on) { |
600 | 602 | ||
601 | useRepeat = on; | 603 | useRepeat = on; |
602 | cout << "setting useRepeat to: " << useRepeat << "\n"; | 604 | cout << "setting useRepeat to: " << useRepeat << "\n"; |
603 | } | 605 | } |
604 | 606 | ||
605 | /* Keyboard::setMapTo ... {{{1 */ | 607 | /* Keyboard::setMapTo ... {{{1 */ |
606 | void Keyboard::setMapToDefault() { | 608 | void Keyboard::setMapToDefault() { |
607 | 609 | ||
608 | 610 | ||
609 | /* load current locale language map */ | 611 | /* load current locale language map */ |
610 | Config *config = new Config("locale"); | 612 | Config *config = new Config("locale"); |
611 | config->setGroup( "Language" ); | 613 | config->setGroup( "Language" ); |
612 | QString l = config->readEntry( "Language" , "en" ); | 614 | QString l = config->readEntry( "Language" , "en" ); |
613 | delete config; | 615 | delete config; |
614 | 616 | ||
615 | QString key_map = QPEApplication::qpeDir() + "/share/multikey/" | 617 | QString key_map = QPEApplication::qpeDir() + "/share/multikey/" |
616 | + l + ".keymap"; | 618 | + l + ".keymap"; |
617 | 619 | ||
618 | /* save change to multikey config file */ | 620 | /* save change to multikey config file */ |
619 | config = new Config("multikey"); | 621 | config = new Config("multikey"); |
620 | config->setGroup ("keymaps"); | 622 | config->setGroup ("keymaps"); |
621 | config->writeEntry ("current", key_map); // default closed | 623 | config->writeEntry ("current", key_map); // default closed |
622 | delete config; | 624 | delete config; |
623 | 625 | ||
624 | delete keys; | 626 | delete keys; |
625 | keys = new Keys(key_map); | 627 | keys = new Keys(key_map); |
626 | 628 | ||
627 | // have to repaint the keyboard | 629 | // have to repaint the keyboard |
628 | repaint(FALSE); | 630 | repaint(FALSE); |
629 | } | 631 | } |
630 | 632 | ||
631 | void Keyboard::setMapToFile(QString map) { | 633 | void Keyboard::setMapToFile(QString map) { |
632 | 634 | ||
633 | /* save change to multikey config file */ | 635 | /* save change to multikey config file */ |
634 | Config *config = new Config("multikey"); | 636 | Config *config = new Config("multikey"); |
635 | config->setGroup ("keymaps"); | 637 | config->setGroup ("keymaps"); |
636 | config->writeEntry ("current", map); // default closed | 638 | config->writeEntry ("current", map); // default closed |
637 | 639 | ||
638 | delete config; | 640 | delete config; |
639 | 641 | ||
640 | delete keys; | 642 | delete keys; |
641 | if (QFile(map).exists()) | 643 | if (QFile(map).exists()) |
642 | keys = new Keys(map); | 644 | keys = new Keys(map); |
643 | else | 645 | else |
644 | keys = new Keys(); | 646 | keys = new Keys(); |
645 | 647 | ||
646 | repaint(FALSE); | 648 | repaint(FALSE); |
647 | 649 | ||
648 | } | 650 | } |
649 | 651 | ||
650 | /* Keybaord::reloadKeyboard {{{1 */ | 652 | /* Keybaord::reloadKeyboard {{{1 */ |
651 | void Keyboard::reloadKeyboard() { | 653 | void Keyboard::reloadKeyboard() { |
652 | 654 | ||
653 | // reload colors and redraw | 655 | // reload colors and redraw |
654 | loadKeyboardColors(); | 656 | loadKeyboardColors(); |
655 | repaint(); | 657 | repaint(); |
656 | 658 | ||
657 | } | 659 | } |
658 | 660 | ||
659 | void Keyboard::loadKeyboardColors() { | 661 | void Keyboard::loadKeyboardColors() { |
660 | 662 | ||
661 | Config config ("multikey"); | 663 | Config config ("multikey"); |
662 | config.setGroup("colors"); | 664 | config.setGroup("colors"); |
663 | 665 | ||
664 | QStringList color; | 666 | QStringList color; |
665 | color = config.readListEntry("keycolor", QChar(',')); | 667 | color = config.readListEntry("keycolor", QChar(',')); |
666 | if (color.isEmpty()) { | 668 | if (color.isEmpty()) { |
667 | color = QStringList::split(",", "240,240,240"); | 669 | color = QStringList::split(",", "240,240,240"); |
668 | config.writeEntry("keycolor", color.join(",")); | 670 | config.writeEntry("keycolor", color.join(",")); |
669 | 671 | ||
670 | } | 672 | } |
671 | keycolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); | 673 | keycolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); |
672 | 674 | ||
673 | color = config.readListEntry("keycolor_pressed", QChar(',')); | 675 | color = config.readListEntry("keycolor_pressed", QChar(',')); |
674 | if (color.isEmpty()) { | 676 | if (color.isEmpty()) { |
675 | color = QStringList::split(",", "171,183,198"); | 677 | color = QStringList::split(",", "171,183,198"); |
676 | config.writeEntry("keycolor_pressed", color.join(",")); | 678 | config.writeEntry("keycolor_pressed", color.join(",")); |
677 | 679 | ||
678 | } | 680 | } |
679 | keycolor_pressed = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); | 681 | keycolor_pressed = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); |
680 | 682 | ||
681 | color = config.readListEntry("keycolor_lines", QChar(',')); | 683 | color = config.readListEntry("keycolor_lines", QChar(',')); |
682 | if (color.isEmpty()) { | 684 | if (color.isEmpty()) { |
683 | color = QStringList::split(",", "138,148,160"); | 685 | color = QStringList::split(",", "138,148,160"); |
684 | config.writeEntry("keycolor_lines", color.join(",")); | 686 | config.writeEntry("keycolor_lines", color.join(",")); |
685 | 687 | ||
686 | } | 688 | } |
687 | keycolor_lines = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); | 689 | keycolor_lines = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); |
688 | 690 | ||
689 | color = config.readListEntry("textcolor", QChar(',')); | 691 | color = config.readListEntry("textcolor", QChar(',')); |
690 | if (color.isEmpty()) { | 692 | if (color.isEmpty()) { |
691 | color = QStringList::split(",", "43,54,68"); | 693 | color = QStringList::split(",", "43,54,68"); |
692 | config.writeEntry("textcolor", color.join(",")); | 694 | config.writeEntry("textcolor", color.join(",")); |
693 | 695 | ||
694 | } | 696 | } |
695 | textcolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); | 697 | textcolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); |
696 | 698 | ||
697 | } | 699 | } |
698 | 700 | ||
699 | /* korean input functions {{{1 | 701 | /* korean input functions {{{1 |
700 | * | 702 | * |
701 | * TODO | 703 | * TODO |
702 | * one major problem with this implementation is that you can't move the | 704 | * one major problem with this implementation is that you can't move the |
703 | * cursor after inputing korean chars, otherwise it will eat up and replace | 705 | * cursor after inputing korean chars, otherwise it will eat up and replace |
704 | * the char before the cursor you move to. fix that | 706 | * the char before the cursor you move to. fix that |
705 | * | 707 | * |
706 | * make backspace delete one single char, not the whole thing if still | 708 | * make backspace delete one single char, not the whole thing if still |
707 | * editing. | 709 | * editing. |
708 | * | 710 | * |
709 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | 711 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
710 | * | 712 | * |
711 | * how korean input works | 713 | * how korean input works |
712 | * | 714 | * |
713 | * all following chars means unicode char value and are in hex | 715 | * all following chars means unicode char value and are in hex |
714 | * | 716 | * |
715 | * ÃÊÀ½ = schar (start char) | 717 | * ÃÊÀ½ = schar (start char) |
716 | * ÁßÀ½ = mchar (middle char) | 718 | * ÁßÀ½ = mchar (middle char) |
717 | * ³¡À½ = echar (end char) | 719 | * ³¡À½ = echar (end char) |
718 | * | 720 | * |
719 | * there are 19 schars. unicode position is at 1100 - 1112 | 721 | * there are 19 schars. unicode position is at 1100 - 1112 |
720 | * there are 21 mchars. unicode position is at 1161 - 1175 | 722 | * there are 21 mchars. unicode position is at 1161 - 1175 |
721 | * there are 27 echars. unicode position is at 11a8 - 11c2 | 723 | * there are 27 echars. unicode position is at 11a8 - 11c2 |
722 | * | 724 | * |
723 | * the map with everything combined is at ac00 - d7a3 | 725 | * the map with everything combined is at ac00 - d7a3 |
724 | * | 726 | * |
725 | */ | 727 | */ |
726 | 728 | ||
727 | ushort Keyboard::parseKoreanInput (ushort c) { | 729 | ushort Keyboard::parseKoreanInput (ushort c) { |
728 | 730 | ||
729 | if ((c != 0 && (c < 0x1100 || 0x11c2 < c) && (c < 0xac00 || 0xd7a3 < c)) | 731 | if ((c != 0 && (c < 0x1100 || 0x11c2 < c) && (c < 0xac00 || 0xd7a3 < c)) |
730 | || | 732 | || |
731 | (c == 0 && qkeycode != Qt::Key_Shift && Qt::Key_CapsLock != qkeycode | 733 | (c == 0 && qkeycode != Qt::Key_Shift && Qt::Key_CapsLock != qkeycode |
732 | && qkeycode != Qt::Key_Control && qkeycode != Qt::Key_Alt)) { | 734 | && qkeycode != Qt::Key_Control && qkeycode != Qt::Key_Alt)) { |
733 | 735 | ||
734 | schar = 0, mchar = 0, echar = 0; | 736 | schar = 0, mchar = 0, echar = 0; |
735 | return c; | 737 | return c; |
736 | } | 738 | } |
737 | 739 | ||
738 | if ( 0x1100 <= c && c <= 0x1112 ) { // schar or echar was input | 740 | if ( 0x1100 <= c && c <= 0x1112 ) { // schar or echar was input |
739 | 741 | ||
740 | if (schar == 0 || (schar != 0 && mchar == 0)) { | 742 | if (schar == 0 || (schar != 0 && mchar == 0)) { |
741 | schar = c; mchar = 0; echar = 0; | 743 | schar = c; mchar = 0; echar = 0; |
742 | return c; | 744 | return c; |
743 | } | 745 | } |
744 | else if (mchar != 0) { | 746 | else if (mchar != 0) { |
745 | 747 | ||
746 | if (echar == 0) { | 748 | if (echar == 0) { |
747 | 749 | ||
748 | if (!(echar = constoe(c))) { | 750 | if (!(echar = constoe(c))) { |
749 | 751 | ||
750 | schar = c; mchar = 0; echar = 0; | 752 | schar = c; mchar = 0; echar = 0; |
751 | return c; | 753 | return c; |
752 | } | 754 | } |
753 | 755 | ||
754 | } | 756 | } |
755 | else { // must figure out what the echar is | 757 | else { // must figure out what the echar is |
756 | 758 | ||
757 | if (echar == 0x11a8) { // ¤¡ | 759 | if (echar == 0x11a8) { // ¤¡ |
758 | 760 | ||
759 | if (c == 0x1100) echar = 0x11a9; // ¤¡ + ¤¡ | 761 | if (c == 0x1100) echar = 0x11a9; // ¤¡ + ¤¡ |
760 | else if (c == 0x1109) echar = 0x11aa; // ¤¡ + ¤µ | 762 | else if (c == 0x1109) echar = 0x11aa; // ¤¡ + ¤µ |
761 | else { | 763 | else { |
762 | schar = c; mchar = 0; echar = 0; | 764 | schar = c; mchar = 0; echar = 0; |
763 | return c; | 765 | return c; |
764 | } | 766 | } |
765 | 767 | ||
766 | } else if (echar == 0x11ab) { // ¤¤ | 768 | } else if (echar == 0x11ab) { // ¤¤ |
767 | 769 | ||
768 | if (c == 0x110c) echar = 0x11ac; // ¤¤ + ¤¸ | 770 | if (c == 0x110c) echar = 0x11ac; // ¤¤ + ¤¸ |
769 | else if (c == 0x1112) echar = 0x11ad; // ¤¤ + ¤¾ | 771 | else if (c == 0x1112) echar = 0x11ad; // ¤¤ + ¤¾ |
770 | else { | 772 | else { |
771 | schar = c; mchar = 0; echar = 0; | 773 | schar = c; mchar = 0; echar = 0; |
772 | return c; | 774 | return c; |
773 | } | 775 | } |
774 | 776 | ||
775 | } else if (echar == 0x11af) { // ¤© | 777 | } else if (echar == 0x11af) { // ¤© |
776 | 778 | ||
777 | if (c == 0x1100) echar = 0x11b0; // ¤© + ¤¡ | 779 | if (c == 0x1100) echar = 0x11b0; // ¤© + ¤¡ |
778 | else if (c == 0x1106) echar = 0x11b1; // ¤© + ¤± | 780 | else if (c == 0x1106) echar = 0x11b1; // ¤© + ¤± |
779 | else if (c == 0x1107) echar = 0x11b2; // ¤© + ¤² | 781 | else if (c == 0x1107) echar = 0x11b2; // ¤© + ¤² |
780 | else if (c == 0x1109) echar = 0x11b3; // ¤© + ¤µ | 782 | else if (c == 0x1109) echar = 0x11b3; // ¤© + ¤µ |
781 | else if (c == 0x1110) echar = 0x11b4; // ¤© + ¤¼ | 783 | else if (c == 0x1110) echar = 0x11b4; // ¤© + ¤¼ |
782 | else if (c == 0x1111) echar = 0x11b5; // ¤© + ¤½ | 784 | else if (c == 0x1111) echar = 0x11b5; // ¤© + ¤½ |
783 | else if (c == 0x1112) echar = 0x11b6; // ¤© + ¤¾ | 785 | else if (c == 0x1112) echar = 0x11b6; // ¤© + ¤¾ |
784 | else { | 786 | else { |
785 | schar = c; mchar = 0; echar = 0; | 787 | schar = c; mchar = 0; echar = 0; |
786 | return c; | 788 | return c; |
787 | } | 789 | } |
788 | 790 | ||
789 | } else if (echar == 0x11b8) { // ¤² | 791 | } else if (echar == 0x11b8) { // ¤² |
790 | 792 | ||
791 | if (c == 0x1109) echar = 0x11b9; // ¤² + ¤µ | 793 | if (c == 0x1109) echar = 0x11b9; // ¤² + ¤µ |
792 | else { | 794 | else { |
793 | schar = c; mchar = 0; echar = 0; | 795 | schar = c; mchar = 0; echar = 0; |
794 | return c; | 796 | return c; |
795 | } | 797 | } |
796 | 798 | ||
797 | } else if (echar == 0x11ba) { // ¤µ | 799 | } else if (echar == 0x11ba) { // ¤µ |
798 | 800 | ||
799 | if (c == 0x1109) echar = 0x11bb; // ¤µ + ¤µ | 801 | if (c == 0x1109) echar = 0x11bb; // ¤µ + ¤µ |
800 | else { | 802 | else { |
801 | schar = c; mchar = 0; echar = 0; | 803 | schar = c; mchar = 0; echar = 0; |
802 | return c; | 804 | return c; |
803 | } | 805 | } |
804 | 806 | ||
805 | } else { // if any other char, cannot combine chars | 807 | } else { // if any other char, cannot combine chars |
806 | 808 | ||
807 | schar = c; mchar = 0; echar = 0; | 809 | schar = c; mchar = 0; echar = 0; |
808 | return c; | 810 | return c; |
809 | } | 811 | } |
810 | 812 | ||
811 | unicode = echar; | 813 | unicode = echar; |
812 | } | 814 | } |
813 | } | 815 | } |
814 | 816 | ||
815 | } | 817 | } |
816 | else if (0x1161 <= c && c <= 0x1175) { // mchar was input | 818 | else if (0x1161 <= c && c <= 0x1175) { // mchar was input |
817 | 819 | ||
818 | if (schar != 0 && mchar == 0) { mchar = c; } | 820 | if (schar != 0 && mchar == 0) { mchar = c; } |
819 | 821 | ||
820 | else if (schar != 0 && mchar != 0 && echar == 0) { | 822 | else if (schar != 0 && mchar != 0 && echar == 0) { |
821 | 823 | ||
822 | switch (mchar) { | 824 | switch (mchar) { |
823 | case 0x1169: | 825 | case 0x1169: |
824 | if (c == 0x1161) mchar = 0x116a; | 826 | if (c == 0x1161) mchar = 0x116a; |
825 | else if (c == 0x1162) mchar = 0x116b; | 827 | else if (c == 0x1162) mchar = 0x116b; |
826 | else if (c == 0x1175) mchar = 0x116c; | 828 | else if (c == 0x1175) mchar = 0x116c; |
827 | else { | 829 | else { |
828 | schar = 0; mchar = 0; echar = 0; | 830 | schar = 0; mchar = 0; echar = 0; |
829 | return c; | 831 | return c; |
830 | } | 832 | } |
831 | break; | 833 | break; |
832 | case 0x116e: | 834 | case 0x116e: |
833 | if (c == 0x1165) mchar = 0x116f; | 835 | if (c == 0x1165) mchar = 0x116f; |
834 | else if (c == 0x1166) mchar = 0x1170; | 836 | else if (c == 0x1166) mchar = 0x1170; |
835 | else if (c == 0x1175) mchar = 0x1171; | 837 | else if (c == 0x1175) mchar = 0x1171; |
836 | else { | 838 | else { |
837 | schar = 0; mchar = 0; echar = 0; | 839 | schar = 0; mchar = 0; echar = 0; |
838 | return c; | 840 | return c; |
839 | } | 841 | } |
840 | break; | 842 | break; |
841 | case 0x1173: | 843 | case 0x1173: |
842 | if (c == 0x1175) mchar = 0x1174; | 844 | if (c == 0x1175) mchar = 0x1174; |
843 | else { | 845 | else { |
844 | schar = 0; mchar = 0; echar = 0; | 846 | schar = 0; mchar = 0; echar = 0; |
845 | return c; | 847 | return c; |
846 | } | 848 | } |
847 | break; | 849 | break; |
848 | default: | 850 | default: |
849 | schar = 0; mchar = 0; echar = 0; | 851 | schar = 0; mchar = 0; echar = 0; |
850 | return c; | 852 | return c; |
851 | } | 853 | } |
852 | } | 854 | } |
853 | else if (schar != 0 && mchar != 0 && echar != 0) { | 855 | else if (schar != 0 && mchar != 0 && echar != 0) { |
854 | 856 | ||
855 | emit key( 8, Qt::Key_Backspace, 0, true, false ); | 857 | emit key( 8, Qt::Key_Backspace, 0, true, false ); |
856 | 858 | ||
857 | ushort prev = 0; | 859 | ushort prev = 0; |
858 | switch (echar) { | 860 | switch (echar) { |
859 | /* | 861 | /* |
860 | case 0x11a9: | 862 | case 0x11a9: |
861 | prev = combineKoreanChars(schar, mchar, 0x11a8); | 863 | prev = combineKoreanChars(schar, mchar, 0x11a8); |
862 | schar = 0x1100; | 864 | schar = 0x1100; |
863 | break; | 865 | break; |
864 | */ | 866 | */ |
865 | case 0x11aa: | 867 | case 0x11aa: |
866 | prev = combineKoreanChars(schar, mchar, 0x11a8); | 868 | prev = combineKoreanChars(schar, mchar, 0x11a8); |
867 | schar = 0x1109; | 869 | schar = 0x1109; |
868 | break; | 870 | break; |
869 | case 0x11ac: | 871 | case 0x11ac: |
870 | prev = combineKoreanChars(schar, mchar, 0x11ab); | 872 | prev = combineKoreanChars(schar, mchar, 0x11ab); |
871 | schar = 0x110c; | 873 | schar = 0x110c; |
872 | break; | 874 | break; |
873 | case 0x11ad: | 875 | case 0x11ad: |
874 | prev = combineKoreanChars(schar, mchar, 0x11ab); | 876 | prev = combineKoreanChars(schar, mchar, 0x11ab); |
875 | schar = 0x1112; | 877 | schar = 0x1112; |
876 | break; | 878 | break; |
877 | case 0x11b0: | 879 | case 0x11b0: |
878 | prev = combineKoreanChars(schar, mchar, 0x11af); | 880 | prev = combineKoreanChars(schar, mchar, 0x11af); |
879 | schar = 0x1100; | 881 | schar = 0x1100; |
880 | break; | 882 | break; |
881 | case 0x11b1: | 883 | case 0x11b1: |
882 | prev = combineKoreanChars(schar, mchar, 0x11af); | 884 | prev = combineKoreanChars(schar, mchar, 0x11af); |
883 | schar = 0x1106; | 885 | schar = 0x1106; |
884 | break; | 886 | break; |
885 | case 0x11b2: | 887 | case 0x11b2: |
886 | prev = combineKoreanChars(schar, mchar, 0x11af); | 888 | prev = combineKoreanChars(schar, mchar, 0x11af); |
887 | schar = 0x1107; | 889 | schar = 0x1107; |
888 | break; | 890 | break; |
889 | case 0x11b3: | 891 | case 0x11b3: |
890 | prev = combineKoreanChars(schar, mchar, 0x11af); | 892 | prev = combineKoreanChars(schar, mchar, 0x11af); |
891 | schar = 0x1109; | 893 | schar = 0x1109; |
892 | break; | 894 | break; |
893 | case 0x11b4: | 895 | case 0x11b4: |
894 | prev = combineKoreanChars(schar, mchar, 0x11af); | 896 | prev = combineKoreanChars(schar, mchar, 0x11af); |
895 | schar = 0x1110; | 897 | schar = 0x1110; |
896 | break; | 898 | break; |
897 | case 0x11b9: | 899 | case 0x11b9: |
898 | prev = combineKoreanChars(schar, mchar, 0x11b8); | 900 | prev = combineKoreanChars(schar, mchar, 0x11b8); |
899 | schar = 0x1109; | 901 | schar = 0x1109; |
900 | break; | 902 | break; |
901 | /* | 903 | /* |
902 | case 0x11bb: | 904 | case 0x11bb: |
903 | prev = combineKoreanChars(schar, mchar, 0x11ba); | 905 | prev = combineKoreanChars(schar, mchar, 0x11ba); |
904 | schar = 0x1109; | 906 | schar = 0x1109; |
905 | break; | 907 | break; |
906 | */ | 908 | */ |
907 | default: | 909 | default: |
908 | 910 | ||
909 | if (constoe(echar)) { | 911 | if (constoe(echar)) { |
910 | 912 | ||
911 | prev = combineKoreanChars(schar, mchar, 0); | 913 | prev = combineKoreanChars(schar, mchar, 0); |
912 | schar = constoe(echar); | 914 | schar = constoe(echar); |
913 | } | 915 | } |
914 | break; | 916 | break; |
915 | } | 917 | } |
916 | 918 | ||
917 | emit key( prev, prev, 0, true, false ); | 919 | emit key( prev, prev, 0, true, false ); |
918 | 920 | ||
919 | mchar = c; echar = 0; | 921 | mchar = c; echar = 0; |
920 | 922 | ||
921 | return combineKoreanChars(schar, mchar, 0); | 923 | return combineKoreanChars(schar, mchar, 0); |
922 | 924 | ||
923 | } | 925 | } |
924 | else { | 926 | else { |
925 | schar = 0; mchar = 0; echar = 0; | 927 | schar = 0; mchar = 0; echar = 0; |
926 | return c; | 928 | return c; |
927 | } | 929 | } |
928 | 930 | ||
929 | } | 931 | } |
930 | else /*if (c == ' ')*/ return c; | 932 | else /*if (c == ' ')*/ return c; |
931 | 933 | ||
932 | 934 | ||
933 | // and now... finally delete previous char, and return new char | 935 | // and now... finally delete previous char, and return new char |
934 | emit key( 8, Qt::Key_Backspace, 0, true, false ); | 936 | emit key( 8, Qt::Key_Backspace, 0, true, false ); |
935 | 937 | ||
936 | 938 | ||
937 | return combineKoreanChars( schar, mchar, echar); | 939 | return combineKoreanChars( schar, mchar, echar); |
938 | 940 | ||
939 | } | 941 | } |
940 | 942 | ||
941 | ushort Keyboard::combineKoreanChars(const ushort s, const ushort m, const ushort e) { | 943 | ushort Keyboard::combineKoreanChars(const ushort s, const ushort m, const ushort e) { |
942 | 944 | ||
943 | return ((s - 0x1100) * 588) + ((m - 0x1161) * 28) + (e ? e - 0x11a7 : 0) + 0xac00; | 945 | return ((s - 0x1100) * 588) + ((m - 0x1161) * 28) + (e ? e - 0x11a7 : 0) + 0xac00; |
944 | 946 | ||
945 | } | 947 | } |
946 | 948 | ||
947 | ushort Keyboard::constoe(const ushort c) { | 949 | ushort Keyboard::constoe(const ushort c) { |
948 | 950 | ||
949 | // converts schars to echars if possible | 951 | // converts schars to echars if possible |
950 | 952 | ||
951 | if (0x1100 <= c && c <= 0x1112) { // schar to echar | 953 | if (0x1100 <= c && c <= 0x1112) { // schar to echar |
952 | 954 | ||
953 | switch (c) { | 955 | switch (c) { |
954 | case 0x1100: return 0x11a8; | 956 | case 0x1100: return 0x11a8; |
955 | case 0x1101: return 0x11a9; | 957 | case 0x1101: return 0x11a9; |
956 | case 0x1102: return 0x11ab; | 958 | case 0x1102: return 0x11ab; |
957 | case 0x1103: return 0x11ae; | 959 | case 0x1103: return 0x11ae; |
958 | case 0x1105: return 0x11af; | 960 | case 0x1105: return 0x11af; |
959 | case 0x1106: return 0x11b7; | 961 | case 0x1106: return 0x11b7; |
960 | case 0x1107: return 0x11b8; | 962 | case 0x1107: return 0x11b8; |
961 | case 0x1109: return 0x11ba; | 963 | case 0x1109: return 0x11ba; |
962 | case 0x110a: return 0x11bb; | 964 | case 0x110a: return 0x11bb; |
963 | case 0x110b: return 0x11bc; | 965 | case 0x110b: return 0x11bc; |
964 | case 0x110c: return 0x11bd; | 966 | case 0x110c: return 0x11bd; |
965 | case 0x110e: return 0x11be; | 967 | case 0x110e: return 0x11be; |
966 | case 0x110f: return 0x11bf; | 968 | case 0x110f: return 0x11bf; |
967 | case 0x1110: return 0x11c0; | 969 | case 0x1110: return 0x11c0; |
968 | case 0x1111: return 0x11c1; | 970 | case 0x1111: return 0x11c1; |
969 | case 0x1112: return 0x11c2; | 971 | case 0x1112: return 0x11c2; |
970 | default: return 0; | 972 | default: return 0; |
971 | 973 | ||
972 | } | 974 | } |
973 | 975 | ||
974 | } else { //echar to schar | 976 | } else { //echar to schar |
975 | 977 | ||
976 | switch (c) { | 978 | switch (c) { |
977 | case 0x11a8: return 0x1100; | 979 | case 0x11a8: return 0x1100; |
978 | case 0x11a9: return 0x1101; | 980 | case 0x11a9: return 0x1101; |
979 | case 0x11ab: return 0x1102; | 981 | case 0x11ab: return 0x1102; |
980 | case 0x11ae: return 0x1103; | 982 | case 0x11ae: return 0x1103; |
981 | case 0x11af: return 0x1105; | 983 | case 0x11af: return 0x1105; |
982 | case 0x11b7: return 0x1106; | 984 | case 0x11b7: return 0x1106; |
983 | case 0x11b8: return 0x1107; | 985 | case 0x11b8: return 0x1107; |
984 | case 0x11ba: return 0x1109; | 986 | case 0x11ba: return 0x1109; |
985 | case 0x11bb: return 0x110a; | 987 | case 0x11bb: return 0x110a; |
986 | case 0x11bc: return 0x110b; | 988 | case 0x11bc: return 0x110b; |
987 | case 0x11bd: return 0x110c; | 989 | case 0x11bd: return 0x110c; |
988 | case 0x11be: return 0x110e; | 990 | case 0x11be: return 0x110e; |
989 | case 0x11bf: return 0x110f; | 991 | case 0x11bf: return 0x110f; |
990 | case 0x11c0: return 0x1110; | 992 | case 0x11c0: return 0x1110; |
991 | case 0x11c1: return 0x1111; | 993 | case 0x11c1: return 0x1111; |
992 | case 0x11c2: return 0x1112; | 994 | case 0x11c2: return 0x1112; |
993 | default: return 0; | 995 | default: return 0; |
994 | 996 | ||
995 | } | 997 | } |
996 | 998 | ||
997 | } | 999 | } |
998 | } | 1000 | } |
999 | 1001 | ||
1000 | 1002 | ||
1001 | // Keys::Keys {{{1 | 1003 | // Keys::Keys {{{1 |
1002 | 1004 | ||
1003 | Keys::Keys() { | 1005 | Keys::Keys() { |
1004 | 1006 | ||
1005 | Config *config = new Config ("multikey"); | 1007 | Config *config = new Config ("multikey"); |
1006 | config->setGroup( "keymaps" ); | 1008 | config->setGroup( "keymaps" ); |
1007 | QString map = config->readEntry( "current" ); | 1009 | QString map = config->readEntry( "current" ); |
1008 | delete config; | 1010 | delete config; |
1009 | 1011 | ||
1010 | if (map.isNull() || !(QFile(map).exists())) { | 1012 | if (map.isNull() || !(QFile(map).exists())) { |
1011 | 1013 | ||
1012 | Config *config = new Config("locale"); | 1014 | Config *config = new Config("locale"); |
1013 | config->setGroup( "Language" ); | 1015 | config->setGroup( "Language" ); |
1014 | QString l = config->readEntry( "Language" , "en" ); | 1016 | QString l = config->readEntry( "Language" , "en" ); |
1015 | delete config; | 1017 | delete config; |
1016 | 1018 | ||
1017 | map = QPEApplication::qpeDir() + "/share/multikey/" | 1019 | map = QPEApplication::qpeDir() + "/share/multikey/" |
1018 | + l + ".keymap"; | 1020 | + l + ".keymap"; |
1019 | 1021 | ||
1020 | } | 1022 | } |
1021 | 1023 | ||
1022 | setKeysFromFile(map); | 1024 | setKeysFromFile(map); |
1023 | } | 1025 | } |
1024 | 1026 | ||
1025 | Keys::Keys(const char * filename) { | 1027 | Keys::Keys(const char * filename) { |
1026 | 1028 | ||