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