summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/multikey/keyboard.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp
index 08318bd..84c0c74 100644
--- a/inputmethods/multikey/keyboard.cpp
+++ b/inputmethods/multikey/keyboard.cpp
@@ -1,1653 +1,1659 @@
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 37
38#include <sys/utsname.h> 38#include <sys/utsname.h>
39 39
40 40
41/* Keyboard::Keyboard {{{1 */ 41/* Keyboard::Keyboard {{{1 */
42Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : 42Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) :
43 QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), alt(0), 43 QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), alt(0),
44 meta(0), circumflex(0), diaeresis(0), baccent(0), accent(0), 44 meta(0), circumflex(0), diaeresis(0), baccent(0), accent(0),
45 useLargeKeys(TRUE), usePicks(0), useRepeat(0), 45 useLargeKeys(TRUE), usePicks(0), useRepeat(0),
46 pressedKeyRow(-1), pressedKeyCol(-1), 46 pressedKeyRow(-1), pressedKeyCol(-1),
47 unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0), 47 unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0),
48 configdlg(0) 48 configdlg(0)
49 49
50{ 50{
51 51
52 // get the default font 52 // get the default font
53 Config *config = new Config( "qpe" ); 53 Config *config = new Config( "qpe" );
54 config->setGroup( "Appearance" ); 54 config->setGroup( "Appearance" );
55 QString familyStr = config->readEntry( "FontFamily", "fixed" ); 55 QString familyStr = config->readEntry( "FontFamily", "fixed" );
56 delete config; 56 delete config;
57 57
58 config = new Config("multikey"); 58 config = new Config("multikey");
59 config->setGroup ("general"); 59 config->setGroup ("general");
60 usePicks = config->readBoolEntry ("usePickboard", 0); // default closed 60 usePicks = config->readBoolEntry ("usePickboard", 0); // default closed
61 useRepeat = config->readBoolEntry ("useRepeat", 1); 61 useRepeat = config->readBoolEntry ("useRepeat", 1);
62 delete config; 62 delete config;
63 63
64 64
65 setFont( QFont( familyStr, 10 ) ); 65 setFont( QFont( familyStr, 10 ) );
66 66
67 picks = new KeyboardPicks( this ); 67 picks = new KeyboardPicks( this );
68 picks->setFont( QFont( familyStr, 10 ) ); 68 picks->setFont( QFont( familyStr, 10 ) );
69 picks->initialise(); 69 picks->initialise();
70 if (usePicks) { 70 if (usePicks) {
71 71
72 QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), 72 QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ),
73 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); 73 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) );
74 74
75 } else picks->hide(); 75 } else picks->hide();
76 76
77 loadKeyboardColors(); 77 loadKeyboardColors();
78 78
79 keys = new Keys(); 79 keys = new Keys();
80 80
81 repeatTimer = new QTimer( this ); 81 repeatTimer = new QTimer( this );
82 connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); 82 connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) );
83 83
84} 84}
85 85
86Keyboard::~Keyboard() { 86Keyboard::~Keyboard() {
87 87
88 if ( configdlg ) { 88 if ( configdlg ) {
89 delete (ConfigDlg *) configdlg; 89 delete (ConfigDlg *) configdlg;
90 configdlg = 0; 90 configdlg = 0;
91 } 91 }
92 92
93} 93}
94 94
95/* Keyboard::resizeEvent {{{1 */ 95/* Keyboard::resizeEvent {{{1 */
96void Keyboard::resizeEvent(QResizeEvent*) 96void Keyboard::resizeEvent(QResizeEvent*)
97{ 97{
98 int ph = picks->sizeHint().height(); 98 int ph = picks->sizeHint().height();
99 picks->setGeometry( 0, 0, width(), ph ); 99 picks->setGeometry( 0, 0, width(), ph );
100 keyHeight = (height()-(usePicks ? ph : 0))/(keys->rows()?keys->rows():1); 100 keyHeight = (height()-(usePicks ? ph : 0))/(keys->rows()?keys->rows():1);
101 101
102 int nk; // number of keys? 102 int nk; // number of keys?
103 if ( useLargeKeys ) { 103 if ( useLargeKeys ) {
104 nk = 15; 104 nk = 15;
105 } else { 105 } else {
106 nk = 19; 106 nk = 19;
107 } 107 }
108 defaultKeyWidth = (width()/nk)/2; 108 defaultKeyWidth = (width()/nk)/2;
109 xoffs = (width()-defaultKeyWidth*nk)/2; // empty key spaces? 109 xoffs = (width()-defaultKeyWidth*nk)/2; // empty key spaces?
110 110
111} 111}
112 112
113/* KeyboardPicks::initialize {{{1 */ 113/* KeyboardPicks::initialize {{{1 */
114void KeyboardPicks::initialise() 114void KeyboardPicks::initialise()
115{ 115{
116 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); 116 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
117 mode = 0; 117 mode = 0;
118 dc = new KeyboardConfig(this); 118 dc = new KeyboardConfig(this);
119 configs.append(dc); 119 configs.append(dc);
120} 120}
121 121
122/* KeyboardPicks::sizeHint {{{1 */ 122/* KeyboardPicks::sizeHint {{{1 */
123QSize KeyboardPicks::sizeHint() const 123QSize KeyboardPicks::sizeHint() const
124{ 124{
125 return QSize(240,fontMetrics().lineSpacing()); 125 return QSize(240,fontMetrics().lineSpacing());
126} 126}
127 127
128 128
129/* KeyboardConfig::generateText {{{1 */ 129/* KeyboardConfig::generateText {{{1 */
130void KeyboardConfig::generateText(const QString &s) 130void KeyboardConfig::generateText(const QString &s)
131{ 131{
132#if defined(Q_WS_QWS) || defined(_WS_QWS_) 132#if defined(Q_WS_QWS) || defined(_WS_QWS_)
133 for (int i=0; i<(int)backspaces; i++) { 133 for (int i=0; i<(int)backspaces; i++) {
134 parent->emitKey( 0, Qt::Key_Backspace, 0, true, false ); 134 parent->emitKey( 0, Qt::Key_Backspace, 0, true, false );
135 parent->emitKey( 0, Qt::Key_Backspace, 0, false, false ); 135 parent->emitKey( 0, Qt::Key_Backspace, 0, false, false );
136 } 136 }
137 for (int i=0; i<(int)s.length(); i++) { 137 for (int i=0; i<(int)s.length(); i++) {
138 parent->emitKey( s[i].unicode(), 0, 0, true, false ); 138 parent->emitKey( s[i].unicode(), 0, 0, true, false );
139 parent->emitKey( s[i].unicode(), 0, 0, false, false ); 139 parent->emitKey( s[i].unicode(), 0, 0, false, false );
140 } 140 }
141 parent->emitKey( 0, Qt::Key_Space, 0, true, false ); 141 parent->emitKey( 0, Qt::Key_Space, 0, true, false );
142 parent->emitKey( 0, Qt::Key_Space, 0, false, false ); 142 parent->emitKey( 0, Qt::Key_Space, 0, false, false );
143 backspaces = 0; 143 backspaces = 0;
144#endif 144#endif
145} 145}
146 146
147 147
148 148
149 149
150/* Keyboard::paintEvent {{{1 */ 150/* Keyboard::paintEvent {{{1 */
151void Keyboard::paintEvent(QPaintEvent* e) 151void Keyboard::paintEvent(QPaintEvent* e)
152{ 152{
153 QPainter painter(this); 153 QPainter painter(this);
154 painter.setClipRect(e->rect()); 154 painter.setClipRect(e->rect());
155 drawKeyboard( painter ); 155 drawKeyboard( painter );
156 picks->dc->draw( &painter ); 156 picks->dc->draw( &painter );
157} 157}
158 158
159 159
160/* Keyboard::drawKeyboard {{{1 */ 160/* Keyboard::drawKeyboard {{{1 */
161 161
162void Keyboard::drawKeyboard(QPainter &p, int row, int col) 162void Keyboard::drawKeyboard(QPainter &p, int row, int col)
163{ 163{
164 164
165 165
166 if (row != -1 && col != -1) { //just redraw one key 166 if (row != -1 && col != -1) { //just redraw one key
167 167
168 int x = 0; 168 int x = 0;
169 for (int i = 0; i < col; i++) { 169 for (int i = 0; i < col; i++) {
170 170
171 x += keys->width(row, i) * defaultKeyWidth; 171 x += keys->width(row, i) * defaultKeyWidth;
172 } 172 }
173 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); 173 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0);
174 174
175 int keyWidth = keys->width(row, col); 175 int keyWidth = keys->width(row, col);
176 176
177 p.fillRect(x + 1, y + 1, 177 p.fillRect(x + 1, y + 1,
178 keyWidth * defaultKeyWidth - 1, keyHeight - 1, 178 keyWidth * defaultKeyWidth - 1, keyHeight - 1,
179 pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor); 179 pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor);
180 180
181 QImage *pix = keys->pix(row,col); 181 QImage *pix = keys->pix(row,col);
182 182
183 ushort c = keys->uni(row, col); 183 ushort c = keys->uni(row, col);
184 184
185 p.setPen(textcolor); 185 p.setPen(textcolor);
186 if (!pix) { 186 if (!pix) {
187 if ((shift || lock) && keys->shift(c)) 187 if ((shift || lock) && keys->shift(c))
188 188
189 if (circumflex && keys->circumflex(keys->shift(c))) 189 if (circumflex && keys->circumflex(keys->shift(c)))
190 c = keys->circumflex(keys->shift(c)); 190 c = keys->circumflex(keys->shift(c));
191 else if (diaeresis && keys->diaeresis(keys->shift(c))) 191 else if (diaeresis && keys->diaeresis(keys->shift(c)))
192 c = keys->diaeresis(keys->shift(c)); 192 c = keys->diaeresis(keys->shift(c));
193 else if (baccent && keys->baccent(keys->shift(c))) 193 else if (baccent && keys->baccent(keys->shift(c)))
194 c = keys->baccent(keys->shift(c)); 194 c = keys->baccent(keys->shift(c));
195 else if (accent && keys->accent(keys->shift(c))) 195 else if (accent && keys->accent(keys->shift(c)))
196 c = keys->accent(keys->shift(c)); 196 c = keys->accent(keys->shift(c));
197 else if (meta && keys->meta(keys->shift(c))) 197 else if (meta && keys->meta(keys->shift(c)))
198 c = keys->meta(keys->shift(c)); 198 c = keys->meta(keys->shift(c));
199 else 199 else
200 c = keys->shift(c); 200 c = keys->shift(c);
201 201
202 else if (meta && keys->meta(c)) 202 else if (meta && keys->meta(c))
203 c = keys->meta(c); 203 c = keys->meta(c);
204 else if (circumflex && keys->circumflex(c)) 204 else if (circumflex && keys->circumflex(c))
205 c = keys->circumflex(c); 205 c = keys->circumflex(c);
206 else if (baccent && keys->baccent(c)) 206 else if (baccent && keys->baccent(c))
207 c = keys->baccent(c); 207 c = keys->baccent(c);
208 else if (accent && keys->accent(c)) 208 else if (accent && keys->accent(c))
209 c = keys->accent(c); 209 c = keys->accent(c);
210 else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) { 210 else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) {
211 211
212 // the diaeresis key itself has to be in the diaeresisMap, 212 // the diaeresis key itself has to be in the diaeresisMap,
213 // or just do this to make it display the diaeresis char. 213 // or just do this to make it display the diaeresis char.
214 214
215 if (c == 0x2c6) 215 if (c == 0x2c6)
216 c = 0xa8; 216 c = 0xa8;
217 else 217 else
218 c = keys->diaeresis(c); 218 c = keys->diaeresis(c);
219 } 219 }
220 220
221 p.drawText(x, y, 221 p.drawText(x, y,
222 defaultKeyWidth * keyWidth + 3, keyHeight, 222 defaultKeyWidth * keyWidth + 3, keyHeight,
223 AlignCenter, (QChar)c); 223 AlignCenter, (QChar)c);
224 } 224 }
225 else 225 else
226 // center the image in the middle of the key 226 // center the image in the middle of the key
227 p.drawImage( x + (defaultKeyWidth * keyWidth - pix->width())/2 + 1, 227 p.drawImage( x + (defaultKeyWidth * keyWidth - pix->width())/2 + 1,
228 y + (keyHeight - pix->height())/2 + 1, 228 y + (keyHeight - pix->height())/2 + 1,
229 *pix ); 229 *pix );
230 230
231 // this fixes the problem that the very right end of the board's vertical line 231 // this fixes the problem that the very right end of the board's vertical line
232 // gets painted over, because it's one pixel shorter than all other keys 232 // gets painted over, because it's one pixel shorter than all other keys
233 p.setPen(keycolor_lines); 233 p.setPen(keycolor_lines);
234 p.drawLine(width() - 1, 0, width() - 1, height()); 234 p.drawLine(width() - 1, 0, width() - 1, height());
235 235
236 } else { 236 } else {
237 237
238 238
239 p.fillRect(0, 0, width(), height(), keycolor); 239 p.fillRect(0, 0, width(), height(), keycolor);
240 240
241 for (row = 1; row <= keys->rows(); row++) { 241 for (row = 1; row <= keys->rows(); row++) {
242 242
243 int x = 0; 243 int x = 0;
244 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); 244 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0);
245 245
246 p.setPen(keycolor_lines); 246 p.setPen(keycolor_lines);
247 p.drawLine(x, y, x + width(), y); 247 p.drawLine(x, y, x + width(), y);
248 248
249 for (int col = 0; col < keys->numKeys(row); col++) { 249 for (int col = 0; col < keys->numKeys(row); col++) {
250 250
251 QImage *pix = keys->pix(row, col); 251 QImage *pix = keys->pix(row, col);
252 int keyWidth = keys->width(row, col); 252 int keyWidth = keys->width(row, col);
253 253
254 254
255 int keyWidthPix = defaultKeyWidth * keyWidth; 255 int keyWidthPix = defaultKeyWidth * keyWidth;
256 256
257 if (keys->pressed(row, col)) 257 if (keys->pressed(row, col))
258 p.fillRect(x+1, y+1, keyWidthPix - 1, 258 p.fillRect(x+1, y+1, keyWidthPix - 1,
259 keyHeight - 1, keycolor_pressed); 259 keyHeight - 1, keycolor_pressed);
260 260
261 ushort c = keys->uni(row, col); 261 ushort c = keys->uni(row, col);
262 262
263 p.setPen(textcolor); 263 p.setPen(textcolor);
264 if (!pix) { 264 if (!pix) {
265 if ((shift || lock) && keys->shift(c)) 265 if ((shift || lock) && keys->shift(c))
266 266
267 if (circumflex && keys->circumflex(keys->shift(c))) 267 if (circumflex && keys->circumflex(keys->shift(c)))
268 c = keys->circumflex(keys->shift(c)); 268 c = keys->circumflex(keys->shift(c));
269 else if (diaeresis && keys->diaeresis(keys->shift(c))) 269 else if (diaeresis && keys->diaeresis(keys->shift(c)))
270 c = keys->diaeresis(keys->shift(c)); 270 c = keys->diaeresis(keys->shift(c));
271 else if (baccent && keys->baccent(keys->shift(c))) 271 else if (baccent && keys->baccent(keys->shift(c)))
272 c = keys->baccent(keys->shift(c)); 272 c = keys->baccent(keys->shift(c));
273 else if (accent && keys->accent(keys->shift(c))) 273 else if (accent && keys->accent(keys->shift(c)))
274 c = keys->accent(keys->shift(c)); 274 c = keys->accent(keys->shift(c));
275 else if (meta && keys->meta(keys->shift(c))) 275 else if (meta && keys->meta(keys->shift(c)))
276 c = keys->meta(keys->shift(c)); 276 c = keys->meta(keys->shift(c));
277 else 277 else
278 c = keys->shift(c); 278 c = keys->shift(c);
279 279
280 else if (meta && keys->meta(c)) 280 else if (meta && keys->meta(c))
281 c = keys->meta(c); 281 c = keys->meta(c);
282 else if (circumflex && keys->circumflex(c)) 282 else if (circumflex && keys->circumflex(c))
283 c = keys->circumflex(c); 283 c = keys->circumflex(c);
284 else if (baccent && keys->baccent(c)) 284 else if (baccent && keys->baccent(c))
285 c = keys->baccent(c); 285 c = keys->baccent(c);
286 else if (accent && keys->accent(c)) 286 else if (accent && keys->accent(c))
287 c = keys->accent(c); 287 c = keys->accent(c);
288 else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) { 288 else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) {
289 289
290 if (c == 0x2c6) 290 if (c == 0x2c6)
291 c = 0xa8; 291 c = 0xa8;
292 else 292 else
293 c = keys->diaeresis(c); 293 c = keys->diaeresis(c);
294 } 294 }
295 295
296 p.drawText(x, y, 296 p.drawText(x, y,
297 keyWidthPix + 3, keyHeight, 297 keyWidthPix + 3, keyHeight,
298 AlignCenter, (QChar)c); 298 AlignCenter, (QChar)c);
299 } 299 }
300 else { 300 else {
301 // center the image in the middle of the key 301 // center the image in the middle of the key
302 pix->setColor(1, textcolor.rgb()); 302 pix->setColor(1, textcolor.rgb());
303 p.drawImage( x + (keyWidthPix - pix->width())/2 + 1, 303 p.drawImage( x + (keyWidthPix - pix->width())/2 + 1,
304 y + (keyHeight - pix->height())/2 + 1, 304 y + (keyHeight - pix->height())/2 + 1,
305 QImage(*pix) ); 305 QImage(*pix) );
306 } 306 }
307 307
308 p.setPen(keycolor_lines); 308 p.setPen(keycolor_lines);
309 p.drawLine(x, y, x, y + keyHeight); 309 p.drawLine(x, y, x, y + keyHeight);
310 310
311 x += keyWidthPix; 311 x += keyWidthPix;
312 } 312 }
313 313
314 314
315 } 315 }
316 p.setPen(keycolor_lines); 316 p.setPen(keycolor_lines);
317 p.drawLine(0, height() - 1, width(), height() - 1); 317 p.drawLine(0, height() - 1, width(), height() - 1);
318 p.drawLine(width() - 1, 0, width() - 1, height()); 318 p.drawLine(width() - 1, 0, width() - 1, height());
319 } 319 }
320 320
321} 321}
322 322
323 323
324/* Keyboard::mousePressEvent {{{1 */ 324/* Keyboard::mousePressEvent {{{1 */
325void Keyboard::mousePressEvent(QMouseEvent *e) 325void Keyboard::mousePressEvent(QMouseEvent *e)
326{ 326{
327 int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1; 327 int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1;
328 if (row > 5) row = 5; 328 if (row > 5) row = 5;
329 329
330 // figure out the column 330 // figure out the column
331 int col = 0; 331 int col = 0;
332 for (int w = 0; e->x() >= w; col++) 332 for (int w = 0; e->x() >= w; col++)
333 if (col < keys->numKeys(row)) // it segfaults if it trys to read past numKeys 333 if (col < keys->numKeys(row)) // it segfaults if it trys to read past numKeys
334 w += keys->width(row,col) * defaultKeyWidth; 334 w += keys->width(row,col) * defaultKeyWidth;
335 else break; 335 else break;
336 336
337 if (col <= 0) return; 337 if (col <= 0) return;
338 338
339 col --; // rewind one... 339 col --; // rewind one...
340 340
341 qkeycode = keys->qcode(row, col); 341 qkeycode = keys->qcode(row, col);
342 unicode = keys->uni(row, col); 342 unicode = keys->uni(row, col);
343 343
344 // might need to repaint if two or more of the same keys. 344 // might need to repaint if two or more of the same keys.
345 // should be faster if just paint one key even though multiple keys exist. 345 // should be faster if just paint one key even though multiple keys exist.
346 bool need_repaint = FALSE; 346 bool need_repaint = FALSE;
347 347
348 // circumflex and diaeresis support 348 // circumflex and diaeresis support
349 // messy to have this here, but too hard to implement any other method 349 // messy to have this here, but too hard to implement any other method
350 if (unicode == 0x2c6) { 350 if (unicode == 0x2c6) {
351 351
352 unicode = 0; 352 unicode = 0;
353 if (shift || lock) { 353 if (shift || lock) {
354 354
355 // diaeresis 355 // diaeresis
356 qkeycode = 0x2001; 356 qkeycode = 0x2001;
357 } 357 }
358 else { 358 else {
359 359
360 // circumflex 360 // circumflex
361 qkeycode = 0x2000; 361 qkeycode = 0x2000;
362 } 362 }
363 } 363 }
364 364
365 // Back accent character support 365 // Back accent character support
366 366
367 //if (unicode == 0x60) { // the keys from 2c6 ~ 2cf should be used instead of the ascii one 367 // the keys from 2c6 ~ 2cf should be used instead of the ascii one
368 if (unicode == 0x2cb) { 368 if (unicode == 0x2cb) {
369 369
370 unicode = 0; 370 unicode = 0;
371 if (shift || lock) { 371 if (shift || lock) {
372 372
373 // circumblex 373 // circumblex
374 qkeycode = 0x2000; 374 qkeycode = 0x2000;
375 } 375 }
376 else { 376 else {
377 377
378 // back accent 378 // back accent
379 qkeycode = 0x2002; 379 qkeycode = 0x2002;
380 } 380 }
381 } 381 }
382 382
383 // Accent character support 383 // Accent character support
384 384
385 //if (unicode == 0xb4) {
386 if (unicode == 0x2ca) { 385 if (unicode == 0x2ca) {
387 386
388 unicode = 0; 387 unicode = 0;
389 if (shift || lock) { 388 if (shift || lock) {
390 389
391 // diaeresis 390 // diaeresis
392 qkeycode = 0x2001; 391 qkeycode = 0x2001;
393 } 392 }
394 else { 393 else {
395 394
396 // accent 395 // accent
397 qkeycode = 0x2003; 396 qkeycode = 0x2003;
398 } 397 }
399 } 398 }
400 399
401 400
402 if (unicode == 0) { // either Qt char, or nothing 401 if (unicode == 0) { // either Qt char, or nothing
403 402
404 if (qkeycode == Qt::Key_F1) { // toggle the pickboard 403 if (qkeycode == Qt::Key_F1) { // toggle the pickboard
405 404
406 if ( configdlg ) { 405 if ( configdlg ) {
407 406
408 delete (ConfigDlg *) configdlg; 407 delete (ConfigDlg *) configdlg;
409 configdlg = 0; 408 configdlg = 0;
410 } 409 }
411 else { 410 else {
412 configdlg = new ConfigDlg (); 411 configdlg = new ConfigDlg ();
413 connect(configdlg, SIGNAL(setMapToDefault()), 412 connect(configdlg, SIGNAL(setMapToDefault()),
414 this, SLOT(setMapToDefault())); 413 this, SLOT(setMapToDefault()));
415 connect(configdlg, SIGNAL(setMapToFile(QString)), 414 connect(configdlg, SIGNAL(setMapToFile(QString)),
416 this, SLOT(setMapToFile(QString))); 415 this, SLOT(setMapToFile(QString)));
417 connect(configdlg, SIGNAL(pickboardToggled(bool)), 416 connect(configdlg, SIGNAL(pickboardToggled(bool)),
418 this, SLOT(togglePickboard(bool))); 417 this, SLOT(togglePickboard(bool)));
419 connect(configdlg, SIGNAL(repeatToggled(bool)), 418 connect(configdlg, SIGNAL(repeatToggled(bool)),
420 this, SLOT(toggleRepeat(bool))); 419 this, SLOT(toggleRepeat(bool)));
421 connect(configdlg, SIGNAL(reloadKeyboard()), 420 connect(configdlg, SIGNAL(reloadKeyboard()),
422 this, SLOT(reloadKeyboard())); 421 this, SLOT(reloadKeyboard()));
423 connect(configdlg, SIGNAL(configDlgClosed()), 422 connect(configdlg, SIGNAL(configDlgClosed()),
424 this, SLOT(cleanupConfigDlg())); 423 this, SLOT(cleanupConfigDlg()));
425 configdlg->showMaximized(); 424 configdlg->showMaximized();
426 configdlg->show(); 425 configdlg->show();
427 configdlg->raise(); 426 configdlg->raise();
428 } 427 }
429 428
430 } else if (qkeycode == Qt::Key_Control) { 429 } else if (qkeycode == Qt::Key_Control) {
431 need_repaint = TRUE; 430 need_repaint = TRUE;
432 431
433 if (ctrl) { 432 if (ctrl) {
434 433
435 *ctrl = 0; 434 *ctrl = 0;
436 ctrl = 0; 435 ctrl = 0;
437 436
438 } else { 437 } else {
439 438
440 ctrl = keys->pressedPtr(row, col); 439 ctrl = keys->pressedPtr(row, col);
441 need_repaint = TRUE; 440 need_repaint = TRUE;
442 *ctrl = !keys->pressed(row, col); 441 *ctrl = !keys->pressed(row, col);
443 442
444 } 443 }
445 444
446 } else if (qkeycode == Qt::Key_Alt) { 445 } else if (qkeycode == Qt::Key_Alt) {
447 need_repaint = TRUE; 446 need_repaint = TRUE;
448 447
449 if (alt) { 448 if (alt) {
450 *alt = 0; 449 *alt = 0;
451 alt = 0; 450 alt = 0;
452 451
453 } else { 452 } else {
454 453
455 alt = keys->pressedPtr(row, col); 454 alt = keys->pressedPtr(row, col);
456 need_repaint = TRUE; 455 need_repaint = TRUE;
457 *alt = !keys->pressed(row, col); 456 *alt = !keys->pressed(row, col);
458 } 457 }
459 458
460 } else if (qkeycode == Qt::Key_Shift) { 459 } else if (qkeycode == Qt::Key_Shift) {
461 need_repaint = TRUE; 460 need_repaint = TRUE;
462 461
463 if (shift) { 462 if (shift) {
464 *shift = 0; 463 *shift = 0;
465 shift = 0; 464 shift = 0;
466 } 465 }
467 else { 466 else {
468 shift = keys->pressedPtr(row, col); 467 shift = keys->pressedPtr(row, col);
469 *shift = 1; 468 *shift = 1;
470 if (lock) { 469 if (lock) {
471 *lock = 0; 470 *lock = 0;
472 lock = 0; 471 lock = 0;
473 } 472 }
474 } 473 }
475 474
476 475
477 /* 476 /*
478 * want to be able to hit circumflex/diaeresis -> shift 477 * want to be able to hit circumflex/diaeresis -> shift
479 * to type in shifted circumflex/diaeresis chars. 478 * to type in shifted circumflex/diaeresis chars.
480 * same thing with meta 479 * same thing with meta
481 480
482 if (meta) { *meta = 0; meta = 0; } 481 if (meta) { *meta = 0; meta = 0; }
483 if (circumflex) { *circumflex = 0; circumflex = 0; } 482 if (circumflex) { *circumflex = 0; circumflex = 0; }
484 if (diaeresis) { *diaeresis = 0; diaeresis = 0; } 483 if (diaeresis) { *diaeresis = 0; diaeresis = 0; }
485 484
486 */ 485 */
487 486
488 } else if (qkeycode == Qt::Key_CapsLock) { 487 } else if (qkeycode == Qt::Key_CapsLock) {
489 need_repaint = TRUE; 488 need_repaint = TRUE;
490 489
491 if (lock) { 490 if (lock) {
492 *lock = 0; 491 *lock = 0;
493 lock = 0; 492 lock = 0;
494 } 493 }
495 else { 494 else {
496 lock = keys->pressedPtr(row, col);; 495 lock = keys->pressedPtr(row, col);;
497 *lock = true;; 496 *lock = true;;
498 if (shift) { 497 if (shift) {
499 *shift = 0; 498 *shift = 0;
500 shift = 0; 499 shift = 0;
501 } 500 }
502 } 501 }
503 502
504 /* 503 /*
505 if (meta) { *meta = 0; meta = 0; } 504 if (meta) { *meta = 0; meta = 0; }
506 if (circumflex) { *circumflex = 0; circumflex = 0; } 505 if (circumflex) { *circumflex = 0; circumflex = 0; }
507 if (diaeresis) { *diaeresis = 0; diaeresis = 0; } 506 if (diaeresis) { *diaeresis = 0; diaeresis = 0; }
508 */ 507 */
509 508
510 } else if (qkeycode == Qt::Key_Meta) { 509 } else if (qkeycode == Qt::Key_Meta) {
511 need_repaint = TRUE; 510 need_repaint = TRUE;
512 511
513 if (meta) { 512 if (meta) {
514 *meta = 0; 513 *meta = 0;
515 meta = 0; 514 meta = 0;
516 515
517 } else { 516 } else {
518 517
519 meta = keys->pressedPtr(row, col); 518 meta = keys->pressedPtr(row, col);
520 *meta = true; 519 *meta = true;
521 } 520 }
522 521
523 // reset all the other keys 522 // reset all the other keys
524 if (shift) { *shift = 0; shift = 0; } 523 if (shift) { *shift = 0; shift = 0; }
525 if (lock) { *lock = 0; lock = 0; } 524 if (lock) { *lock = 0; lock = 0; }
526 if (circumflex) { *circumflex = 0; circumflex = 0; } 525 if (circumflex) { *circumflex = 0; circumflex = 0; }
527 if (diaeresis) { *diaeresis = 0; diaeresis = 0; } 526 if (diaeresis) { *diaeresis = 0; diaeresis = 0; }
528 if (baccent) { *baccent = 0; baccent = 0; } 527 if (baccent) { *baccent = 0; baccent = 0; }
529 if (accent) { *accent = 0; accent = 0; } 528 if (accent) { *accent = 0; accent = 0; }
530 529
531 // dont need to emit this key... acts same as alt 530 // dont need to emit this key... acts same as alt
532 qkeycode = 0; 531 qkeycode = 0;
533 532
534 // circumflex 533 // circumflex
535 } else if (qkeycode == 0x2000) { 534 } else if (qkeycode == 0x2000) {
536 need_repaint = TRUE; 535 need_repaint = TRUE;
537 536
538 if (circumflex) { 537 if (circumflex) {
539 538
540 *circumflex = 0; 539 *circumflex = 0;
541 circumflex = 0; 540 circumflex = 0;
542 541
543 } else { 542 } else {
544 543
545 circumflex = keys->pressedPtr(row, col); 544 circumflex = keys->pressedPtr(row, col);
546 *circumflex = true; 545 *circumflex = true;
547 } 546 }
548 547
549 /* no need to turn off shift or lock if circumflex 548 /* no need to turn off shift or lock if circumflex
550 * keys are pressed 549 * keys are pressed
551 550
552 if (shift) { *shift = 0; shift = 0; } 551 if (shift) { *shift = 0; shift = 0; }
553 if (lock) { *lock = 0; lock = 0; } 552 if (lock) { *lock = 0; lock = 0; }
554 553
555 */ 554 */
556 555
557 // have to reset all the other keys 556 // have to reset all the other keys
558 if (meta) { *meta = 0; meta = 0; } 557 if (meta) { *meta = 0; meta = 0; }
559 if (diaeresis) { 558 if (diaeresis) {
560 559
561 // *diaeresis and *circumflex point to the same thing 560 // *diaeresis and *circumflex point to the same thing
562 // when diaeresis is enabled and you hit the circumflex 561 // when diaeresis is enabled and you hit the circumflex
563 // since they are the same key, it should turn off the 562 // since they are the same key, it should turn off the
564 // key 563 // key
565 564
566 *diaeresis = 0; 565 *diaeresis = 0;
567 diaeresis = 0; 566 diaeresis = 0;
568 circumflex = 0; 567 circumflex = 0;
569 } 568 }
570 569
571 qkeycode = 0; 570 qkeycode = 0;
572 571
573 // diaeresis 572 // diaeresis
574 } else if (qkeycode == 0x2001) { 573 } else if (qkeycode == 0x2001) {
575 need_repaint = TRUE; 574 need_repaint = TRUE;
576 575
577 if (diaeresis) { 576 if (diaeresis) {
578 577
579 *diaeresis = 0; 578 *diaeresis = 0;
580 diaeresis = 0; 579 diaeresis = 0;
581 580
582 } else { 581 } else {
583 582
584 diaeresis = keys->pressedPtr(row, col); 583 diaeresis = keys->pressedPtr(row, col);
585 *diaeresis = true; 584 *diaeresis = true;
586 } 585 }
587 586
588 587
589 if (shift) { *shift = 0; shift = 0; } 588 if (shift) { *shift = 0; shift = 0; }
590 589
591 /* 590 /*
592 * 591 *
593 if (lock) { *lock = 0; lock = 0; } 592 if (lock) { *lock = 0; lock = 0; }
594 * 593 *
595 */ 594 */
596 595
597 if (meta) { *meta = 0; meta = 0; } 596 if (meta) { *meta = 0; meta = 0; }
598 if (circumflex) { 597 if (circumflex) {
599 598
600 // *circumflex = 0; 599 // *circumflex = 0;
601 // 600 //
602 // same thing the diaeresis pointer points too 601 // same thing the diaeresis pointer points too
603 602
604 circumflex = 0; 603 circumflex = 0;
605 } 604 }
606 605
607 606
608 qkeycode = 0; 607 qkeycode = 0;
609 608
610 // Back accent 609 // Back accent
611 } else if (qkeycode == 0x2002) { 610 } else if (qkeycode == 0x2002) {
612 need_repaint = TRUE; 611 need_repaint = TRUE;
613 612
614 if (baccent) { 613 if (baccent) {
615 614
616 *baccent = 0; 615 *baccent = 0;
617 baccent = 0; 616 baccent = 0;
618 617
619 } else { 618 } else {
620 619
621 baccent = keys->pressedPtr(row, col); 620 baccent = keys->pressedPtr(row, col);
622 *baccent = true; 621 *baccent = true;
623 } 622 }
624 623
625 624
626 if (shift) { *shift = 0; shift = 0; } 625 if (shift) { *shift = 0; shift = 0; }
627 if (meta) { *meta = 0; meta = 0; } 626 if (meta) { *meta = 0; meta = 0; }
628 if (accent) { *accent = 0; accent = 0; } 627 if (accent) { *accent = 0; accent = 0; }
629 628
630 qkeycode = 0; 629 qkeycode = 0;
631 630
632 // Accent 631 // Accent
633 } else if (qkeycode == 0x2003) { 632 } else if (qkeycode == 0x2003) {
634 need_repaint = TRUE; 633 need_repaint = TRUE;
635 634
636 if (accent) { 635 if (accent) {
637 636
638 *accent = 0; 637 *accent = 0;
639 accent = 0; 638 accent = 0;
640 639
641 } else { 640 } else {
642 641
643 accent = keys->pressedPtr(row, col); 642 accent = keys->pressedPtr(row, col);
644 *accent = true; 643 *accent = true;
645 } 644 }
646 645
647 646
648 if (shift) { *shift = 0; shift = 0; } 647 if (shift) { *shift = 0; shift = 0; }
649 if (meta) { *meta = 0; meta = 0; } 648 if (meta) { *meta = 0; meta = 0; }
650 if (baccent) { *baccent = 0; } 649 if (baccent) { *baccent = 0; }
651 650
652 qkeycode = 0; 651 qkeycode = 0;
653 } 652 }
654 653
655 } 654 }
656 else { // normal char 655 else { // normal char
657 if ((shift || lock) && keys->shift(unicode)) { 656 if ((shift || lock) && keys->shift(unicode)) {
658 657
659 // make diaeresis/circumflex -> shift input shifted 658 // make diaeresis/circumflex -> shift input shifted
660 // diaeresis/circumflex chars 659 // diaeresis/circumflex chars
661 660
662 if (circumflex && keys->circumflex(keys->shift(unicode))) 661 if (circumflex && keys->circumflex(keys->shift(unicode)))
663 unicode = keys->circumflex(keys->shift(unicode)); 662 unicode = keys->circumflex(keys->shift(unicode));
664 else if (diaeresis && keys->diaeresis(keys->shift(unicode))) 663 else if (diaeresis && keys->diaeresis(keys->shift(unicode)))
665 unicode = keys->diaeresis(keys->shift(unicode)); 664 unicode = keys->diaeresis(keys->shift(unicode));
666 else if (baccent && keys->baccent(keys->shift(unicode))) 665 else if (baccent && keys->baccent(keys->shift(unicode)))
667 unicode = keys->baccent(keys->shift(unicode)); 666 unicode = keys->baccent(keys->shift(unicode));
668 else if (accent && keys->accent(keys->shift(unicode))) 667 else if (accent && keys->accent(keys->shift(unicode)))
669 unicode = keys->accent(keys->shift(unicode)); 668 unicode = keys->accent(keys->shift(unicode));
670 else if (meta && keys->meta(keys->shift(unicode))) 669 else if (meta && keys->meta(keys->shift(unicode)))
671 unicode = keys->meta(keys->shift(unicode)); 670 unicode = keys->meta(keys->shift(unicode));
672 else 671 else
673 unicode = keys->shift(unicode); 672 unicode = keys->shift(unicode);
674 } 673 }
675 else if (meta && keys->meta(unicode)) { 674 else if (meta && keys->meta(unicode)) {
676 unicode = keys->meta(unicode); 675 unicode = keys->meta(unicode);
677 } 676 }
678 else if (circumflex && keys->circumflex(unicode)) { 677 else if (circumflex && keys->circumflex(unicode)) {
679 unicode = keys->circumflex(unicode); 678 unicode = keys->circumflex(unicode);
680 } 679 }
681 else if (diaeresis && keys->diaeresis(unicode)) { 680 else if (diaeresis && keys->diaeresis(unicode)) {
682 681
683 unicode = keys->diaeresis(unicode); 682 unicode = keys->diaeresis(unicode);
684 } 683 }
685 else if (baccent && keys->baccent(unicode)) { 684 else if (baccent && keys->baccent(unicode)) {
686 unicode = keys->baccent(unicode); 685 unicode = keys->baccent(unicode);
687 } 686 }
688 else if (accent && keys->accent(unicode)) { 687 else if (accent && keys->accent(unicode)) {
689 unicode = keys->accent(unicode); 688 unicode = keys->accent(unicode);
690 } 689 }
691 } 690 }
692 691
693 // korean parsing 692 // korean parsing
694 if (keys->lang == "ko") { 693 if (keys->lang == "ko") {
695 694
696 unicode = parseKoreanInput(unicode); 695 unicode = parseKoreanInput(unicode);
697 } 696 }
698 697
699 modifiers = (ctrl ? Qt::ControlButton : 0) | (alt ? Qt::AltButton : 0); 698 modifiers = (ctrl ? Qt::ControlButton : 0) | (alt ? Qt::AltButton : 0);
700 699
701 if ('A' <= unicode && unicode <= 'z' && modifiers) { 700 if ('A' <= unicode && unicode <= 'z' && modifiers) {
702 701
703 qkeycode = QChar(unicode).upper(); 702 qkeycode = QChar(unicode).upper();
704 unicode = qkeycode - '@'; 703 unicode = qkeycode - '@';
705 } 704 }
706 705
707 QWSServer::sendKeyEvent(unicode, qkeycode, modifiers, true, false); 706 QWSServer::sendKeyEvent(unicode, qkeycode, modifiers, true, false);
708 707
709 // pickboard stuff 708 // pickboard stuff
710 if (usePicks) { 709 if (usePicks) {
711 710
712 KeyboardConfig *dc = picks->dc; 711 KeyboardConfig *dc = picks->dc;
713 712
714 if (dc) { 713 if (dc) {
715 if (qkeycode == Qt::Key_Backspace) { 714 if (qkeycode == Qt::Key_Backspace) {
716 dc->input.remove(dc->input.last()); // remove last input 715 dc->input.remove(dc->input.last()); // remove last input
717 dc->decBackspaces(); 716 dc->decBackspaces();
718 } else if ( qkeycode == Qt::Key_Return || QChar(unicode).isPunct() || QChar(unicode).isSpace() || unicode == 0) { 717 } else if ( qkeycode == Qt::Key_Return || QChar(unicode).isPunct() || QChar(unicode).isSpace() || unicode == 0) {
719 dc->input.clear(); 718 dc->input.clear();
720 dc->resetBackspaces(); 719 dc->resetBackspaces();
721 } else { 720 } else {
722 dc->add(QString(QChar(unicode))); 721 dc->add(QString(QChar(unicode)));
723 dc->incBackspaces(); 722 dc->incBackspaces();
724 } 723 }
725 } 724 }
726 picks->repaint(); 725 picks->repaint();
727 } 726 }
728 727
729 728
730 // painting 729 // painting
731 pressed = TRUE; 730 pressed = TRUE;
732 731
733 pressedKeyRow = row; 732 pressedKeyRow = row;
734 pressedKeyCol = col; 733 pressedKeyCol = col;
735 734
736 if (need_repaint) repaint(FALSE); 735 if (need_repaint) repaint(FALSE);
737 else { // just paint the one key pressed 736 else { // just paint the one key pressed
738 737
739 738
740 739
741 QPainter p(this); 740 QPainter p(this);
742 drawKeyboard(p, row, col); 741 drawKeyboard(p, row, col);
743 742
744 } 743 }
745 744
746 if (useRepeat) repeatTimer->start( 800 ); 745 if (useRepeat) repeatTimer->start( 800 );
747 //pressTid = startTimer(80); 746 //pressTid = startTimer(80);
748 747
749} 748}
750 749
751 750
752/* Keyboard::mouseReleaseEvent {{{1 */ 751/* Keyboard::mouseReleaseEvent {{{1 */
753void Keyboard::mouseReleaseEvent(QMouseEvent*) 752void Keyboard::mouseReleaseEvent(QMouseEvent*)
754{ 753{
755 pressed = FALSE; 754 pressed = FALSE;
756 //if ( pressTid == 0 ) 755 //if ( pressTid == 0 )
757#if defined(Q_WS_QWS) || defined(_WS_QWS_) 756#if defined(Q_WS_QWS) || defined(_WS_QWS_)
758 if ( unicode != -1 ) { 757 if ( unicode != -1 ) {
759 emit key( unicode, qkeycode, modifiers, false, false ); 758 emit key( unicode, qkeycode, modifiers, false, false );
760 repeatTimer->stop(); 759 repeatTimer->stop();
761 } 760 }
762#endif 761#endif
763 if (shift && unicode != 0) { 762 if (shift && unicode != 0) {
764 763
765 764
766 *shift = 0; // unpress shift key 765 *shift = 0; // unpress shift key
767 shift = 0; // reset the shift pointer 766 shift = 0; // reset the shift pointer
768 repaint(FALSE); 767 repaint(FALSE);
769 768
770 } 769 }
771 if (ctrl && unicode != 0) { 770 if (ctrl && unicode != 0) {
772 771
773 *ctrl = 0; 772 *ctrl = 0;
774 ctrl = 0; 773 ctrl = 0;
775 repaint(FALSE); 774 repaint(FALSE);
776 775
777 } 776 }
777 if (alt && alt != 0) {
778
779 *alt = 0;
780 alt = 0;
781 repaint(FALSE);
782
783 }
778 784
779 /* 785 /*
780 * do not make the meta key release after being pressed 786 * do not make the meta key release after being pressed
781 * 787 *
782 788
783 else if (meta && unicode != 0) { 789 else if (meta && unicode != 0) {
784 790
785 *meta = 0; 791 *meta = 0;
786 meta = 0; 792 meta = 0;
787 repaint(FALSE); 793 repaint(FALSE);
788 } 794 }
789 795
790 */ 796 */
791 797
792 else clearHighlight(); 798 else clearHighlight();
793} 799}
794 800
795/* Keyboard::timerEvent {{{1 */ 801/* Keyboard::timerEvent {{{1 */
796 802
797/* dont know what this does, but i think it is here so that if your screen 803/* dont know what this does, but i think it is here so that if your screen
798 * sticks (like on an ipaq) then it will stop repeating if you click another 804 * sticks (like on an ipaq) then it will stop repeating if you click another
799 * key... but who knows what anything does in this thing anyway? 805 * key... but who knows what anything does in this thing anyway?
800 806
801 void Keyboard::timerEvent(QTimerEvent* e) 807 void Keyboard::timerEvent(QTimerEvent* e)
802{ 808{
803 if ( e->timerId() == pressTid ) { 809 if ( e->timerId() == pressTid ) {
804 killTimer(pressTid); 810 killTimer(pressTid);
805 pressTid = 0; 811 pressTid = 0;
806 if ( !pressed ) 812 if ( !pressed )
807 cout << "calling clearHighlight from timerEvent\n"; 813 cout << "calling clearHighlight from timerEvent\n";
808 //clearHighlight(); 814 //clearHighlight();
809 } 815 }
810} 816}
811*/ 817*/
812 818
813void Keyboard::repeat() 819void Keyboard::repeat()
814{ 820{
815 821
816 repeatTimer->start( 200 ); 822 repeatTimer->start( 200 );
817 emit key( unicode, qkeycode, modifiers, true, true ); 823 emit key( unicode, qkeycode, modifiers, true, true );
818} 824}
819 825
820void Keyboard::clearHighlight() 826void Keyboard::clearHighlight()
821{ 827{
822 if ( pressedKeyRow >= 0 && pressedKeyCol >= 0) { 828 if ( pressedKeyRow >= 0 && pressedKeyCol >= 0) {
823 int tmpRow = pressedKeyRow; 829 int tmpRow = pressedKeyRow;
824 int tmpCol = pressedKeyCol; 830 int tmpCol = pressedKeyCol;
825 831
826 pressedKeyRow = -1; 832 pressedKeyRow = -1;
827 pressedKeyCol = -1; 833 pressedKeyCol = -1;
828 834
829 QPainter p(this); 835 QPainter p(this);
830 drawKeyboard(p, tmpRow, tmpCol); 836 drawKeyboard(p, tmpRow, tmpCol);
831 } 837 }
832} 838}
833 839
834 840
835/* Keyboard::sizeHint {{{1 */ 841/* Keyboard::sizeHint {{{1 */
836QSize Keyboard::sizeHint() const 842QSize Keyboard::sizeHint() const
837{ 843{
838 QFontMetrics fm=fontMetrics(); 844 QFontMetrics fm=fontMetrics();
839 int keyHeight = fm.lineSpacing() + 2; 845 int keyHeight = fm.lineSpacing() + 2;
840 846
841 return QSize( 240, keyHeight * keys->rows() + (usePicks ? picks->sizeHint().height() : 0) + 1); 847 return QSize( 240, keyHeight * keys->rows() + (usePicks ? picks->sizeHint().height() : 0) + 1);
842} 848}
843 849
844 850
845void Keyboard::resetState() 851void Keyboard::resetState()
846{ 852{
847 if (shift) { *shift = 0; shift = 0; } 853 if (shift) { *shift = 0; shift = 0; }
848 if (lock) {*lock = 0; lock = 0; } 854 if (lock) {*lock = 0; lock = 0; }
849 if (meta) { *meta = 0; meta = 0; } 855 if (meta) { *meta = 0; meta = 0; }
850 if (circumflex) { *circumflex = 0; circumflex = 0; } 856 if (circumflex) { *circumflex = 0; circumflex = 0; }
851 if (diaeresis) { *diaeresis = 0; diaeresis = 0; } 857 if (diaeresis) { *diaeresis = 0; diaeresis = 0; }
852 if (baccent) { *baccent = 0; baccent = 0; } 858 if (baccent) { *baccent = 0; baccent = 0; }
853 if (accent) { *accent = 0; accent = 0; } 859 if (accent) { *accent = 0; accent = 0; }
854 860
855 schar = mchar = echar = 0; 861 schar = mchar = echar = 0;
856 picks->resetState(); 862 picks->resetState();
857} 863}
858 864
859/* Keyboard::togglePickboard {{{1 */ 865/* Keyboard::togglePickboard {{{1 */
860void Keyboard::togglePickboard(bool on_off) 866void Keyboard::togglePickboard(bool on_off)
861{ 867{
862 usePicks = on_off; 868 usePicks = on_off;
863 if (usePicks) { 869 if (usePicks) {
864 picks->show(); 870 picks->show();
865 //move(x(), y() - picks->height()); // not required anymore because QCopChannel::send 871 //move(x(), y() - picks->height()); // not required anymore because QCopChannel::send
866 //adjustSize(); 872 //adjustSize();
867 QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), 873 QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ),
868 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); 874 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) );
869 } else { 875 } else {
870 876
871 picks->hide(); 877 picks->hide();
872 picks->resetState(); 878 picks->resetState();
873 //move(x(), y() + picks->height()); 879 //move(x(), y() + picks->height());
874 //adjustSize(); 880 //adjustSize();
875 QObject::disconnect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), 881 QObject::disconnect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ),
876 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); 882 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) );
877 883
878 } 884 }
879 /* 885 /*
880 * this closes && opens the input method 886 * this closes && opens the input method
881 */ 887 */
882 QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); 888 QCopChannel::send ("QPE/TaskBar", "hideInputMethod()");
883 QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); 889 QCopChannel::send ("QPE/TaskBar", "showInputMethod()");
884} 890}
885 891
886void Keyboard::toggleRepeat(bool on) { 892void Keyboard::toggleRepeat(bool on) {
887 893
888 useRepeat = on; 894 useRepeat = on;
889 //cout << "setting useRepeat to: " << useRepeat << "\n"; 895 //cout << "setting useRepeat to: " << useRepeat << "\n";
890} 896}
891 897
892void Keyboard::cleanupConfigDlg() { 898void Keyboard::cleanupConfigDlg() {
893 899
894 if ( configdlg ) { 900 if ( configdlg ) {
895 delete (ConfigDlg *) configdlg; 901 delete (ConfigDlg *) configdlg;
896 configdlg = 0; 902 configdlg = 0;
897 } 903 }
898} 904}
899 905
900/* Keyboard::setMapTo ... {{{1 */ 906/* Keyboard::setMapTo ... {{{1 */
901void Keyboard::setMapToDefault() { 907void Keyboard::setMapToDefault() {
902 908
903 909
904 /* load current locale language map */ 910 /* load current locale language map */
905 Config *config = new Config("locale"); 911 Config *config = new Config("locale");
906 config->setGroup( "Language" ); 912 config->setGroup( "Language" );
907 QString l = config->readEntry( "Language" , "en" ); 913 QString l = config->readEntry( "Language" , "en" );
908 delete config; 914 delete config;
909 915
910 QString key_map = QPEApplication::qpeDir() + "share/multikey/" 916 QString key_map = QPEApplication::qpeDir() + "share/multikey/"
911 + l + ".keymap"; 917 + l + ".keymap";
912 918
913 /* save change to multikey config file */ 919 /* save change to multikey config file */
914 config = new Config("multikey"); 920 config = new Config("multikey");
915 config->setGroup ("keymaps"); 921 config->setGroup ("keymaps");
916 config->writeEntry ("current", key_map); // default closed 922 config->writeEntry ("current", key_map); // default closed
917 delete config; 923 delete config;
918 924
919 int prevRows = keys->rows(); 925 int prevRows = keys->rows();
920 926
921 delete keys; 927 delete keys;
922 keys = new Keys(key_map); 928 keys = new Keys(key_map);
923 929
924 // have to repaint the keyboard 930 // have to repaint the keyboard
925 if (prevRows != keys->rows()) { 931 if (prevRows != keys->rows()) {
926 932
927 QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); 933 QCopChannel::send ("QPE/TaskBar", "hideInputMethod()");
928 QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); 934 QCopChannel::send ("QPE/TaskBar", "showInputMethod()");
929 935
930 } else repaint(FALSE); 936 } else repaint(FALSE);
931 937
932 resetState(); 938 resetState();
933} 939}
934 940
935void Keyboard::setMapToFile(QString map) { 941void Keyboard::setMapToFile(QString map) {
936 942
937 /* save change to multikey config file */ 943 /* save change to multikey config file */
938 Config *config = new Config("multikey"); 944 Config *config = new Config("multikey");
939 config->setGroup ("keymaps"); 945 config->setGroup ("keymaps");
940 config->writeEntry ("current", map); // default closed 946 config->writeEntry ("current", map); // default closed
941 947
942 delete config; 948 delete config;
943 949
944 int prevRows = keys->rows(); 950 int prevRows = keys->rows();
945 951
946 delete keys; 952 delete keys;
947 if (QFile(map).exists()) 953 if (QFile(map).exists())
948 keys = new Keys(map); 954 keys = new Keys(map);
949 else 955 else
950 keys = new Keys(); 956 keys = new Keys();
951 957
952 if (keys->rows() != prevRows) { 958 if (keys->rows() != prevRows) {
953 959
954 QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); 960 QCopChannel::send ("QPE/TaskBar", "hideInputMethod()");
955 QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); 961 QCopChannel::send ("QPE/TaskBar", "showInputMethod()");
956 } 962 }
957 else repaint(FALSE); 963 else repaint(FALSE);
958 964
959 resetState(); 965 resetState();
960} 966}
961 967
962/* Keybaord::reloadKeyboard {{{1 */ 968/* Keybaord::reloadKeyboard {{{1 */
963void Keyboard::reloadKeyboard() { 969void Keyboard::reloadKeyboard() {
964 970
965 // reload colors and redraw 971 // reload colors and redraw
966 loadKeyboardColors(); 972 loadKeyboardColors();
967 repaint(); 973 repaint();
968 974
969} 975}
970 976
971void Keyboard::loadKeyboardColors() { 977void Keyboard::loadKeyboardColors() {
972 978
973 Config config ("multikey"); 979 Config config ("multikey");
974 config.setGroup("colors"); 980 config.setGroup("colors");
975 981
976 QStringList color; 982 QStringList color;
977 color = config.readListEntry("keycolor", QChar(',')); 983 color = config.readListEntry("keycolor", QChar(','));
978 if (color.isEmpty()) { 984 if (color.isEmpty()) {
979 color = QStringList::split(",", "240,240,240"); 985 color = QStringList::split(",", "240,240,240");
980 config.writeEntry("keycolor", color.join(",")); 986 config.writeEntry("keycolor", color.join(","));
981 987
982 } 988 }
983 keycolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); 989 keycolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt());
984 990
985 color = config.readListEntry("keycolor_pressed", QChar(',')); 991 color = config.readListEntry("keycolor_pressed", QChar(','));
986 if (color.isEmpty()) { 992 if (color.isEmpty()) {
987 color = QStringList::split(",", "171,183,198"); 993 color = QStringList::split(",", "171,183,198");
988 config.writeEntry("keycolor_pressed", color.join(",")); 994 config.writeEntry("keycolor_pressed", color.join(","));
989 995
990 } 996 }
991 keycolor_pressed = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); 997 keycolor_pressed = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt());
992 998
993 color = config.readListEntry("keycolor_lines", QChar(',')); 999 color = config.readListEntry("keycolor_lines", QChar(','));
994 if (color.isEmpty()) { 1000 if (color.isEmpty()) {
995 color = QStringList::split(",", "138,148,160"); 1001 color = QStringList::split(",", "138,148,160");
996 config.writeEntry("keycolor_lines", color.join(",")); 1002 config.writeEntry("keycolor_lines", color.join(","));
997 1003
998 } 1004 }
999 keycolor_lines = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); 1005 keycolor_lines = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt());
1000 1006
1001 color = config.readListEntry("textcolor", QChar(',')); 1007 color = config.readListEntry("textcolor", QChar(','));
1002 if (color.isEmpty()) { 1008 if (color.isEmpty()) {
1003 color = QStringList::split(",", "43,54,68"); 1009 color = QStringList::split(",", "43,54,68");
1004 config.writeEntry("textcolor", color.join(",")); 1010 config.writeEntry("textcolor", color.join(","));
1005 1011
1006 } 1012 }
1007 textcolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); 1013 textcolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt());
1008 1014
1009} 1015}
1010 1016
1011/* korean input functions {{{1 1017/* korean input functions {{{1
1012 * 1018 *
1013 * TODO 1019 * TODO
1014 * one major problem with this implementation is that you can't move the 1020 * one major problem with this implementation is that you can't move the
1015 * cursor after inputing korean chars, otherwise it will eat up and replace 1021 * cursor after inputing korean chars, otherwise it will eat up and replace
1016 * the char before the cursor you move to. fix that 1022 * the char before the cursor you move to. fix that
1017 * 1023 *
1018 * make backspace delete one single char, not the whole thing if still 1024 * make backspace delete one single char, not the whole thing if still
1019 * editing. 1025 * editing.
1020 * 1026 *
1021 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 1027 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
1022 * 1028 *
1023 * how korean input works 1029 * how korean input works
1024 * 1030 *
1025 * all following chars means unicode char value and are in hex 1031 * all following chars means unicode char value and are in hex
1026 * 1032 *
1027 * 초음 = schar (start char) 1033 * 초음 = schar (start char)
1028 * 중음 = mchar (middle char) 1034 * 중음 = mchar (middle char)
1029 * 끝음 = echar (end char) 1035 * 끝음 = echar (end char)
1030 * 1036 *
1031 * there are 19 schars. unicode position is at 1100 - 1112 1037 * there are 19 schars. unicode position is at 1100 - 1112
1032 * there are 21 mchars. unicode position is at 1161 - 1175 1038 * there are 21 mchars. unicode position is at 1161 - 1175
1033 * there are 27 echars. unicode position is at 11a8 - 11c2 1039 * there are 27 echars. unicode position is at 11a8 - 11c2
1034 * 1040 *
1035 * the map with everything combined is at ac00 - d7a3 1041 * the map with everything combined is at ac00 - d7a3
1036 * 1042 *
1037 */ 1043 */
1038 1044
1039ushort Keyboard::parseKoreanInput (ushort c) { 1045ushort Keyboard::parseKoreanInput (ushort c) {
1040 1046
1041 if ((c != 0 && (c < 0x1100 || 0x11c2 < c) && (c < 0xac00 || 0xd7a3 < c)) 1047 if ((c != 0 && (c < 0x1100 || 0x11c2 < c) && (c < 0xac00 || 0xd7a3 < c))
1042 || 1048 ||
1043 (c == 0 && qkeycode != Qt::Key_Shift && Qt::Key_CapsLock != qkeycode 1049 (c == 0 && qkeycode != Qt::Key_Shift && Qt::Key_CapsLock != qkeycode
1044 && qkeycode != Qt::Key_Control && qkeycode != Qt::Key_Alt)) { 1050 && qkeycode != Qt::Key_Control && qkeycode != Qt::Key_Alt)) {
1045 1051
1046 schar = 0, mchar = 0, echar = 0; 1052 schar = 0, mchar = 0, echar = 0;
1047 return c; 1053 return c;
1048 } 1054 }
1049 1055
1050 if ( 0x1100 <= c && c <= 0x1112 ) { // schar or echar was input 1056 if ( 0x1100 <= c && c <= 0x1112 ) { // schar or echar was input
1051 1057
1052 if (schar == 0 || (schar != 0 && mchar == 0)) { 1058 if (schar == 0 || (schar != 0 && mchar == 0)) {
1053 schar = c; mchar = 0; echar = 0; 1059 schar = c; mchar = 0; echar = 0;
1054 return c; 1060 return c;
1055 } 1061 }
1056 else if (mchar != 0) { 1062 else if (mchar != 0) {
1057 1063
1058 if (echar == 0) { 1064 if (echar == 0) {
1059 1065
1060 if (!(echar = constoe(c))) { 1066 if (!(echar = constoe(c))) {
1061 1067
1062 schar = c; mchar = 0; echar = 0; 1068 schar = c; mchar = 0; echar = 0;
1063 return c; 1069 return c;
1064 } 1070 }
1065 1071
1066 } 1072 }
1067 else { // must figure out what the echar is 1073 else { // must figure out what the echar is
1068 1074
1069 if (echar == 0x11a8) { // ㄱ 1075 if (echar == 0x11a8) { // ㄱ
1070 1076
1071 if (c == 0x1100) echar = 0x11a9; // ㄱ + ㄱ 1077 if (c == 0x1100) echar = 0x11a9; // ㄱ + ㄱ
1072 else if (c == 0x1109) echar = 0x11aa; // ㄱ + ㅅ 1078 else if (c == 0x1109) echar = 0x11aa; // ㄱ + ㅅ
1073 else { 1079 else {
1074 schar = c; mchar = 0; echar = 0; 1080 schar = c; mchar = 0; echar = 0;
1075 return c; 1081 return c;
1076 } 1082 }
1077 1083
1078 } else if (echar == 0x11ab) { // ㄴ 1084 } else if (echar == 0x11ab) { // ㄴ
1079 1085
1080 if (c == 0x110c) echar = 0x11ac; // ㄴ + ㅈ 1086 if (c == 0x110c) echar = 0x11ac; // ㄴ + ㅈ
1081 else if (c == 0x1112) echar = 0x11ad; // ㄴ + ㅎ 1087 else if (c == 0x1112) echar = 0x11ad; // ㄴ + ㅎ
1082 else { 1088 else {
1083 schar = c; mchar = 0; echar = 0; 1089 schar = c; mchar = 0; echar = 0;
1084 return c; 1090 return c;
1085 } 1091 }
1086 1092
1087 } else if (echar == 0x11af) { // ㄹ 1093 } else if (echar == 0x11af) { // ㄹ
1088 1094
1089 if (c == 0x1100) echar = 0x11b0; // ㄹ + ㄱ 1095 if (c == 0x1100) echar = 0x11b0; // ㄹ + ㄱ
1090 else if (c == 0x1106) echar = 0x11b1; // ㄹ + ㅁ 1096 else if (c == 0x1106) echar = 0x11b1; // ㄹ + ㅁ
1091 else if (c == 0x1107) echar = 0x11b2; // ㄹ + ㅂ 1097 else if (c == 0x1107) echar = 0x11b2; // ㄹ + ㅂ
1092 else if (c == 0x1109) echar = 0x11b3; // ㄹ + ㅅ 1098 else if (c == 0x1109) echar = 0x11b3; // ㄹ + ㅅ
1093 else if (c == 0x1110) echar = 0x11b4; // ㄹ + ㅌ 1099 else if (c == 0x1110) echar = 0x11b4; // ㄹ + ㅌ
1094 else if (c == 0x1111) echar = 0x11b5; // ㄹ + ㅍ 1100 else if (c == 0x1111) echar = 0x11b5; // ㄹ + ㅍ
1095 else if (c == 0x1112) echar = 0x11b6; // ㄹ + ㅎ 1101 else if (c == 0x1112) echar = 0x11b6; // ㄹ + ㅎ
1096 else { 1102 else {
1097 schar = c; mchar = 0; echar = 0; 1103 schar = c; mchar = 0; echar = 0;
1098 return c; 1104 return c;
1099 } 1105 }
1100 1106
1101 } else if (echar == 0x11b8) { // ㅂ 1107 } else if (echar == 0x11b8) { // ㅂ
1102 1108
1103 if (c == 0x1109) echar = 0x11b9; // ㅂ + ㅅ 1109 if (c == 0x1109) echar = 0x11b9; // ㅂ + ㅅ
1104 else { 1110 else {
1105 schar = c; mchar = 0; echar = 0; 1111 schar = c; mchar = 0; echar = 0;
1106 return c; 1112 return c;
1107 } 1113 }
1108 1114
1109 } else if (echar == 0x11ba) { // ㅅ 1115 } else if (echar == 0x11ba) { // ㅅ
1110 1116
1111 if (c == 0x1109) echar = 0x11bb; // ㅅ + ㅅ 1117 if (c == 0x1109) echar = 0x11bb; // ㅅ + ㅅ
1112 else { 1118 else {
1113 schar = c; mchar = 0; echar = 0; 1119 schar = c; mchar = 0; echar = 0;
1114 return c; 1120 return c;
1115 } 1121 }
1116 1122
1117 } else { // if any other char, cannot combine chars 1123 } else { // if any other char, cannot combine chars
1118 1124
1119 schar = c; mchar = 0; echar = 0; 1125 schar = c; mchar = 0; echar = 0;
1120 return c; 1126 return c;
1121 } 1127 }
1122 1128
1123 unicode = echar; 1129 unicode = echar;
1124 } 1130 }
1125 } 1131 }
1126 1132
1127 } 1133 }
1128 else if (0x1161 <= c && c <= 0x1175) { // mchar was input 1134 else if (0x1161 <= c && c <= 0x1175) { // mchar was input
1129 1135
1130 if (schar != 0 && mchar == 0) { mchar = c; } 1136 if (schar != 0 && mchar == 0) { mchar = c; }
1131 1137
1132 else if (schar != 0 && mchar != 0 && echar == 0) { 1138 else if (schar != 0 && mchar != 0 && echar == 0) {
1133 1139
1134 switch (mchar) { 1140 switch (mchar) {
1135 case 0x1169: 1141 case 0x1169:
1136 if (c == 0x1161) mchar = 0x116a; 1142 if (c == 0x1161) mchar = 0x116a;
1137 else if (c == 0x1162) mchar = 0x116b; 1143 else if (c == 0x1162) mchar = 0x116b;
1138 else if (c == 0x1175) mchar = 0x116c; 1144 else if (c == 0x1175) mchar = 0x116c;
1139 else { 1145 else {
1140 schar = 0; mchar = 0; echar = 0; 1146 schar = 0; mchar = 0; echar = 0;
1141 return c; 1147 return c;
1142 } 1148 }
1143 break; 1149 break;
1144 case 0x116e: 1150 case 0x116e:
1145 if (c == 0x1165) mchar = 0x116f; 1151 if (c == 0x1165) mchar = 0x116f;
1146 else if (c == 0x1166) mchar = 0x1170; 1152 else if (c == 0x1166) mchar = 0x1170;
1147 else if (c == 0x1175) mchar = 0x1171; 1153 else if (c == 0x1175) mchar = 0x1171;
1148 else { 1154 else {
1149 schar = 0; mchar = 0; echar = 0; 1155 schar = 0; mchar = 0; echar = 0;
1150 return c; 1156 return c;
1151 } 1157 }
1152 break; 1158 break;
1153 case 0x1173: 1159 case 0x1173:
1154 if (c == 0x1175) mchar = 0x1174; 1160 if (c == 0x1175) mchar = 0x1174;
1155 else { 1161 else {
1156 schar = 0; mchar = 0; echar = 0; 1162 schar = 0; mchar = 0; echar = 0;
1157 return c; 1163 return c;
1158 } 1164 }
1159 break; 1165 break;
1160 default: 1166 default:
1161 schar = 0; mchar = 0; echar = 0; 1167 schar = 0; mchar = 0; echar = 0;
1162 return c; 1168 return c;
1163 } 1169 }
1164 } 1170 }
1165 else if (schar != 0 && mchar != 0 && echar != 0) { 1171 else if (schar != 0 && mchar != 0 && echar != 0) {
1166 1172
1167 emit key( 8, Qt::Key_Backspace, 0, true, false ); 1173 emit key( 8, Qt::Key_Backspace, 0, true, false );
1168 1174
1169 ushort prev = 0; 1175 ushort prev = 0;
1170 switch (echar) { 1176 switch (echar) {
1171 /* 1177 /*
1172 case 0x11a9: 1178 case 0x11a9:
1173 prev = combineKoreanChars(schar, mchar, 0x11a8); 1179 prev = combineKoreanChars(schar, mchar, 0x11a8);
1174 schar = 0x1100; 1180 schar = 0x1100;
1175 break; 1181 break;
1176 */ 1182 */
1177 case 0x11aa: 1183 case 0x11aa:
1178 prev = combineKoreanChars(schar, mchar, 0x11a8); 1184 prev = combineKoreanChars(schar, mchar, 0x11a8);
1179 schar = 0x1109; 1185 schar = 0x1109;
1180 break; 1186 break;
1181 case 0x11ac: 1187 case 0x11ac:
1182 prev = combineKoreanChars(schar, mchar, 0x11ab); 1188 prev = combineKoreanChars(schar, mchar, 0x11ab);
1183 schar = 0x110c; 1189 schar = 0x110c;
1184 break; 1190 break;
1185 case 0x11ad: 1191 case 0x11ad:
1186 prev = combineKoreanChars(schar, mchar, 0x11ab); 1192 prev = combineKoreanChars(schar, mchar, 0x11ab);
1187 schar = 0x1112; 1193 schar = 0x1112;
1188 break; 1194 break;
1189 case 0x11b0: 1195 case 0x11b0:
1190 prev = combineKoreanChars(schar, mchar, 0x11af); 1196 prev = combineKoreanChars(schar, mchar, 0x11af);
1191 schar = 0x1100; 1197 schar = 0x1100;
1192 break; 1198 break;
1193 case 0x11b1: 1199 case 0x11b1:
1194 prev = combineKoreanChars(schar, mchar, 0x11af); 1200 prev = combineKoreanChars(schar, mchar, 0x11af);
1195 schar = 0x1106; 1201 schar = 0x1106;
1196 break; 1202 break;
1197 case 0x11b2: 1203 case 0x11b2:
1198 prev = combineKoreanChars(schar, mchar, 0x11af); 1204 prev = combineKoreanChars(schar, mchar, 0x11af);
1199 schar = 0x1107; 1205 schar = 0x1107;
1200 break; 1206 break;
1201 case 0x11b3: 1207 case 0x11b3:
1202 prev = combineKoreanChars(schar, mchar, 0x11af); 1208 prev = combineKoreanChars(schar, mchar, 0x11af);
1203 schar = 0x1109; 1209 schar = 0x1109;
1204 break; 1210 break;
1205 case 0x11b4: 1211 case 0x11b4:
1206 prev = combineKoreanChars(schar, mchar, 0x11af); 1212 prev = combineKoreanChars(schar, mchar, 0x11af);
1207 schar = 0x1110; 1213 schar = 0x1110;
1208 break; 1214 break;
1209 case 0x11b9: 1215 case 0x11b9:
1210 prev = combineKoreanChars(schar, mchar, 0x11b8); 1216 prev = combineKoreanChars(schar, mchar, 0x11b8);
1211 schar = 0x1109; 1217 schar = 0x1109;
1212 break; 1218 break;
1213 /* 1219 /*
1214 case 0x11bb: 1220 case 0x11bb:
1215 prev = combineKoreanChars(schar, mchar, 0x11ba); 1221 prev = combineKoreanChars(schar, mchar, 0x11ba);
1216 schar = 0x1109; 1222 schar = 0x1109;
1217 break; 1223 break;
1218 */ 1224 */
1219 default: 1225 default:
1220 1226
1221 if (constoe(echar)) { 1227 if (constoe(echar)) {
1222 1228
1223 prev = combineKoreanChars(schar, mchar, 0); 1229 prev = combineKoreanChars(schar, mchar, 0);
1224 schar = constoe(echar); 1230 schar = constoe(echar);
1225 } 1231 }
1226 break; 1232 break;
1227 } 1233 }
1228 1234
1229 emit key( prev, prev, 0, true, false ); 1235 emit key( prev, prev, 0, true, false );
1230 1236
1231 mchar = c; echar = 0; 1237 mchar = c; echar = 0;
1232 1238
1233 return combineKoreanChars(schar, mchar, 0); 1239 return combineKoreanChars(schar, mchar, 0);
1234 1240
1235 } 1241 }
1236 else { 1242 else {
1237 schar = 0; mchar = 0; echar = 0; 1243 schar = 0; mchar = 0; echar = 0;
1238 return c; 1244 return c;
1239 } 1245 }
1240 1246
1241 } 1247 }
1242 else /*if (c == ' ')*/ return c; 1248 else /*if (c == ' ')*/ return c;
1243 1249
1244 1250
1245 // and now... finally delete previous char, and return new char 1251 // and now... finally delete previous char, and return new char
1246 emit key( 8, Qt::Key_Backspace, 0, true, false ); 1252 emit key( 8, Qt::Key_Backspace, 0, true, false );
1247 1253
1248 1254
1249 return combineKoreanChars( schar, mchar, echar); 1255 return combineKoreanChars( schar, mchar, echar);
1250 1256
1251} 1257}
1252 1258
1253ushort Keyboard::combineKoreanChars(const ushort s, const ushort m, const ushort e) { 1259ushort Keyboard::combineKoreanChars(const ushort s, const ushort m, const ushort e) {
1254 1260
1255 return ((s - 0x1100) * 588) + ((m - 0x1161) * 28) + (e ? e - 0x11a7 : 0) + 0xac00; 1261 return ((s - 0x1100) * 588) + ((m - 0x1161) * 28) + (e ? e - 0x11a7 : 0) + 0xac00;
1256 1262
1257} 1263}
1258 1264
1259ushort Keyboard::constoe(const ushort c) { 1265ushort Keyboard::constoe(const ushort c) {
1260 1266
1261 // converts schars to echars if possible 1267 // converts schars to echars if possible
1262 1268
1263 if (0x1100 <= c && c <= 0x1112) { // schar to echar 1269 if (0x1100 <= c && c <= 0x1112) { // schar to echar
1264 1270
1265 switch (c) { 1271 switch (c) {
1266 case 0x1100: return 0x11a8; 1272 case 0x1100: return 0x11a8;
1267 case 0x1101: return 0x11a9; 1273 case 0x1101: return 0x11a9;
1268 case 0x1102: return 0x11ab; 1274 case 0x1102: return 0x11ab;
1269 case 0x1103: return 0x11ae; 1275 case 0x1103: return 0x11ae;
1270 case 0x1105: return 0x11af; 1276 case 0x1105: return 0x11af;
1271 case 0x1106: return 0x11b7; 1277 case 0x1106: return 0x11b7;
1272 case 0x1107: return 0x11b8; 1278 case 0x1107: return 0x11b8;
1273 case 0x1109: return 0x11ba; 1279 case 0x1109: return 0x11ba;
1274 case 0x110a: return 0x11bb; 1280 case 0x110a: return 0x11bb;
1275 case 0x110b: return 0x11bc; 1281 case 0x110b: return 0x11bc;
1276 case 0x110c: return 0x11bd; 1282 case 0x110c: return 0x11bd;
1277 case 0x110e: return 0x11be; 1283 case 0x110e: return 0x11be;
1278 case 0x110f: return 0x11bf; 1284 case 0x110f: return 0x11bf;
1279 case 0x1110: return 0x11c0; 1285 case 0x1110: return 0x11c0;
1280 case 0x1111: return 0x11c1; 1286 case 0x1111: return 0x11c1;
1281 case 0x1112: return 0x11c2; 1287 case 0x1112: return 0x11c2;
1282 default: return 0; 1288 default: return 0;
1283 1289
1284 } 1290 }
1285 1291
1286 } else { //echar to schar 1292 } else { //echar to schar
1287 1293
1288 switch (c) { 1294 switch (c) {
1289 case 0x11a8: return 0x1100; 1295 case 0x11a8: return 0x1100;
1290 case 0x11a9: return 0x1101; 1296 case 0x11a9: return 0x1101;
1291 case 0x11ab: return 0x1102; 1297 case 0x11ab: return 0x1102;
1292 case 0x11ae: return 0x1103; 1298 case 0x11ae: return 0x1103;
1293 case 0x11af: return 0x1105; 1299 case 0x11af: return 0x1105;
1294 case 0x11b7: return 0x1106; 1300 case 0x11b7: return 0x1106;
1295 case 0x11b8: return 0x1107; 1301 case 0x11b8: return 0x1107;
1296 case 0x11ba: return 0x1109; 1302 case 0x11ba: return 0x1109;
1297 case 0x11bb: return 0x110a; 1303 case 0x11bb: return 0x110a;
1298 case 0x11bc: return 0x110b; 1304 case 0x11bc: return 0x110b;
1299 case 0x11bd: return 0x110c; 1305 case 0x11bd: return 0x110c;
1300 case 0x11be: return 0x110e; 1306 case 0x11be: return 0x110e;
1301 case 0x11bf: return 0x110f; 1307 case 0x11bf: return 0x110f;
1302 case 0x11c0: return 0x1110; 1308 case 0x11c0: return 0x1110;
1303 case 0x11c1: return 0x1111; 1309 case 0x11c1: return 0x1111;
1304 case 0x11c2: return 0x1112; 1310 case 0x11c2: return 0x1112;
1305 default: return 0; 1311 default: return 0;
1306 1312
1307 } 1313 }
1308 1314
1309 } 1315 }
1310} 1316}
1311 1317
1312 1318
1313// Keys::Keys {{{1 1319// Keys::Keys {{{1
1314 1320
1315Keys::Keys() { 1321Keys::Keys() {
1316 1322
1317 Config *config = new Config ("multikey"); 1323 Config *config = new Config ("multikey");
1318 config->setGroup( "keymaps" ); 1324 config->setGroup( "keymaps" );
1319 QString map = config->readEntry( "current" ); 1325 QString map = config->readEntry( "current" );
1320 delete config; 1326 delete config;
1321 1327
1322 if (map.isNull() || !(QFile(map).exists())) { 1328 if (map.isNull() || !(QFile(map).exists())) {
1323 1329
1324 Config *config = new Config("locale"); 1330 Config *config = new Config("locale");
1325 config->setGroup( "Language" ); 1331 config->setGroup( "Language" );
1326 QString l = config->readEntry( "Language" , "en" ); 1332 QString l = config->readEntry( "Language" , "en" );
1327 delete config; 1333 delete config;
1328 1334
1329 map = QPEApplication::qpeDir() + "/share/multikey/" 1335 map = QPEApplication::qpeDir() + "/share/multikey/"
1330 + l + ".keymap"; 1336 + l + ".keymap";
1331 1337
1332 } 1338 }
1333 if (map.isNull() || !(QFile(map).exists())) { 1339 if (map.isNull() || !(QFile(map).exists())) {
1334 map = QPEApplication::qpeDir() + "/share/multikey/en.keymap"; 1340 map = QPEApplication::qpeDir() + "/share/multikey/en.keymap";
1335 } 1341 }
1336 1342
1337 setKeysFromFile(map); 1343 setKeysFromFile(map);
1338} 1344}
1339 1345
1340Keys::Keys(const char * filename) { 1346Keys::Keys(const char * filename) {
1341 1347
1342 setKeysFromFile(filename); 1348 setKeysFromFile(filename);
1343} 1349}
1344 1350
1345// Keys::setKeysFromFile {{{2 1351// Keys::setKeysFromFile {{{2
1346void Keys::setKeysFromFile(const char * filename) { 1352void Keys::setKeysFromFile(const char * filename) {
1347 1353
1348 QFile f(filename); 1354 QFile f(filename);
1349 1355
1350 if (f.open(IO_ReadOnly)) { 1356 if (f.open(IO_ReadOnly)) {
1351 1357
1352 QTextStream t(&f); 1358 QTextStream t(&f);
1353 int row; 1359 int row;
1354 int qcode; 1360 int qcode;
1355 ushort unicode; 1361 ushort unicode;
1356 int width; 1362 int width;
1357 QString buf; 1363 QString buf;
1358 QString comment; 1364 QString comment;
1359 char * xpm[256]; //couldnt be larger than that... could it? 1365 char * xpm[256]; //couldnt be larger than that... could it?
1360 QImage *xpm2pix = 0; 1366 QImage *xpm2pix = 0;
1361 1367
1362 buf = t.readLine(); 1368 buf = t.readLine();
1363 while (buf) { 1369 while (buf) {
1364 1370
1365 // get rid of comments 1371 // get rid of comments
1366 buf.replace(QRegExp("#.*$", FALSE, FALSE), ""); 1372 buf.replace(QRegExp("#.*$", FALSE, FALSE), "");
1367 1373
1368 // key definition 1374 // key definition
1369 if (buf.contains(QRegExp("^\\d+\\s+[0-1a-fx]+", FALSE, FALSE))) { 1375 if (buf.contains(QRegExp("^\\d+\\s+[0-1a-fx]+", FALSE, FALSE))) {
1370 // no $1 type referencing!!! this implementation of regexp sucks 1376 // no $1 type referencing!!! this implementation of regexp sucks
1371 1377
1372 // dont know of any sscanf() type funcs in Qt lib 1378 // dont know of any sscanf() type funcs in Qt lib
1373 QTextStream tmp (buf, IO_ReadOnly); 1379 QTextStream tmp (buf, IO_ReadOnly);
1374 tmp >> row >> qcode >> unicode >> width >> comment; 1380 tmp >> row >> qcode >> unicode >> width >> comment;
1375 1381
1376 buf = t.readLine(); 1382 buf = t.readLine();
1377 int xpmLineCount = 0; 1383 int xpmLineCount = 0;
1378 xpm2pix = 0; 1384 xpm2pix = 0;
1379 1385
1380 // erase blank space 1386 // erase blank space
1381 while (buf.contains(QRegExp("^\\s*$")) && buf) buf = t.readLine(); 1387 while (buf.contains(QRegExp("^\\s*$")) && buf) buf = t.readLine();
1382 1388
1383 while (buf.contains(QRegExp("^\\s*\".*\""))) { 1389 while (buf.contains(QRegExp("^\\s*\".*\""))) {
1384 1390
1385 QString xpmBuf = buf.stripWhiteSpace(); 1391 QString xpmBuf = buf.stripWhiteSpace();
1386 1392
1387 xpm[xpmLineCount] = new char [xpmBuf.length()]; 1393 xpm[xpmLineCount] = new char [xpmBuf.length()];
1388 1394
1389 int j = 0; 1395 int j = 0;
1390 for (ushort i = 0; i < xpmBuf.length(); i++) { 1396 for (ushort i = 0; i < xpmBuf.length(); i++) {
1391 if (xpmBuf[i].latin1() != '"') { 1397 if (xpmBuf[i].latin1() != '"') {
1392 1398
1393 ((char *)xpm[xpmLineCount])[j] = xpmBuf.at(i).latin1(); 1399 ((char *)xpm[xpmLineCount])[j] = xpmBuf.at(i).latin1();
1394 j++; 1400 j++;
1395 } 1401 }
1396 1402
1397 } 1403 }
1398 // have to close that facker up 1404 // have to close that facker up
1399 ((char *)xpm[xpmLineCount])[j] = '\0'; 1405 ((char *)xpm[xpmLineCount])[j] = '\0';
1400 1406
1401 xpmLineCount++; 1407 xpmLineCount++;
1402 buf = t.readLine(); 1408 buf = t.readLine();
1403 } 1409 }
1404 if (xpmLineCount) { 1410 if (xpmLineCount) {
1405 1411
1406 xpm2pix = new QImage((const char **)xpm); 1412 xpm2pix = new QImage((const char **)xpm);
1407 for (int i = 0; i < xpmLineCount; i++) 1413 for (int i = 0; i < xpmLineCount; i++)
1408 1414
1409 delete [] (xpm[i]); 1415 delete [] (xpm[i]);
1410 1416
1411 } 1417 }
1412 setKey(row, qcode, unicode, width, xpm2pix); 1418 setKey(row, qcode, unicode, width, xpm2pix);
1413 } 1419 }
1414 1420
1415 // shift map 1421 // shift map
1416 else if (buf.contains(QRegExp("^[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { 1422 else if (buf.contains(QRegExp("^[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) {
1417 1423
1418 QTextStream tmp (buf, IO_ReadOnly); 1424 QTextStream tmp (buf, IO_ReadOnly);
1419 ushort lower, shift; 1425 ushort lower, shift;
1420 tmp >> lower >> shift; 1426 tmp >> lower >> shift;
1421 1427
1422 shiftMap.insert(lower, shift); 1428 shiftMap.insert(lower, shift);
1423 1429
1424 buf = t.readLine(); 1430 buf = t.readLine();
1425 } 1431 }
1426 1432
1427 // meta key map 1433 // meta key map
1428 else if (buf.contains(QRegExp("^\\s*m\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { 1434 else if (buf.contains(QRegExp("^\\s*m\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) {
1429 1435
1430 QTextStream tmp (buf, IO_ReadOnly); 1436 QTextStream tmp (buf, IO_ReadOnly);
1431 ushort lower, shift; 1437 ushort lower, shift;
1432 QChar m; 1438 QChar m;
1433 tmp >> m >> lower >> shift; 1439 tmp >> m >> lower >> shift;
1434 1440
1435 metaMap.insert(lower, shift); 1441 metaMap.insert(lower, shift);
1436 1442
1437 buf = t.readLine(); 1443 buf = t.readLine();
1438 } 1444 }
1439 1445
1440 // circumflex 1446 // circumflex
1441 else if (buf.contains(QRegExp("^\\s*c\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { 1447 else if (buf.contains(QRegExp("^\\s*c\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) {
1442 1448
1443 QTextStream tmp (buf, IO_ReadOnly); 1449 QTextStream tmp (buf, IO_ReadOnly);
1444 ushort lower, shift; 1450 ushort lower, shift;
1445 QChar c; 1451 QChar c;
1446 tmp >> c >> lower >> shift; 1452 tmp >> c >> lower >> shift;
1447 1453
1448 circumflexMap.insert(lower, shift); 1454 circumflexMap.insert(lower, shift);
1449 1455
1450 buf = t.readLine(); 1456 buf = t.readLine();
1451 } 1457 }
1452 // diaeresis 1458 // diaeresis
1453 else if (buf.contains(QRegExp("^\\s*d\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { 1459 else if (buf.contains(QRegExp("^\\s*d\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) {
1454 1460
1455 QTextStream tmp (buf, IO_ReadOnly); 1461 QTextStream tmp (buf, IO_ReadOnly);
1456 ushort lower, shift; 1462 ushort lower, shift;
1457 QChar d; 1463 QChar d;
1458 tmp >> d >> lower >> shift; 1464 tmp >> d >> lower >> shift;
1459 1465
1460 diaeresisMap.insert(lower, shift); 1466 diaeresisMap.insert(lower, shift);
1461 1467
1462 buf = t.readLine(); 1468 buf = t.readLine();
1463 } 1469 }
1464 // back accent 1470 // back accent
1465 else if (buf.contains(QRegExp("^\\s*b\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { 1471 else if (buf.contains(QRegExp("^\\s*b\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) {
1466 1472
1467 QTextStream tmp (buf, IO_ReadOnly); 1473 QTextStream tmp (buf, IO_ReadOnly);
1468 ushort lower, shift; 1474 ushort lower, shift;
1469 QChar d; 1475 QChar d;
1470 tmp >> d >> lower >> shift; 1476 tmp >> d >> lower >> shift;
1471 1477
1472 baccentMap.insert(lower, shift); 1478 baccentMap.insert(lower, shift);
1473 1479
1474 qDebug ("Estoy aadiendo %i con %i", lower, shift); 1480 qDebug ("Estoy aadiendo %i con %i", lower, shift);
1475 buf = t.readLine(); 1481 buf = t.readLine();
1476 } 1482 }
1477 // accent 1483 // accent
1478 else if (buf.contains(QRegExp("^\\s*a\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { 1484 else if (buf.contains(QRegExp("^\\s*a\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) {
1479 1485
1480 QTextStream tmp (buf, IO_ReadOnly); 1486 QTextStream tmp (buf, IO_ReadOnly);
1481 ushort lower, shift; 1487 ushort lower, shift;
1482 QChar d; 1488 QChar d;
1483 tmp >> d >> lower >> shift; 1489 tmp >> d >> lower >> shift;
1484 1490
1485 accentMap.insert(lower, shift); 1491 accentMap.insert(lower, shift);
1486 1492
1487 buf = t.readLine(); 1493 buf = t.readLine();
1488 } 1494 }
1489 1495
1490 // other variables like lang & title 1496 // other variables like lang & title
1491 else if (buf.contains(QRegExp("^\\s*[a-zA-Z]+\\s*=\\s*[a-zA-Z0-9/]+\\s*$", FALSE, FALSE))) { 1497 else if (buf.contains(QRegExp("^\\s*[a-zA-Z]+\\s*=\\s*[a-zA-Z0-9/]+\\s*$", FALSE, FALSE))) {
1492 1498
1493 QTextStream tmp (buf, IO_ReadOnly); 1499 QTextStream tmp (buf, IO_ReadOnly);
1494 QString name, equals, value; 1500 QString name, equals, value;
1495 1501
1496 tmp >> name >> equals >> value; 1502 tmp >> name >> equals >> value;
1497 1503
1498 if (name == "lang") { 1504 if (name == "lang") {
1499 1505
1500 lang = value; 1506 lang = value;
1501 1507
1502 } 1508 }
1503 1509
1504 buf = t.readLine(); 1510 buf = t.readLine();
1505 } 1511 }
1506 // comments 1512 // comments
1507 else if (buf.contains(QRegExp("^\\s*#"))) { 1513 else if (buf.contains(QRegExp("^\\s*#"))) {
1508 1514
1509 buf = t.readLine(); 1515 buf = t.readLine();
1510 1516
1511 } else { // blank line, or garbage 1517 } else { // blank line, or garbage
1512 1518
1513 buf = t.readLine(); 1519 buf = t.readLine();
1514 1520
1515 } 1521 }
1516 1522
1517 } 1523 }
1518 f.close(); 1524 f.close();
1519 } 1525 }
1520 1526
1521} 1527}
1522 1528
1523// Keys::setKey {{{2 1529// Keys::setKey {{{2
1524void Keys::setKey(const int row, const int qcode, const ushort unicode, 1530void Keys::setKey(const int row, const int qcode, const ushort unicode,
1525 const int width, QImage *pix) { 1531 const int width, QImage *pix) {
1526 1532
1527 Key * key; 1533 Key * key;
1528 key = new Key; 1534 key = new Key;
1529 key->qcode = qcode; 1535 key->qcode = qcode;
1530 key->unicode = unicode; 1536 key->unicode = unicode;
1531 key->width = width; 1537 key->width = width;
1532 1538
1533 // share key->pressed between same keys 1539 // share key->pressed between same keys
1534 bool found = 0; 1540 bool found = 0;
1535 for (int i = 1; i <= 5; i++) { 1541 for (int i = 1; i <= 5; i++) {
1536 for (unsigned int j = 0; j < keys[i].count(); j++) 1542 for (unsigned int j = 0; j < keys[i].count(); j++)
1537 if (keys[i].at(j)->qcode == qcode && keys[i].at(j)->unicode == unicode) { 1543 if (keys[i].at(j)->qcode == qcode && keys[i].at(j)->unicode == unicode) {
1538 1544
1539 key->pressed = keys[i].at(j)->pressed; 1545 key->pressed = keys[i].at(j)->pressed;
1540 found = 1; 1546 found = 1;
1541 } 1547 }
1542 1548
1543 } 1549 }
1544 if (!found) { 1550 if (!found) {
1545 1551
1546 key->pressed = new bool; 1552 key->pressed = new bool;
1547 *(key->pressed) = 0; 1553 *(key->pressed) = 0;
1548 } 1554 }
1549 1555
1550 key->pix = pix; 1556 key->pix = pix;
1551 1557
1552 1558
1553 keys[row].append(key); 1559 keys[row].append(key);
1554} 1560}
1555 1561
1556// Keys::~Keys {{{2 1562// Keys::~Keys {{{2
1557Keys::~Keys() { 1563Keys::~Keys() {
1558 1564
1559 for (int i = 1; i <= 5; i++) 1565 for (int i = 1; i <= 5; i++)
1560 for (unsigned int j = 0; j < keys[i].count(); j++) 1566 for (unsigned int j = 0; j < keys[i].count(); j++)
1561 delete keys[i].at(j); 1567 delete keys[i].at(j);
1562 1568
1563} 1569}
1564 1570
1565// Keys:: other functions {{{2 1571// Keys:: other functions {{{2
1566int Keys::width(const int row, const int col) { 1572int Keys::width(const int row, const int col) {
1567 1573
1568 return keys[row].at(col)->width; 1574 return keys[row].at(col)->width;
1569 1575
1570} 1576}
1571 1577
1572int Keys::rows() { 1578int Keys::rows() {
1573 1579
1574 for (int i = 1; i <= 5; i++) { 1580 for (int i = 1; i <= 5; i++) {
1575 1581
1576 if (keys[i].count() == 0) 1582 if (keys[i].count() == 0)
1577 return i - 1; 1583 return i - 1;
1578 1584
1579 } 1585 }
1580 return 5; 1586 return 5;
1581} 1587}
1582 1588
1583ushort Keys::uni(const int row, const int col) { 1589ushort Keys::uni(const int row, const int col) {
1584 1590
1585 return keys[row].at(col)->unicode; 1591 return keys[row].at(col)->unicode;
1586 1592
1587} 1593}
1588 1594
1589int Keys::qcode(const int row, const int col) { 1595int Keys::qcode(const int row, const int col) {
1590 1596
1591 return keys[row].at(col)->qcode; 1597 return keys[row].at(col)->qcode;
1592} 1598}
1593 1599
1594QImage *Keys::pix(const int row, const int col) { 1600QImage *Keys::pix(const int row, const int col) {
1595 1601
1596 return keys[row].at(col)->pix; 1602 return keys[row].at(col)->pix;
1597 1603
1598} 1604}
1599bool Keys::pressed(const int row, const int col) { 1605bool Keys::pressed(const int row, const int col) {
1600 1606
1601 return *(keys[row].at(col)->pressed); 1607 return *(keys[row].at(col)->pressed);
1602} 1608}
1603 1609
1604int Keys::numKeys(const int row) { 1610int Keys::numKeys(const int row) {
1605 1611
1606 return keys[row].count(); 1612 return keys[row].count();
1607} 1613}
1608 1614
1609void Keys::setPressed(const int row, const int col, const bool pressed) { 1615void Keys::setPressed(const int row, const int col, const bool pressed) {
1610 1616
1611 *(keys[row].at(col)->pressed) = pressed; 1617 *(keys[row].at(col)->pressed) = pressed;
1612} 1618}
1613 1619
1614ushort Keys::shift(const ushort uni) { 1620ushort Keys::shift(const ushort uni) {
1615 1621
1616 if (shiftMap[uni]) return shiftMap[uni]; 1622 if (shiftMap[uni]) return shiftMap[uni];
1617 else return 0; 1623 else return 0;
1618} 1624}
1619 1625
1620ushort Keys::meta(const ushort uni) { 1626ushort Keys::meta(const ushort uni) {
1621 1627
1622 if (metaMap[uni]) return metaMap[uni]; 1628 if (metaMap[uni]) return metaMap[uni];
1623 else return 0; 1629 else return 0;
1624} 1630}
1625 1631
1626ushort Keys::circumflex(const ushort uni) { 1632ushort Keys::circumflex(const ushort uni) {
1627 1633
1628 if (circumflexMap[uni]) return circumflexMap[uni]; 1634 if (circumflexMap[uni]) return circumflexMap[uni];
1629 else return 0; 1635 else return 0;
1630} 1636}
1631 1637
1632ushort Keys::diaeresis(const ushort uni) { 1638ushort Keys::diaeresis(const ushort uni) {
1633 1639
1634 if(diaeresisMap[uni]) return diaeresisMap[uni]; 1640 if(diaeresisMap[uni]) return diaeresisMap[uni];
1635 else return 0; 1641 else return 0;
1636} 1642}
1637 1643
1638ushort Keys::baccent(const ushort uni) { 1644ushort Keys::baccent(const ushort uni) {
1639 1645
1640 if(baccentMap[uni]) return baccentMap[uni]; 1646 if(baccentMap[uni]) return baccentMap[uni];
1641 else return 0; 1647 else return 0;
1642} 1648}
1643 1649
1644ushort Keys::accent(const ushort uni) { 1650ushort Keys::accent(const ushort uni) {
1645 1651
1646 if(accentMap[uni]) return accentMap[uni]; 1652 if(accentMap[uni]) return accentMap[uni];
1647 else return 0; 1653 else return 0;
1648} 1654}
1649 1655
1650bool *Keys::pressedPtr(const int row, const int col) { 1656bool *Keys::pressedPtr(const int row, const int col) {
1651 1657
1652 return keys[row].at(col)->pressed; 1658 return keys[row].at(col)->pressed;
1653} 1659}