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