summaryrefslogtreecommitdiff
authorhash <hash>2002-08-22 05:50:34 (UTC)
committer hash <hash>2002-08-22 05:50:34 (UTC)
commit4c02921ddab3dd8b48d7d54a0c09e8f4ca71efb3 (patch) (unidiff)
treeaeada387b0a02e5cbdb409309a47a36649938b95
parentea0d66f137984689c4d4ef6da7dd4b7323760e8c (diff)
downloadopie-4c02921ddab3dd8b48d7d54a0c09e8f4ca71efb3.zip
opie-4c02921ddab3dd8b48d7d54a0c09e8f4ca71efb3.tar.gz
opie-4c02921ddab3dd8b48d7d54a0c09e8f4ca71efb3.tar.bz2
added meta key support for maps like german and jumpx
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/multikey/keyboard.cpp98
-rw-r--r--inputmethods/multikey/keyboard.h3
2 files changed, 93 insertions, 8 deletions
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp
index 7098a6b..74c99c7 100644
--- a/inputmethods/multikey/keyboard.cpp
+++ b/inputmethods/multikey/keyboard.cpp
@@ -1,1175 +1,1257 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "keyboard.h" 21#include "keyboard.h"
22#include "configdlg.h" 22#include "configdlg.h"
23 23
24#include <qpe/global.h> 24#include <qpe/global.h>
25#include <qpe/qcopenvelope_qws.h> 25#include <qpe/qcopenvelope_qws.h>
26 26
27#include <qwindowsystem_qws.h> 27#include <qwindowsystem_qws.h>
28#include <qpainter.h> 28#include <qpainter.h>
29#include <qfontmetrics.h> 29#include <qfontmetrics.h>
30#include <qtimer.h> 30#include <qtimer.h>
31#include <qpe/qpeapplication.h> 31#include <qpe/qpeapplication.h>
32#include <qpe/config.h> 32#include <qpe/config.h>
33#include <ctype.h> 33#include <ctype.h>
34#include <qfile.h> 34#include <qfile.h>
35#include <qtextstream.h> 35#include <qtextstream.h>
36#include <qstringlist.h> 36#include <qstringlist.h>
37#include <iostream.h> 37#include <iostream.h>
38 38
39#include <sys/utsname.h> 39#include <sys/utsname.h>
40 40
41 41
42/* Keyboard::Keyboard {{{1 */ 42/* Keyboard::Keyboard {{{1 */
43Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : 43Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) :
44 QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), 44 QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), alt(0), meta(0),
45 alt(0), useLargeKeys(TRUE), usePicks(0), useRepeat(0), pressedKeyRow(-1), pressedKeyCol(-1), 45 useLargeKeys(TRUE), usePicks(0), useRepeat(0), pressedKeyRow(-1), pressedKeyCol(-1),
46 unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0), 46 unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0),
47 configdlg(0) 47 configdlg(0)
48 48
49{ 49{
50 50
51 // get the default font 51 // get the default font
52 Config *config = new Config( "qpe" ); 52 Config *config = new Config( "qpe" );
53 config->setGroup( "Appearance" ); 53 config->setGroup( "Appearance" );
54 QString familyStr = config->readEntry( "FontFamily", "fixed" ); 54 QString familyStr = config->readEntry( "FontFamily", "fixed" );
55 delete config; 55 delete config;
56 56
57 config = new Config("multikey"); 57 config = new Config("multikey");
58 config->setGroup ("general"); 58 config->setGroup ("general");
59 usePicks = config->readBoolEntry ("usePickboard", "0"); // default closed 59 usePicks = config->readBoolEntry ("usePickboard", "0"); // default closed
60 useRepeat = config->readBoolEntry ("useRepeat", "1"); 60 useRepeat = config->readBoolEntry ("useRepeat", "1");
61 delete config; 61 delete config;
62 62
63 63
64 setFont( QFont( familyStr, 10 ) ); 64 setFont( QFont( familyStr, 10 ) );
65 65
66 picks = new KeyboardPicks( this ); 66 picks = new KeyboardPicks( this );
67 picks->setFont( QFont( familyStr, 10 ) ); 67 picks->setFont( QFont( familyStr, 10 ) );
68 picks->initialise(); 68 picks->initialise();
69 if (usePicks) { 69 if (usePicks) {
70 70
71 QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), 71 QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ),
72 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); 72 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) );
73 73
74 } else picks->hide(); 74 } else picks->hide();
75 75
76 loadKeyboardColors(); 76 loadKeyboardColors();
77 77
78 keys = new Keys(); 78 keys = new Keys();
79 79
80 repeatTimer = new QTimer( this ); 80 repeatTimer = new QTimer( this );
81 connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); 81 connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) );
82 82
83} 83}
84 84
85Keyboard::~Keyboard() { 85Keyboard::~Keyboard() {
86 86
87 if ( configdlg ) { 87 if ( configdlg ) {
88 delete (ConfigDlg *) configdlg; 88 delete (ConfigDlg *) configdlg;
89 configdlg = 0; 89 configdlg = 0;
90 } 90 }
91 91
92} 92}
93 93
94/* Keyboard::resizeEvent {{{1 */ 94/* Keyboard::resizeEvent {{{1 */
95void Keyboard::resizeEvent(QResizeEvent*) 95void Keyboard::resizeEvent(QResizeEvent*)
96{ 96{
97 int ph = picks->sizeHint().height(); 97 int ph = picks->sizeHint().height();
98 picks->setGeometry( 0, 0, width(), ph ); 98 picks->setGeometry( 0, 0, width(), ph );
99 keyHeight = (height()-(usePicks ? ph : 0))/5; 99 keyHeight = (height()-(usePicks ? ph : 0))/5;
100 100
101 int nk; // number of keys? 101 int nk; // number of keys?
102 if ( useLargeKeys ) { 102 if ( useLargeKeys ) {
103 nk = 15; 103 nk = 15;
104 } else { 104 } else {
105 nk = 19; 105 nk = 19;
106 } 106 }
107 defaultKeyWidth = (width()/nk)/2; 107 defaultKeyWidth = (width()/nk)/2;
108 xoffs = (width()-defaultKeyWidth*nk)/2; // empty key spaces? 108 xoffs = (width()-defaultKeyWidth*nk)/2; // empty key spaces?
109 109
110} 110}
111 111
112/* KeyboardPicks::initialize {{{1 */ 112/* KeyboardPicks::initialize {{{1 */
113void KeyboardPicks::initialise() 113void KeyboardPicks::initialise()
114{ 114{
115 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); 115 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
116 mode = 0; 116 mode = 0;
117 dc = new KeyboardConfig(this); 117 dc = new KeyboardConfig(this);
118 configs.append(dc); 118 configs.append(dc);
119} 119}
120 120
121/* KeyboardPicks::sizeHint {{{1 */ 121/* KeyboardPicks::sizeHint {{{1 */
122QSize KeyboardPicks::sizeHint() const 122QSize KeyboardPicks::sizeHint() const
123{ 123{
124 return QSize(240,fontMetrics().lineSpacing()); 124 return QSize(240,fontMetrics().lineSpacing());
125} 125}
126 126
127 127
128/* KeyboardConfig::generateText {{{1 */ 128/* KeyboardConfig::generateText {{{1 */
129void KeyboardConfig::generateText(const QString &s) 129void KeyboardConfig::generateText(const QString &s)
130{ 130{
131#if defined(Q_WS_QWS) || defined(_WS_QWS_) 131#if defined(Q_WS_QWS) || defined(_WS_QWS_)
132 for (int i=0; i<(int)backspaces; i++) { 132 for (int i=0; i<(int)backspaces; i++) {
133 parent->emitKey( 0, Qt::Key_Backspace, 0, true, false ); 133 parent->emitKey( 0, Qt::Key_Backspace, 0, true, false );
134 parent->emitKey( 0, Qt::Key_Backspace, 0, false, false ); 134 parent->emitKey( 0, Qt::Key_Backspace, 0, false, false );
135 } 135 }
136 for (int i=0; i<(int)s.length(); i++) { 136 for (int i=0; i<(int)s.length(); i++) {
137 parent->emitKey( s[i].unicode(), 0, 0, true, false ); 137 parent->emitKey( s[i].unicode(), 0, 0, true, false );
138 parent->emitKey( s[i].unicode(), 0, 0, false, false ); 138 parent->emitKey( s[i].unicode(), 0, 0, false, false );
139 } 139 }
140 parent->emitKey( 0, Qt::Key_Space, 0, true, false ); 140 parent->emitKey( 0, Qt::Key_Space, 0, true, false );
141 parent->emitKey( 0, Qt::Key_Space, 0, false, false ); 141 parent->emitKey( 0, Qt::Key_Space, 0, false, false );
142 backspaces = 0; 142 backspaces = 0;
143#endif 143#endif
144} 144}
145 145
146 146
147 147
148 148
149/* Keyboard::paintEvent {{{1 */ 149/* Keyboard::paintEvent {{{1 */
150void Keyboard::paintEvent(QPaintEvent* e) 150void Keyboard::paintEvent(QPaintEvent* e)
151{ 151{
152 QPainter painter(this); 152 QPainter painter(this);
153 painter.setClipRect(e->rect()); 153 painter.setClipRect(e->rect());
154 drawKeyboard( painter ); 154 drawKeyboard( painter );
155 picks->dc->draw( &painter ); 155 picks->dc->draw( &painter );
156} 156}
157 157
158 158
159/* Keyboard::drawKeyboard {{{1 */ 159/* Keyboard::drawKeyboard {{{1 */
160 160
161void Keyboard::drawKeyboard(QPainter &p, int row, int col) 161void Keyboard::drawKeyboard(QPainter &p, int row, int col)
162{ 162{
163 163
164 164
165 if (row != -1 && col != -1) { //just redraw one key 165 if (row != -1 && col != -1) { //just redraw one key
166 166
167 int x = 0; 167 int x = 0;
168 for (int i = 0; i < col; i++) { 168 for (int i = 0; i < col; i++) {
169 169
170 x += keys->width(row, i) * defaultKeyWidth; 170 x += keys->width(row, i) * defaultKeyWidth;
171 } 171 }
172 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); 172 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0);
173 173
174 int keyWidth = keys->width(row, col); 174 int keyWidth = keys->width(row, col);
175 175
176 p.fillRect(x + 1, y + 1, 176 p.fillRect(x + 1, y + 1,
177 keyWidth * defaultKeyWidth - 1, keyHeight - 1, 177 keyWidth * defaultKeyWidth - 1, keyHeight - 1,
178 pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor); 178 pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor);
179 179
180 QPixmap *pix = keys->pix(row,col); 180 QPixmap *pix = keys->pix(row,col);
181 181
182 ushort c = keys->uni(row, col); 182 ushort c = keys->uni(row, col);
183 183
184 p.setPen(textcolor); 184 p.setPen(textcolor);
185 if (!pix) 185 if (!pix) {
186 if (shift || lock)
187 c = keys->shift(c);
188 if (meta) {
189
190 c = keys->meta(c);
191 }
186 p.drawText(x, y, 192 p.drawText(x, y,
187 defaultKeyWidth * keyWidth, keyHeight, 193 defaultKeyWidth * keyWidth + 3, keyHeight,
188 AlignCenter, ((shift || lock) && keys->shift(c)) ? (QChar)keys->shift(c) : (QChar)c); 194 AlignCenter, (QChar)c);
195 }
189 else 196 else
190 // center the image in the middle of the key 197 // center the image in the middle of the key
191 p.drawPixmap( x + (defaultKeyWidth * keyWidth - pix->width())/2, 198 p.drawPixmap( x + (defaultKeyWidth * keyWidth - pix->width())/2,
192 y + (keyHeight - pix->height())/2 + 1, 199 y + (keyHeight - pix->height())/2 + 1,
193 *pix ); 200 *pix );
194 201
195 // this fixes the problem that the very right end of the board's vertical line 202 // this fixes the problem that the very right end of the board's vertical line
196 // gets painted over, because it's one pixel shorter than all other keys 203 // gets painted over, because it's one pixel shorter than all other keys
197 p.setPen(keycolor_lines); 204 p.setPen(keycolor_lines);
198 p.drawLine(width() - 1, 0, width() - 1, height()); 205 p.drawLine(width() - 1, 0, width() - 1, height());
199 206
200 } else { 207 } else {
201 208
202 209
203 p.fillRect(0, 0, width(), height(), keycolor); 210 p.fillRect(0, 0, width(), height(), keycolor);
204 211
205 for (row = 1; row <= 5; row++) { 212 for (row = 1; row <= 5; row++) {
206 213
207 int x = 0; 214 int x = 0;
208 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); 215 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0);
209 216
210 p.setPen(keycolor_lines); 217 p.setPen(keycolor_lines);
211 p.drawLine(x, y, x + width(), y); 218 p.drawLine(x, y, x + width(), y);
212 219
213 for (int col = 0; col < keys->numKeys(row); col++) { 220 for (int col = 0; col < keys->numKeys(row); col++) {
214 221
215 QPixmap *pix = keys->pix(row, col); 222 QPixmap *pix = keys->pix(row, col);
216 int keyWidth = keys->width(row, col); 223 int keyWidth = keys->width(row, col);
217 224
218 225
219 int keyWidthPix = defaultKeyWidth * keyWidth; 226 int keyWidthPix = defaultKeyWidth * keyWidth;
220 227
221 if (keys->pressed(row, col)) 228 if (keys->pressed(row, col))
222 p.fillRect(x+1, y+1, keyWidthPix - 1, 229 p.fillRect(x+1, y+1, keyWidthPix - 1,
223 keyHeight - 1, keycolor_pressed); 230 keyHeight - 1, keycolor_pressed);
224 231
225 ushort c = keys->uni(row, col); 232 ushort c = keys->uni(row, col);
226 233
227 if (!pix) { 234 if (!pix) {
228 p.setPen(textcolor); 235 if ((shift || lock) && keys->shift(c))
236 c = keys->shift(c);
237 else if (meta && keys->meta(c))
238 c = keys->meta(c);
239
229 p.drawText(x, y, 240 p.drawText(x, y,
230 keyWidthPix, keyHeight, 241 defaultKeyWidth * keyWidth + 3, keyHeight,
231 AlignCenter, ((shift || lock) && keys->shift(c)) ? (QChar)keys->shift(c) : (QChar)c); 242 AlignCenter, (QChar)c);
232 } 243 }
233 else { 244 else {
234 // center the image in the middle of the key 245 // center the image in the middle of the key
235 p.drawPixmap( x + (keyWidthPix - pix->width())/2, 246 p.drawPixmap( x + (keyWidthPix - pix->width())/2,
236 y + (keyHeight - pix->height())/2 + 1, 247 y + (keyHeight - pix->height())/2 + 1,
237 QPixmap(*pix) ); 248 QPixmap(*pix) );
238 } 249 }
239 250
240 p.setPen(keycolor_lines); 251 p.setPen(keycolor_lines);
241 p.drawLine(x, y, x, y + keyHeight); 252 p.drawLine(x, y, x, y + keyHeight);
242 253
243 x += keyWidthPix; 254 x += keyWidthPix;
244 } 255 }
245 256
246 257
247 } 258 }
248 p.drawLine(0, height() - 1, width(), height() - 1); 259 p.drawLine(0, height() - 1, width(), height() - 1);
249 p.drawLine(width() - 1, 0, width() - 1, height()); 260 p.drawLine(width() - 1, 0, width() - 1, height());
250 } 261 }
251 262
252} 263}
253 264
254 265
255/* Keyboard::mousePressEvent {{{1 */ 266/* Keyboard::mousePressEvent {{{1 */
256void Keyboard::mousePressEvent(QMouseEvent *e) 267void Keyboard::mousePressEvent(QMouseEvent *e)
257{ 268{
258 int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1; 269 int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1;
259 if (row > 5) row = 5; 270 if (row > 5) row = 5;
260 271
261 // figure out the column 272 // figure out the column
262 int col = 0; 273 int col = 0;
263 for (int w = 0; e->x() >= w; col++) 274 for (int w = 0; e->x() >= w; col++)
264 if (col < keys->numKeys(row)) // it segfaults if it trys to read past numKeys 275 if (col < keys->numKeys(row)) // it segfaults if it trys to read past numKeys
265 w += keys->width(row,col) * defaultKeyWidth; 276 w += keys->width(row,col) * defaultKeyWidth;
266 else break; 277 else break;
267 278
268 if (col <= 0) return; 279 if (col <= 0) return;
269 280
270 col --; // rewind one... 281 col --; // rewind one...
271 282
272 qkeycode = keys->qcode(row, col); 283 qkeycode = keys->qcode(row, col);
273 unicode = keys->uni(row, col); 284 unicode = keys->uni(row, col);
274 285
275 // might need to repaint if two or more of the same keys. 286 // might need to repaint if two or more of the same keys.
276 // should be faster if just paint one key even though multiple keys exist. 287 // should be faster if just paint one key even though multiple keys exist.
277 bool need_repaint = FALSE; 288 bool need_repaint = FALSE;
278 289
279 if (unicode == 0) { // either Qt char, or nothing 290 if (unicode == 0) { // either Qt char, or nothing
280 291
281 if (qkeycode == Qt::Key_F1) { // toggle the pickboard 292 if (qkeycode == Qt::Key_F1) { // toggle the pickboard
282 293
283 if ( configdlg ) { 294 if ( configdlg ) {
284 delete (ConfigDlg *) configdlg; 295 delete (ConfigDlg *) configdlg;
285 configdlg = 0; 296 configdlg = 0;
286 } 297 }
287 else { 298 else {
288 configdlg = new ConfigDlg (); 299 configdlg = new ConfigDlg ();
289 connect(configdlg, SIGNAL(setMapToDefault()), 300 connect(configdlg, SIGNAL(setMapToDefault()),
290 this, SLOT(setMapToDefault())); 301 this, SLOT(setMapToDefault()));
291 connect(configdlg, SIGNAL(setMapToFile(QString)), 302 connect(configdlg, SIGNAL(setMapToFile(QString)),
292 this, SLOT(setMapToFile(QString))); 303 this, SLOT(setMapToFile(QString)));
293 connect(configdlg, SIGNAL(pickboardToggled(bool)), 304 connect(configdlg, SIGNAL(pickboardToggled(bool)),
294 this, SLOT(togglePickboard(bool))); 305 this, SLOT(togglePickboard(bool)));
295 connect(configdlg, SIGNAL(repeatToggled(bool)), 306 connect(configdlg, SIGNAL(repeatToggled(bool)),
296 this, SLOT(toggleRepeat(bool))); 307 this, SLOT(toggleRepeat(bool)));
297 connect(configdlg, SIGNAL(reloadKeyboard()), 308 connect(configdlg, SIGNAL(reloadKeyboard()),
298 this, SLOT(reloadKeyboard())); 309 this, SLOT(reloadKeyboard()));
299 configdlg->showMaximized(); 310 configdlg->showMaximized();
300 configdlg->show(); 311 configdlg->show();
301 configdlg->raise(); 312 configdlg->raise();
302 } 313 }
303 314
304 } else if (qkeycode == Qt::Key_Control) { 315 } else if (qkeycode == Qt::Key_Control) {
305 316
306 if (ctrl) { 317 if (ctrl) {
307 318
308 *ctrl = 0; 319 *ctrl = 0;
309 ctrl = 0; 320 ctrl = 0;
310 321
311 } else { 322 } else {
312 323
313 ctrl = keys->pressedPtr(row, col); 324 ctrl = keys->pressedPtr(row, col);
314 need_repaint = TRUE; 325 need_repaint = TRUE;
315 *ctrl = !keys->pressed(row, col); 326 *ctrl = !keys->pressed(row, col);
316 327
317 } 328 }
318 329
319 } else if (qkeycode == Qt::Key_Alt) { 330 } else if (qkeycode == Qt::Key_Alt) {
320 331
321 if (alt) { 332 if (alt) {
322 *alt = 0; 333 *alt = 0;
323 alt = 0; 334 alt = 0;
324 335
325 } else { 336 } else {
326 337
327 alt = keys->pressedPtr(row, col); 338 alt = keys->pressedPtr(row, col);
328 need_repaint = TRUE; 339 need_repaint = TRUE;
329 *alt = !keys->pressed(row, col); 340 *alt = !keys->pressed(row, col);
330 } 341 }
331 342
332 } else if (qkeycode == Qt::Key_Shift) { 343 } else if (qkeycode == Qt::Key_Shift) {
333 need_repaint = TRUE; 344 need_repaint = TRUE;
334 345
335 if (shift) { 346 if (shift) {
336 *shift = 0; 347 *shift = 0;
337 shift = 0; 348 shift = 0;
338 } 349 }
339 else { 350 else {
340 shift = keys->pressedPtr(row, col); 351 shift = keys->pressedPtr(row, col);
341 *shift = 1; 352 *shift = 1;
342 if (lock) { 353 if (lock) {
343 *lock = 0; 354 *lock = 0;
344 lock = 0; 355 lock = 0;
345 } 356 }
346 } 357 }
358 if (meta) {
359
360 *meta = 0;
361 meta = 0;
362 }
347 363
348 } else if (qkeycode == Qt::Key_CapsLock) { 364 } else if (qkeycode == Qt::Key_CapsLock) {
349 need_repaint = TRUE; 365 need_repaint = TRUE;
350 366
351 if (lock) { 367 if (lock) {
352 *lock = 0; 368 *lock = 0;
353 lock = 0; 369 lock = 0;
354 } 370 }
355 else { 371 else {
356 lock = keys->pressedPtr(row, col);; 372 lock = keys->pressedPtr(row, col);;
357 *lock = 1; 373 *lock = 1;
358 if (shift) { 374 if (shift) {
359 *shift = 0; 375 *shift = 0;
360 shift = 0; 376 shift = 0;
361 } 377 }
362 } 378 }
379 if (meta) {
380
381 *meta = 0;
382 meta = 0;
383 }
384
385 } else if (qkeycode == Qt::Key_Meta) {
386 need_repaint = TRUE;
387
388 if (meta) {
389 *meta = 0;
390 meta = 0;
391
392 } else {
393
394 meta = keys->pressedPtr(row, col);
395 need_repaint = TRUE;
396 *meta = !keys->pressed(row, col);
397 }
398
399 if (shift) {
400
401 *shift = 0;
402 shift = 0;
403
404 }
405 if (lock) {
406
407 *lock = 0;
408 lock = 0;
409
410 }
363 411
412 // dont need to emit this key... acts same as alt
413 qkeycode = 0;
364 } 414 }
365 415
366 } 416 }
367 else { // normal char 417 else { // normal char
368 if ((shift || lock) && keys->shift(unicode)) { 418 if ((shift || lock) && keys->shift(unicode)) {
369 unicode = keys->shift(unicode); 419 unicode = keys->shift(unicode);
370 } 420 }
421 if (meta && keys->meta(unicode)) {
422 unicode = keys->meta(unicode);
423 }
371 } 424 }
372 425
373 // korean parsing 426 // korean parsing
374 if (keys->lang == "ko") { 427 if (keys->lang == "ko") {
375 428
376 unicode = parseKoreanInput(unicode); 429 unicode = parseKoreanInput(unicode);
377 } 430 }
378 431
379 modifiers = (ctrl ? Qt::ControlButton : 0) | (alt ? Qt::AltButton : 0); 432 modifiers = (ctrl ? Qt::ControlButton : 0) | (alt ? Qt::AltButton : 0);
380 433
381 if ('A' <= unicode && unicode <= 'z' && modifiers) { 434 if ('A' <= unicode && unicode <= 'z' && modifiers) {
382 435
383 qkeycode = QChar(unicode).upper(); 436 qkeycode = QChar(unicode).upper();
384 unicode = qkeycode - '@'; 437 unicode = qkeycode - '@';
385 } 438 }
386 439
387 QWSServer::sendKeyEvent(unicode, qkeycode, modifiers, true, false); 440 QWSServer::sendKeyEvent(unicode, qkeycode, modifiers, true, false);
388 441
389 // pickboard stuff 442 // pickboard stuff
390 if (usePicks) { 443 if (usePicks) {
391 444
392 KeyboardConfig *dc = picks->dc; 445 KeyboardConfig *dc = picks->dc;
393 446
394 if (dc) { 447 if (dc) {
395 if (qkeycode == Qt::Key_Backspace) { 448 if (qkeycode == Qt::Key_Backspace) {
396 dc->input.remove(dc->input.last()); // remove last input 449 dc->input.remove(dc->input.last()); // remove last input
397 dc->decBackspaces(); 450 dc->decBackspaces();
398 } else if ( qkeycode == Qt::Key_Return || QChar(unicode).isPunct() || QChar(unicode).isSpace() || unicode == 0) { 451 } else if ( qkeycode == Qt::Key_Return || QChar(unicode).isPunct() || QChar(unicode).isSpace() || unicode == 0) {
399 dc->input.clear(); 452 dc->input.clear();
400 dc->resetBackspaces(); 453 dc->resetBackspaces();
401 } else { 454 } else {
402 dc->add(QString(QChar(unicode))); 455 dc->add(QString(QChar(unicode)));
403 dc->incBackspaces(); 456 dc->incBackspaces();
404 } 457 }
405 } 458 }
406 picks->repaint(); 459 picks->repaint();
407 } 460 }
408 461
409 462
410 // painting 463 // painting
411 pressed = TRUE; 464 pressed = TRUE;
412 465
413 pressedKeyRow = row; 466 pressedKeyRow = row;
414 pressedKeyCol = col; 467 pressedKeyCol = col;
415 468
416 if (need_repaint) repaint(FALSE); 469 if (need_repaint) repaint(FALSE);
417 else { // just paint the one key pressed 470 else { // just paint the one key pressed
418 471
419 472
420 473
421 QPainter p(this); 474 QPainter p(this);
422 drawKeyboard(p, row, col); 475 drawKeyboard(p, row, col);
423 476
424 } 477 }
425 478
426 if (useRepeat) repeatTimer->start( 800 ); 479 if (useRepeat) repeatTimer->start( 800 );
427 //pressTid = startTimer(80); 480 //pressTid = startTimer(80);
428 481
429} 482}
430 483
431 484
432/* Keyboard::mouseReleaseEvent {{{1 */ 485/* Keyboard::mouseReleaseEvent {{{1 */
433void Keyboard::mouseReleaseEvent(QMouseEvent*) 486void Keyboard::mouseReleaseEvent(QMouseEvent*)
434{ 487{
435 pressed = FALSE; 488 pressed = FALSE;
436 //if ( pressTid == 0 ) 489 //if ( pressTid == 0 )
437#if defined(Q_WS_QWS) || defined(_WS_QWS_) 490#if defined(Q_WS_QWS) || defined(_WS_QWS_)
438 if ( unicode != -1 ) { 491 if ( unicode != -1 ) {
439 emit key( unicode, qkeycode, modifiers, false, false ); 492 emit key( unicode, qkeycode, modifiers, false, false );
440 repeatTimer->stop(); 493 repeatTimer->stop();
441 } 494 }
442#endif 495#endif
443 if (shift && unicode != 0) { 496 if (shift && unicode != 0) {
444 497
445 498
446 *shift = 0; // unpress shift key 499 *shift = 0; // unpress shift key
447 shift = 0; // reset the shift pointer 500 shift = 0; // reset the shift pointer
448 repaint(FALSE); 501 repaint(FALSE);
449 502
503 } else if (meta && unicode != 0) {
504
505 *meta = 0;
506 meta = 0;
507 repaint(FALSE);
450 } 508 }
451 else 509 else
452 510
453 clearHighlight(); 511 clearHighlight();
454} 512}
455 513
456/* Keyboard::timerEvent {{{1 */ 514/* Keyboard::timerEvent {{{1 */
457 515
458/* dont know what this does, but i think it is here so that if your screen 516/* dont know what this does, but i think it is here so that if your screen
459 * sticks (like on an ipaq) then it will stop repeating if you click another 517 * sticks (like on an ipaq) then it will stop repeating if you click another
460 * key... but who knows what anything does in this thing anyway? 518 * key... but who knows what anything does in this thing anyway?
461 519
462 void Keyboard::timerEvent(QTimerEvent* e) 520 void Keyboard::timerEvent(QTimerEvent* e)
463{ 521{
464 if ( e->timerId() == pressTid ) { 522 if ( e->timerId() == pressTid ) {
465 killTimer(pressTid); 523 killTimer(pressTid);
466 pressTid = 0; 524 pressTid = 0;
467 if ( !pressed ) 525 if ( !pressed )
468 cout << "calling clearHighlight from timerEvent\n"; 526 cout << "calling clearHighlight from timerEvent\n";
469 //clearHighlight(); 527 //clearHighlight();
470 } 528 }
471} 529}
472*/ 530*/
473 531
474void Keyboard::repeat() 532void Keyboard::repeat()
475{ 533{
476 534
477 repeatTimer->start( 200 ); 535 repeatTimer->start( 200 );
478 emit key( unicode, qkeycode, modifiers, true, true ); 536 emit key( unicode, qkeycode, modifiers, true, true );
479} 537}
480 538
481void Keyboard::clearHighlight() 539void Keyboard::clearHighlight()
482{ 540{
483 if ( pressedKeyRow >= 0 && pressedKeyCol >= 0) { 541 if ( pressedKeyRow >= 0 && pressedKeyCol >= 0) {
484 int tmpRow = pressedKeyRow; 542 int tmpRow = pressedKeyRow;
485 int tmpCol = pressedKeyCol; 543 int tmpCol = pressedKeyCol;
486 544
487 pressedKeyRow = -1; 545 pressedKeyRow = -1;
488 pressedKeyCol = -1; 546 pressedKeyCol = -1;
489 547
490 QPainter p(this); 548 QPainter p(this);
491 drawKeyboard(p, tmpRow, tmpCol); 549 drawKeyboard(p, tmpRow, tmpCol);
492 } 550 }
493} 551}
494 552
495 553
496/* Keyboard::sizeHint {{{1 */ 554/* Keyboard::sizeHint {{{1 */
497QSize Keyboard::sizeHint() const 555QSize Keyboard::sizeHint() const
498{ 556{
499 QFontMetrics fm=fontMetrics(); 557 QFontMetrics fm=fontMetrics();
500 int keyHeight = fm.lineSpacing() + 2; 558 int keyHeight = fm.lineSpacing() + 2;
501 559
502 return QSize( 240, keyHeight * 5 + (usePicks ? picks->sizeHint().height() : 0) + 1); 560 return QSize( 240, keyHeight * 5 + (usePicks ? picks->sizeHint().height() : 0) + 1);
503} 561}
504 562
505 563
506void Keyboard::resetState() 564void Keyboard::resetState()
507{ 565{
508 schar = mchar = echar = 0; 566 schar = mchar = echar = 0;
509 picks->resetState(); 567 picks->resetState();
510} 568}
511 569
512/* Keyboard::togglePickboard {{{1 */ 570/* Keyboard::togglePickboard {{{1 */
513void Keyboard::togglePickboard(bool on_off) 571void Keyboard::togglePickboard(bool on_off)
514{ 572{
515 usePicks = on_off; 573 usePicks = on_off;
516 if (usePicks) { 574 if (usePicks) {
517 picks->show(); 575 picks->show();
518 //move(x(), y() - picks->height()); // not required anymore because QCopChannel::send 576 //move(x(), y() - picks->height()); // not required anymore because QCopChannel::send
519 //adjustSize(); 577 //adjustSize();
520 QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), 578 QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ),
521 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); 579 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) );
522 } else { 580 } else {
523 581
524 picks->hide(); 582 picks->hide();
525 picks->resetState(); 583 picks->resetState();
526 //move(x(), y() + picks->height()); 584 //move(x(), y() + picks->height());
527 //adjustSize(); 585 //adjustSize();
528 QObject::disconnect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), 586 QObject::disconnect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ),
529 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); 587 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) );
530 588
531 } 589 }
532 /* 590 /*
533 * this closes && opens the input method 591 * this closes && opens the input method
534 */ 592 */
535 QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); 593 QCopChannel::send ("QPE/TaskBar", "hideInputMethod()");
536 QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); 594 QCopChannel::send ("QPE/TaskBar", "showInputMethod()");
537} 595}
538 596
539void Keyboard::toggleRepeat(bool on) { 597void Keyboard::toggleRepeat(bool on) {
540 598
541 useRepeat = on; 599 useRepeat = on;
542 cout << "setting useRepeat to: " << useRepeat << "\n"; 600 cout << "setting useRepeat to: " << useRepeat << "\n";
543} 601}
544 602
545/* Keyboard::setMapTo ... {{{1 */ 603/* Keyboard::setMapTo ... {{{1 */
546void Keyboard::setMapToDefault() { 604void Keyboard::setMapToDefault() {
547 605
548 606
549 /* load current locale language map */ 607 /* load current locale language map */
550 Config *config = new Config("locale"); 608 Config *config = new Config("locale");
551 config->setGroup( "Language" ); 609 config->setGroup( "Language" );
552 QString l = config->readEntry( "Language" , "en" ); 610 QString l = config->readEntry( "Language" , "en" );
553 delete config; 611 delete config;
554 612
555 QString key_map = QPEApplication::qpeDir() + "/share/multikey/" 613 QString key_map = QPEApplication::qpeDir() + "/share/multikey/"
556 + l + ".keymap"; 614 + l + ".keymap";
557 615
558 /* save change to multikey config file */ 616 /* save change to multikey config file */
559 config = new Config("multikey"); 617 config = new Config("multikey");
560 config->setGroup ("keymaps"); 618 config->setGroup ("keymaps");
561 config->writeEntry ("current", key_map); // default closed 619 config->writeEntry ("current", key_map); // default closed
562 delete config; 620 delete config;
563 621
564 delete keys; 622 delete keys;
565 keys = new Keys(key_map); 623 keys = new Keys(key_map);
566 624
567 // have to repaint the keyboard 625 // have to repaint the keyboard
568 repaint(FALSE); 626 repaint(FALSE);
569} 627}
570 628
571void Keyboard::setMapToFile(QString map) { 629void Keyboard::setMapToFile(QString map) {
572 630
573 /* save change to multikey config file */ 631 /* save change to multikey config file */
574 Config *config = new Config("multikey"); 632 Config *config = new Config("multikey");
575 config->setGroup ("keymaps"); 633 config->setGroup ("keymaps");
576 config->writeEntry ("current", map); // default closed 634 config->writeEntry ("current", map); // default closed
577 635
578 delete config; 636 delete config;
579 637
580 delete keys; 638 delete keys;
581 if (QFile(map).exists()) 639 if (QFile(map).exists())
582 keys = new Keys(map); 640 keys = new Keys(map);
583 else 641 else
584 keys = new Keys(); 642 keys = new Keys();
585 643
586 repaint(FALSE); 644 repaint(FALSE);
587 645
588} 646}
589 647
590/* Keybaord::reloadKeyboard {{{1 */ 648/* Keybaord::reloadKeyboard {{{1 */
591void Keyboard::reloadKeyboard() { 649void Keyboard::reloadKeyboard() {
592 650
593 // reload colors and redraw 651 // reload colors and redraw
594 loadKeyboardColors(); 652 loadKeyboardColors();
595 repaint(); 653 repaint();
596 654
597} 655}
598 656
599void Keyboard::loadKeyboardColors() { 657void Keyboard::loadKeyboardColors() {
600 658
601 Config config ("multikey"); 659 Config config ("multikey");
602 config.setGroup("colors"); 660 config.setGroup("colors");
603 661
604 QStringList color; 662 QStringList color;
605 color = config.readListEntry("keycolor", QChar(',')); 663 color = config.readListEntry("keycolor", QChar(','));
606 if (color.isEmpty()) { 664 if (color.isEmpty()) {
607 color = QStringList::split(",", "240,240,240"); 665 color = QStringList::split(",", "240,240,240");
608 config.writeEntry("keycolor", color.join(",")); 666 config.writeEntry("keycolor", color.join(","));
609 667
610 } 668 }
611 keycolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); 669 keycolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt());
612 670
613 color = config.readListEntry("keycolor_pressed", QChar(',')); 671 color = config.readListEntry("keycolor_pressed", QChar(','));
614 if (color.isEmpty()) { 672 if (color.isEmpty()) {
615 color = QStringList::split(",", "171,183,198"); 673 color = QStringList::split(",", "171,183,198");
616 config.writeEntry("keycolor_pressed", color.join(",")); 674 config.writeEntry("keycolor_pressed", color.join(","));
617 675
618 } 676 }
619 keycolor_pressed = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); 677 keycolor_pressed = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt());
620 678
621 color = config.readListEntry("keycolor_lines", QChar(',')); 679 color = config.readListEntry("keycolor_lines", QChar(','));
622 if (color.isEmpty()) { 680 if (color.isEmpty()) {
623 color = QStringList::split(",", "138,148,160"); 681 color = QStringList::split(",", "138,148,160");
624 config.writeEntry("keycolor_lines", color.join(",")); 682 config.writeEntry("keycolor_lines", color.join(","));
625 683
626 } 684 }
627 keycolor_lines = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); 685 keycolor_lines = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt());
628 686
629 color = config.readListEntry("textcolor", QChar(',')); 687 color = config.readListEntry("textcolor", QChar(','));
630 if (color.isEmpty()) { 688 if (color.isEmpty()) {
631 color = QStringList::split(",", "43,54,68"); 689 color = QStringList::split(",", "43,54,68");
632 config.writeEntry("textcolor", color.join(",")); 690 config.writeEntry("textcolor", color.join(","));
633 691
634 } 692 }
635 textcolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); 693 textcolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt());
636 694
637} 695}
638 696
639/* korean input functions {{{1 697/* korean input functions {{{1
640 * 698 *
641 * TODO 699 * TODO
642 * one major problem with this implementation is that you can't move the 700 * one major problem with this implementation is that you can't move the
643 * cursor after inputing korean chars, otherwise it will eat up and replace 701 * cursor after inputing korean chars, otherwise it will eat up and replace
644 * the char before the cursor you move to. fix that 702 * the char before the cursor you move to. fix that
645 * 703 *
646 * make backspace delete one single char, not the whole thing if still 704 * make backspace delete one single char, not the whole thing if still
647 * editing. 705 * editing.
648 * 706 *
649 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 707 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
650 * 708 *
651 * how korean input works 709 * how korean input works
652 * 710 *
653 * all following chars means unicode char value and are in hex 711 * all following chars means unicode char value and are in hex
654 * 712 *
655 * ÃÊÀ½ = schar (start char) 713 * ÃÊÀ½ = schar (start char)
656 * ÁßÀ½ = mchar (middle char) 714 * ÁßÀ½ = mchar (middle char)
657 * ³¡À½ = echar (end char) 715 * ³¡À½ = echar (end char)
658 * 716 *
659 * there are 19 schars. unicode position is at 1100 - 1112 717 * there are 19 schars. unicode position is at 1100 - 1112
660 * there are 21 mchars. unicode position is at 1161 - 1175 718 * there are 21 mchars. unicode position is at 1161 - 1175
661 * there are 27 echars. unicode position is at 11a8 - 11c2 719 * there are 27 echars. unicode position is at 11a8 - 11c2
662 * 720 *
663 * the map with everything combined is at ac00 - d7a3 721 * the map with everything combined is at ac00 - d7a3
664 * 722 *
665 */ 723 */
666 724
667ushort Keyboard::parseKoreanInput (ushort c) { 725ushort Keyboard::parseKoreanInput (ushort c) {
668 726
669 if ((c != 0 && (c < 0x1100 || 0x11c2 < c) && (c < 0xac00 || 0xd7a3 < c)) 727 if ((c != 0 && (c < 0x1100 || 0x11c2 < c) && (c < 0xac00 || 0xd7a3 < c))
670 || 728 ||
671 (c == 0 && qkeycode != Qt::Key_Shift && Qt::Key_CapsLock != qkeycode 729 (c == 0 && qkeycode != Qt::Key_Shift && Qt::Key_CapsLock != qkeycode
672 && qkeycode != Qt::Key_Control && qkeycode != Qt::Key_Alt)) { 730 && qkeycode != Qt::Key_Control && qkeycode != Qt::Key_Alt)) {
673 731
674 schar = 0, mchar = 0, echar = 0; 732 schar = 0, mchar = 0, echar = 0;
675 return c; 733 return c;
676 } 734 }
677 735
678 if ( 0x1100 <= c && c <= 0x1112 ) { // schar or echar was input 736 if ( 0x1100 <= c && c <= 0x1112 ) { // schar or echar was input
679 737
680 if (schar == 0 || (schar != 0 && mchar == 0)) { 738 if (schar == 0 || (schar != 0 && mchar == 0)) {
681 schar = c; mchar = 0; echar = 0; 739 schar = c; mchar = 0; echar = 0;
682 return c; 740 return c;
683 } 741 }
684 else if (mchar != 0) { 742 else if (mchar != 0) {
685 743
686 if (echar == 0) { 744 if (echar == 0) {
687 745
688 if (!(echar = constoe(c))) { 746 if (!(echar = constoe(c))) {
689 747
690 schar = c; mchar = 0; echar = 0; 748 schar = c; mchar = 0; echar = 0;
691 return c; 749 return c;
692 } 750 }
693 751
694 } 752 }
695 else { // must figure out what the echar is 753 else { // must figure out what the echar is
696 754
697 if (echar == 0x11a8) { // ¤¡ 755 if (echar == 0x11a8) { // ¤¡
698 756
699 if (c == 0x1100) echar = 0x11a9; // ¤¡ + ¤¡ 757 if (c == 0x1100) echar = 0x11a9; // ¤¡ + ¤¡
700 else if (c == 0x1109) echar = 0x11aa; // ¤¡ + ¤µ 758 else if (c == 0x1109) echar = 0x11aa; // ¤¡ + ¤µ
701 else { 759 else {
702 schar = c; mchar = 0; echar = 0; 760 schar = c; mchar = 0; echar = 0;
703 return c; 761 return c;
704 } 762 }
705 763
706 } else if (echar == 0x11ab) { // ¤¤ 764 } else if (echar == 0x11ab) { // ¤¤
707 765
708 if (c == 0x110c) echar = 0x11ac; // ¤¤ + ¤¸ 766 if (c == 0x110c) echar = 0x11ac; // ¤¤ + ¤¸
709 else if (c == 0x1112) echar = 0x11ad; // ¤¤ + ¤¾ 767 else if (c == 0x1112) echar = 0x11ad; // ¤¤ + ¤¾
710 else { 768 else {
711 schar = c; mchar = 0; echar = 0; 769 schar = c; mchar = 0; echar = 0;
712 return c; 770 return c;
713 } 771 }
714 772
715 } else if (echar == 0x11af) { // ¤© 773 } else if (echar == 0x11af) { // ¤©
716 774
717 if (c == 0x1100) echar = 0x11b0; // ¤© + ¤¡ 775 if (c == 0x1100) echar = 0x11b0; // ¤© + ¤¡
718 else if (c == 0x1106) echar = 0x11b1; // ¤© + ¤± 776 else if (c == 0x1106) echar = 0x11b1; // ¤© + ¤±
719 else if (c == 0x1107) echar = 0x11b2; // ¤© + ¤² 777 else if (c == 0x1107) echar = 0x11b2; // ¤© + ¤²
720 else if (c == 0x1109) echar = 0x11b3; // ¤© + ¤µ 778 else if (c == 0x1109) echar = 0x11b3; // ¤© + ¤µ
721 else if (c == 0x1110) echar = 0x11b4; // ¤© + ¤¼ 779 else if (c == 0x1110) echar = 0x11b4; // ¤© + ¤¼
722 else if (c == 0x1111) echar = 0x11b5; // ¤© + ¤½ 780 else if (c == 0x1111) echar = 0x11b5; // ¤© + ¤½
723 else if (c == 0x1112) echar = 0x11b6; // ¤© + ¤¾ 781 else if (c == 0x1112) echar = 0x11b6; // ¤© + ¤¾
724 else { 782 else {
725 schar = c; mchar = 0; echar = 0; 783 schar = c; mchar = 0; echar = 0;
726 return c; 784 return c;
727 } 785 }
728 786
729 } else if (echar == 0x11b8) { // ¤² 787 } else if (echar == 0x11b8) { // ¤²
730 788
731 if (c == 0x1109) echar = 0x11b9; // ¤² + ¤µ 789 if (c == 0x1109) echar = 0x11b9; // ¤² + ¤µ
732 else { 790 else {
733 schar = c; mchar = 0; echar = 0; 791 schar = c; mchar = 0; echar = 0;
734 return c; 792 return c;
735 } 793 }
736 794
737 } else if (echar == 0x11ba) { // ¤µ 795 } else if (echar == 0x11ba) { // ¤µ
738 796
739 if (c == 0x1109) echar = 0x11bb; // ¤µ + ¤µ 797 if (c == 0x1109) echar = 0x11bb; // ¤µ + ¤µ
740 else { 798 else {
741 schar = c; mchar = 0; echar = 0; 799 schar = c; mchar = 0; echar = 0;
742 return c; 800 return c;
743 } 801 }
744 802
745 } else { // if any other char, cannot combine chars 803 } else { // if any other char, cannot combine chars
746 804
747 schar = c; mchar = 0; echar = 0; 805 schar = c; mchar = 0; echar = 0;
748 return c; 806 return c;
749 } 807 }
750 808
751 unicode = echar; 809 unicode = echar;
752 } 810 }
753 } 811 }
754 812
755 } 813 }
756 else if (0x1161 <= c && c <= 0x1175) { // mchar was input 814 else if (0x1161 <= c && c <= 0x1175) { // mchar was input
757 815
758 if (schar != 0 && mchar == 0) { mchar = c; } 816 if (schar != 0 && mchar == 0) { mchar = c; }
759 817
760 else if (schar != 0 && mchar != 0 && echar == 0) { 818 else if (schar != 0 && mchar != 0 && echar == 0) {
761 819
762 switch (mchar) { 820 switch (mchar) {
763 case 0x1169: 821 case 0x1169:
764 if (c == 0x1161) mchar = 0x116a; 822 if (c == 0x1161) mchar = 0x116a;
765 else if (c == 0x1162) mchar = 0x116b; 823 else if (c == 0x1162) mchar = 0x116b;
766 else if (c == 0x1175) mchar = 0x116c; 824 else if (c == 0x1175) mchar = 0x116c;
767 else { 825 else {
768 schar = 0; mchar = 0; echar = 0; 826 schar = 0; mchar = 0; echar = 0;
769 return c; 827 return c;
770 } 828 }
771 break; 829 break;
772 case 0x116e: 830 case 0x116e:
773 if (c == 0x1165) mchar = 0x116f; 831 if (c == 0x1165) mchar = 0x116f;
774 else if (c == 0x1166) mchar = 0x1170; 832 else if (c == 0x1166) mchar = 0x1170;
775 else if (c == 0x1175) mchar = 0x1171; 833 else if (c == 0x1175) mchar = 0x1171;
776 else { 834 else {
777 schar = 0; mchar = 0; echar = 0; 835 schar = 0; mchar = 0; echar = 0;
778 return c; 836 return c;
779 } 837 }
780 break; 838 break;
781 case 0x1173: 839 case 0x1173:
782 if (c == 0x1175) mchar = 0x1174; 840 if (c == 0x1175) mchar = 0x1174;
783 else { 841 else {
784 schar = 0; mchar = 0; echar = 0; 842 schar = 0; mchar = 0; echar = 0;
785 return c; 843 return c;
786 } 844 }
787 break; 845 break;
788 default: 846 default:
789 schar = 0; mchar = 0; echar = 0; 847 schar = 0; mchar = 0; echar = 0;
790 return c; 848 return c;
791 } 849 }
792 } 850 }
793 else if (schar != 0 && mchar != 0 && echar != 0) { 851 else if (schar != 0 && mchar != 0 && echar != 0) {
794 852
795 emit key( 8, Qt::Key_Backspace, 0, true, false ); 853 emit key( 8, Qt::Key_Backspace, 0, true, false );
796 854
797 ushort prev = 0; 855 ushort prev = 0;
798 switch (echar) { 856 switch (echar) {
799 /* 857 /*
800 case 0x11a9: 858 case 0x11a9:
801 prev = combineKoreanChars(schar, mchar, 0x11a8); 859 prev = combineKoreanChars(schar, mchar, 0x11a8);
802 schar = 0x1100; 860 schar = 0x1100;
803 break; 861 break;
804 */ 862 */
805 case 0x11aa: 863 case 0x11aa:
806 prev = combineKoreanChars(schar, mchar, 0x11a8); 864 prev = combineKoreanChars(schar, mchar, 0x11a8);
807 schar = 0x1109; 865 schar = 0x1109;
808 break; 866 break;
809 case 0x11ac: 867 case 0x11ac:
810 prev = combineKoreanChars(schar, mchar, 0x11ab); 868 prev = combineKoreanChars(schar, mchar, 0x11ab);
811 schar = 0x110c; 869 schar = 0x110c;
812 break; 870 break;
813 case 0x11ad: 871 case 0x11ad:
814 prev = combineKoreanChars(schar, mchar, 0x11ab); 872 prev = combineKoreanChars(schar, mchar, 0x11ab);
815 schar = 0x1112; 873 schar = 0x1112;
816 break; 874 break;
817 case 0x11b0: 875 case 0x11b0:
818 prev = combineKoreanChars(schar, mchar, 0x11af); 876 prev = combineKoreanChars(schar, mchar, 0x11af);
819 schar = 0x1100; 877 schar = 0x1100;
820 break; 878 break;
821 case 0x11b1: 879 case 0x11b1:
822 prev = combineKoreanChars(schar, mchar, 0x11af); 880 prev = combineKoreanChars(schar, mchar, 0x11af);
823 schar = 0x1106; 881 schar = 0x1106;
824 break; 882 break;
825 case 0x11b2: 883 case 0x11b2:
826 prev = combineKoreanChars(schar, mchar, 0x11af); 884 prev = combineKoreanChars(schar, mchar, 0x11af);
827 schar = 0x1107; 885 schar = 0x1107;
828 break; 886 break;
829 case 0x11b3: 887 case 0x11b3:
830 prev = combineKoreanChars(schar, mchar, 0x11af); 888 prev = combineKoreanChars(schar, mchar, 0x11af);
831 schar = 0x1109; 889 schar = 0x1109;
832 break; 890 break;
833 case 0x11b4: 891 case 0x11b4:
834 prev = combineKoreanChars(schar, mchar, 0x11af); 892 prev = combineKoreanChars(schar, mchar, 0x11af);
835 schar = 0x1110; 893 schar = 0x1110;
836 break; 894 break;
837 case 0x11b9: 895 case 0x11b9:
838 prev = combineKoreanChars(schar, mchar, 0x11b8); 896 prev = combineKoreanChars(schar, mchar, 0x11b8);
839 schar = 0x1109; 897 schar = 0x1109;
840 break; 898 break;
841 /* 899 /*
842 case 0x11bb: 900 case 0x11bb:
843 prev = combineKoreanChars(schar, mchar, 0x11ba); 901 prev = combineKoreanChars(schar, mchar, 0x11ba);
844 schar = 0x1109; 902 schar = 0x1109;
845 break; 903 break;
846 */ 904 */
847 default: 905 default:
848 906
849 if (constoe(echar)) { 907 if (constoe(echar)) {
850 908
851 prev = combineKoreanChars(schar, mchar, 0); 909 prev = combineKoreanChars(schar, mchar, 0);
852 schar = constoe(echar); 910 schar = constoe(echar);
853 } 911 }
854 break; 912 break;
855 } 913 }
856 914
857 emit key( prev, prev, 0, true, false ); 915 emit key( prev, prev, 0, true, false );
858 916
859 mchar = c; echar = 0; 917 mchar = c; echar = 0;
860 918
861 return combineKoreanChars(schar, mchar, 0); 919 return combineKoreanChars(schar, mchar, 0);
862 920
863 } 921 }
864 else { 922 else {
865 schar = 0; mchar = 0; echar = 0; 923 schar = 0; mchar = 0; echar = 0;
866 return c; 924 return c;
867 } 925 }
868 926
869 } 927 }
870 else /*if (c == ' ')*/ return c; 928 else /*if (c == ' ')*/ return c;
871 929
872 930
873 // and now... finally delete previous char, and return new char 931 // and now... finally delete previous char, and return new char
874 emit key( 8, Qt::Key_Backspace, 0, true, false ); 932 emit key( 8, Qt::Key_Backspace, 0, true, false );
875 933
876 934
877 return combineKoreanChars( schar, mchar, echar); 935 return combineKoreanChars( schar, mchar, echar);
878 936
879} 937}
880 938
881ushort Keyboard::combineKoreanChars(const ushort s, const ushort m, const ushort e) { 939ushort Keyboard::combineKoreanChars(const ushort s, const ushort m, const ushort e) {
882 940
883 return ((s - 0x1100) * 588) + ((m - 0x1161) * 28) + (e ? e - 0x11a7 : 0) + 0xac00; 941 return ((s - 0x1100) * 588) + ((m - 0x1161) * 28) + (e ? e - 0x11a7 : 0) + 0xac00;
884 942
885} 943}
886 944
887ushort Keyboard::constoe(const ushort c) { 945ushort Keyboard::constoe(const ushort c) {
888 946
889 // converts schars to echars if possible 947 // converts schars to echars if possible
890 948
891 if (0x1100 <= c && c <= 0x1112) { // schar to echar 949 if (0x1100 <= c && c <= 0x1112) { // schar to echar
892 950
893 switch (c) { 951 switch (c) {
894 case 0x1100: return 0x11a8; 952 case 0x1100: return 0x11a8;
895 case 0x1101: return 0x11a9; 953 case 0x1101: return 0x11a9;
896 case 0x1102: return 0x11ab; 954 case 0x1102: return 0x11ab;
897 case 0x1103: return 0x11ae; 955 case 0x1103: return 0x11ae;
898 case 0x1105: return 0x11af; 956 case 0x1105: return 0x11af;
899 case 0x1106: return 0x11b7; 957 case 0x1106: return 0x11b7;
900 case 0x1107: return 0x11b8; 958 case 0x1107: return 0x11b8;
901 case 0x1109: return 0x11ba; 959 case 0x1109: return 0x11ba;
902 case 0x110a: return 0x11bb; 960 case 0x110a: return 0x11bb;
903 case 0x110b: return 0x11bc; 961 case 0x110b: return 0x11bc;
904 case 0x110c: return 0x11bd; 962 case 0x110c: return 0x11bd;
905 case 0x110e: return 0x11be; 963 case 0x110e: return 0x11be;
906 case 0x110f: return 0x11bf; 964 case 0x110f: return 0x11bf;
907 case 0x1110: return 0x11c0; 965 case 0x1110: return 0x11c0;
908 case 0x1111: return 0x11c1; 966 case 0x1111: return 0x11c1;
909 case 0x1112: return 0x11c2; 967 case 0x1112: return 0x11c2;
910 default: return 0; 968 default: return 0;
911 969
912 } 970 }
913 971
914 } else { //echar to schar 972 } else { //echar to schar
915 973
916 switch (c) { 974 switch (c) {
917 case 0x11a8: return 0x1100; 975 case 0x11a8: return 0x1100;
918 case 0x11a9: return 0x1101; 976 case 0x11a9: return 0x1101;
919 case 0x11ab: return 0x1102; 977 case 0x11ab: return 0x1102;
920 case 0x11ae: return 0x1103; 978 case 0x11ae: return 0x1103;
921 case 0x11af: return 0x1105; 979 case 0x11af: return 0x1105;
922 case 0x11b7: return 0x1106; 980 case 0x11b7: return 0x1106;
923 case 0x11b8: return 0x1107; 981 case 0x11b8: return 0x1107;
924 case 0x11ba: return 0x1109; 982 case 0x11ba: return 0x1109;
925 case 0x11bb: return 0x110a; 983 case 0x11bb: return 0x110a;
926 case 0x11bc: return 0x110b; 984 case 0x11bc: return 0x110b;
927 case 0x11bd: return 0x110c; 985 case 0x11bd: return 0x110c;
928 case 0x11be: return 0x110e; 986 case 0x11be: return 0x110e;
929 case 0x11bf: return 0x110f; 987 case 0x11bf: return 0x110f;
930 case 0x11c0: return 0x1110; 988 case 0x11c0: return 0x1110;
931 case 0x11c1: return 0x1111; 989 case 0x11c1: return 0x1111;
932 case 0x11c2: return 0x1112; 990 case 0x11c2: return 0x1112;
933 default: return 0; 991 default: return 0;
934 992
935 } 993 }
936 994
937 } 995 }
938} 996}
939 997
940 998
941// Keys::Keys {{{1 999// Keys::Keys {{{1
942 1000
943Keys::Keys() { 1001Keys::Keys() {
944 1002
945 Config *config = new Config ("multikey"); 1003 Config *config = new Config ("multikey");
946 config->setGroup( "keymaps" ); 1004 config->setGroup( "keymaps" );
947 QString map = config->readEntry( "current" ); 1005 QString map = config->readEntry( "current" );
948 delete config; 1006 delete config;
949 1007
950 if (map.isNull() || !(QFile(map).exists())) { 1008 if (map.isNull() || !(QFile(map).exists())) {
951 1009
952 Config *config = new Config("locale"); 1010 Config *config = new Config("locale");
953 config->setGroup( "Language" ); 1011 config->setGroup( "Language" );
954 QString l = config->readEntry( "Language" , "en" ); 1012 QString l = config->readEntry( "Language" , "en" );
955 delete config; 1013 delete config;
956 1014
957 map = QPEApplication::qpeDir() + "/share/multikey/" 1015 map = QPEApplication::qpeDir() + "/share/multikey/"
958 + l + ".keymap"; 1016 + l + ".keymap";
959 1017
960 } 1018 }
961 1019
962 setKeysFromFile(map); 1020 setKeysFromFile(map);
963} 1021}
964 1022
965Keys::Keys(const char * filename) { 1023Keys::Keys(const char * filename) {
966 1024
967 setKeysFromFile(filename); 1025 setKeysFromFile(filename);
968} 1026}
969 1027
970// Keys::setKeysFromFile {{{2 1028// Keys::setKeysFromFile {{{2
971void Keys::setKeysFromFile(const char * filename) { 1029void Keys::setKeysFromFile(const char * filename) {
972 1030
973 QFile f(filename); 1031 QFile f(filename);
974 1032
975 if (f.open(IO_ReadOnly)) { 1033 if (f.open(IO_ReadOnly)) {
976 1034
977 QTextStream t(&f); 1035 QTextStream t(&f);
978 int row; 1036 int row;
979 int qcode; 1037 int qcode;
980 ushort unicode; 1038 ushort unicode;
981 int width; 1039 int width;
982 QString buf; 1040 QString buf;
983 QString comment; 1041 QString comment;
984 char * xpm[256]; //couldnt be larger than that... could it? 1042 char * xpm[256]; //couldnt be larger than that... could it?
985 QPixmap *xpm2pix = 0; 1043 QPixmap *xpm2pix = 0;
986 1044
987 buf = t.readLine(); 1045 buf = t.readLine();
988 while (buf) { 1046 while (buf) {
989 1047
990 // key definition 1048 // key definition
991 if (buf.contains(QRegExp("^\\d+\\s+[0-1a-fx]+", FALSE, FALSE))) { 1049 if (buf.contains(QRegExp("^\\d+\\s+[0-1a-fx]+", FALSE, FALSE))) {
992 // no $1 type referencing!!! this implementation of regexp sucks 1050 // no $1 type referencing!!! this implementation of regexp sucks
993 1051
994 // dont know of any sscanf() type funcs in Qt lib 1052 // dont know of any sscanf() type funcs in Qt lib
995 QTextStream tmp (buf, IO_ReadOnly); 1053 QTextStream tmp (buf, IO_ReadOnly);
996 tmp >> row >> qcode >> unicode >> width >> comment; 1054 tmp >> row >> qcode >> unicode >> width >> comment;
997 1055
998 buf = t.readLine(); 1056 buf = t.readLine();
999 int xpmLineCount = 0; 1057 int xpmLineCount = 0;
1000 xpm2pix = 0; 1058 xpm2pix = 0;
1001 1059
1002 // erase blank space 1060 // erase blank space
1003 while (buf.contains(QRegExp("^\\s*$")) && buf) buf = t.readLine(); 1061 while (buf.contains(QRegExp("^\\s*$")) && buf) buf = t.readLine();
1004 1062
1005 while (buf.contains(QRegExp("^\\s*\".*\""))) { 1063 while (buf.contains(QRegExp("^\\s*\".*\""))) {
1006 1064
1007 QString xpmBuf = buf.stripWhiteSpace(); 1065 QString xpmBuf = buf.stripWhiteSpace();
1008 1066
1009 xpm[xpmLineCount] = new char [xpmBuf.length()]; 1067 xpm[xpmLineCount] = new char [xpmBuf.length()];
1010 1068
1011 int j = 0; 1069 int j = 0;
1012 for (ushort i = 0; i < xpmBuf.length(); i++) { 1070 for (ushort i = 0; i < xpmBuf.length(); i++) {
1013 if (xpmBuf[i].latin1() != '"') { 1071 if (xpmBuf[i].latin1() != '"') {
1014 1072
1015 ((char *)xpm[xpmLineCount])[j] = xpmBuf.at(i).latin1(); 1073 ((char *)xpm[xpmLineCount])[j] = xpmBuf.at(i).latin1();
1016 j++; 1074 j++;
1017 } 1075 }
1018 1076
1019 } 1077 }
1020 // have to close that facker up 1078 // have to close that facker up
1021 ((char *)xpm[xpmLineCount])[j] = '\0'; 1079 ((char *)xpm[xpmLineCount])[j] = '\0';
1022 1080
1023 xpmLineCount++; 1081 xpmLineCount++;
1024 buf = t.readLine(); 1082 buf = t.readLine();
1025 } 1083 }
1026 if (xpmLineCount) { 1084 if (xpmLineCount) {
1027 1085
1028 xpm2pix = new QPixmap((const char **)xpm); 1086 xpm2pix = new QPixmap((const char **)xpm);
1029 for (int i = 0; i < xpmLineCount; i++) 1087 for (int i = 0; i < xpmLineCount; i++)
1030 1088
1031 delete [] (xpm[i]); 1089 delete [] (xpm[i]);
1032 1090
1033 } 1091 }
1034 setKey(row, qcode, unicode, width, xpm2pix); 1092 setKey(row, qcode, unicode, width, xpm2pix);
1035 } 1093 }
1036 1094
1037 // shift map 1095 // shift map
1038 else if (buf.contains(QRegExp("^[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { 1096 else if (buf.contains(QRegExp("^[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) {
1039 1097
1040 QTextStream tmp (buf, IO_ReadOnly); 1098 QTextStream tmp (buf, IO_ReadOnly);
1041 ushort lower, shift; 1099 ushort lower, shift;
1042 tmp >> lower >> shift; 1100 tmp >> lower >> shift;
1043 1101
1044 shiftMap.insert(lower, shift); 1102 shiftMap.insert(lower, shift);
1045 1103
1046 buf = t.readLine(); 1104 buf = t.readLine();
1047 } 1105 }
1048 1106
1107 // meta key map
1108 else if (buf.contains(QRegExp("^\\s*m\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) {
1109
1110 QTextStream tmp (buf, IO_ReadOnly);
1111 ushort lower, shift;
1112 QChar m;
1113 tmp >> m >> lower >> shift;
1114
1115 metaMap.insert(lower, shift);
1116
1117 buf = t.readLine();
1118 }
1119
1049 // other variables like lang & title 1120 // other variables like lang & title
1050 else if (buf.contains(QRegExp("^\\s*[a-zA-Z]+\\s*=\\s*[a-zA-Z0-9/]+\\s*$", FALSE, FALSE))) { 1121 else if (buf.contains(QRegExp("^\\s*[a-zA-Z]+\\s*=\\s*[a-zA-Z0-9/]+\\s*$", FALSE, FALSE))) {
1051 1122
1052 QTextStream tmp (buf, IO_ReadOnly); 1123 QTextStream tmp (buf, IO_ReadOnly);
1053 QString name, equals, value; 1124 QString name, equals, value;
1054 1125
1055 tmp >> name >> equals >> value; 1126 tmp >> name >> equals >> value;
1056 1127
1057 if (name == "lang") { 1128 if (name == "lang") {
1058 1129
1059 lang = value; 1130 lang = value;
1060 1131
1061 } 1132 }
1062 1133
1063 buf = t.readLine(); 1134 buf = t.readLine();
1064 } 1135 }
1065 // comments 1136 // comments
1066 else if (buf.contains(QRegExp("^\\s*#"))) { 1137 else if (buf.contains(QRegExp("^\\s*#"))) {
1067 1138
1068 buf = t.readLine(); 1139 buf = t.readLine();
1069 1140
1070 } else { // blank line, or garbage 1141 } else { // blank line, or garbage
1071 1142
1072 buf = t.readLine(); 1143 buf = t.readLine();
1073 1144
1074 } 1145 }
1075 1146
1076 } 1147 }
1077 f.close(); 1148 f.close();
1078 } 1149 }
1079 1150
1080} 1151}
1081 1152
1082// Keys::setKey {{{2 1153// Keys::setKey {{{2
1083void Keys::setKey(const int row, const int qcode, const ushort unicode, 1154void Keys::setKey(const int row, const int qcode, const ushort unicode,
1084 const int width, QPixmap *pix) { 1155 const int width, QPixmap *pix) {
1085 1156
1086 Key * key; 1157 Key * key;
1087 key = new Key; 1158 key = new Key;
1088 key->qcode = qcode; 1159 key->qcode = qcode;
1089 key->unicode = unicode; 1160 key->unicode = unicode;
1090 key->width = width; 1161 key->width = width;
1091 1162
1092 // share key->pressed between same keys 1163 // share key->pressed between same keys
1093 bool found = 0; 1164 bool found = 0;
1094 for (int i = 1; i <= 5; i++) { 1165 for (int i = 1; i <= 5; i++) {
1095 for (unsigned int j = 0; j < keys[i].count(); j++) 1166 for (unsigned int j = 0; j < keys[i].count(); j++)
1096 if (keys[i].at(j)->qcode == qcode && keys[i].at(j)->unicode == unicode) { 1167 if (keys[i].at(j)->qcode == qcode && keys[i].at(j)->unicode == unicode) {
1097 1168
1098 key->pressed = keys[i].at(j)->pressed; 1169 key->pressed = keys[i].at(j)->pressed;
1099 found = 1; 1170 found = 1;
1100 } 1171 }
1101 1172
1102 } 1173 }
1103 if (!found) { 1174 if (!found) {
1104 1175
1105 key->pressed = new bool; 1176 key->pressed = new bool;
1106 *(key->pressed) = 0; 1177 *(key->pressed) = 0;
1107 } 1178 }
1108 1179
1109 key->pix = pix; 1180 key->pix = pix;
1110 1181
1111 1182
1112 keys[row].append(key); 1183 keys[row].append(key);
1113} 1184}
1114 1185
1115// Keys::~Keys {{{2 1186// Keys::~Keys {{{2
1116Keys::~Keys() { 1187Keys::~Keys() {
1117 1188
1118 for (int i = 1; i <= 5; i++) 1189 for (int i = 1; i <= 5; i++)
1119 for (unsigned int j = 0; j < keys[i].count(); j++) 1190 for (unsigned int j = 0; j < keys[i].count(); j++)
1120 delete keys[i].at(j); 1191 delete keys[i].at(j);
1121 1192
1122} 1193}
1123 1194
1124// Keys:: other functions {{{2 1195// Keys:: other functions {{{2
1125int Keys::width(const int row, const int col) { 1196int Keys::width(const int row, const int col) {
1126 1197
1127 return keys[row].at(col)->width; 1198 return keys[row].at(col)->width;
1128 1199
1129} 1200}
1130ushort Keys::uni(const int row, const int col) { 1201ushort Keys::uni(const int row, const int col) {
1131 1202
1132 return keys[row].at(col)->unicode; 1203 return keys[row].at(col)->unicode;
1133 1204
1134} 1205}
1135 1206
1136int Keys::qcode(const int row, const int col) { 1207int Keys::qcode(const int row, const int col) {
1137 1208
1138 return keys[row].at(col)->qcode; 1209 return keys[row].at(col)->qcode;
1139} 1210}
1140 1211
1141QPixmap *Keys::pix(const int row, const int col) { 1212QPixmap *Keys::pix(const int row, const int col) {
1142 1213
1143 return keys[row].at(col)->pix; 1214 return keys[row].at(col)->pix;
1144 1215
1145} 1216}
1146bool Keys::pressed(const int row, const int col) { 1217bool Keys::pressed(const int row, const int col) {
1147 1218
1148 return *(keys[row].at(col)->pressed); 1219 return *(keys[row].at(col)->pressed);
1149} 1220}
1150 1221
1151int Keys::numKeys(const int row) { 1222int Keys::numKeys(const int row) {
1152 1223
1153 return keys[row].count(); 1224 return keys[row].count();
1154} 1225}
1155 1226
1156void Keys::setPressed(const int row, const int col, const bool pressed) { 1227void Keys::setPressed(const int row, const int col, const bool pressed) {
1157 1228
1158 *(keys[row].at(col)->pressed) = pressed; 1229 *(keys[row].at(col)->pressed) = pressed;
1159} 1230}
1160 1231
1161ushort Keys::shift(const ushort uni) { 1232ushort Keys::shift(const ushort uni) {
1162 1233
1163 if (shiftMap[uni]) { 1234 if (shiftMap[uni]) {
1164 1235
1165 return shiftMap[uni]; 1236 return shiftMap[uni];
1166 } 1237 }
1167 else 1238 else
1168 return 0; 1239 return 0;
1169 1240
1170} 1241}
1171 1242
1243ushort Keys::meta(const ushort uni) {
1244
1245 if (metaMap[uni]) {
1246
1247 return metaMap[uni];
1248 }
1249 else
1250 return 0;
1251
1252}
1253
1172bool *Keys::pressedPtr(const int row, const int col) { 1254bool *Keys::pressedPtr(const int row, const int col) {
1173 1255
1174 return keys[row].at(col)->pressed; 1256 return keys[row].at(col)->pressed;
1175} 1257}
diff --git a/inputmethods/multikey/keyboard.h b/inputmethods/multikey/keyboard.h
index dc50e55..b692975 100644
--- a/inputmethods/multikey/keyboard.h
+++ b/inputmethods/multikey/keyboard.h
@@ -1,170 +1,173 @@
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 <qframe.h> 20#include <qframe.h>
21#include <qmap.h> 21#include <qmap.h>
22#include "../pickboard/pickboardcfg.h" 22#include "../pickboard/pickboardcfg.h"
23#include "../pickboard/pickboardpicks.h" 23#include "../pickboard/pickboardpicks.h"
24#include "configdlg.h" 24#include "configdlg.h"
25 25
26class QTimer; 26class QTimer;
27 27
28class KeyboardConfig : public DictFilterConfig 28class KeyboardConfig : public DictFilterConfig
29{ 29{
30public: 30public:
31 KeyboardConfig(PickboardPicks* p) : DictFilterConfig(p), backspaces(0) { nrows = 1; } 31 KeyboardConfig(PickboardPicks* p) : DictFilterConfig(p), backspaces(0) { nrows = 1; }
32 virtual void generateText(const QString &s); 32 virtual void generateText(const QString &s);
33 void decBackspaces() { if (backspaces) backspaces--; } 33 void decBackspaces() { if (backspaces) backspaces--; }
34 void incBackspaces() { backspaces++; } 34 void incBackspaces() { backspaces++; }
35 void resetBackspaces() { backspaces = 0; } 35 void resetBackspaces() { backspaces = 0; }
36private: 36private:
37 int backspaces; 37 int backspaces;
38}; 38};
39 39
40 40
41class KeyboardPicks : public PickboardPicks 41class KeyboardPicks : public PickboardPicks
42{ 42{
43 Q_OBJECT 43 Q_OBJECT
44public: 44public:
45 KeyboardPicks(QWidget* parent=0, const char* name=0, WFlags f=0) 45 KeyboardPicks(QWidget* parent=0, const char* name=0, WFlags f=0)
46 : PickboardPicks(parent, name, f) { } 46 : PickboardPicks(parent, name, f) { }
47 void initialise(); 47 void initialise();
48 virtual QSize sizeHint() const; 48 virtual QSize sizeHint() const;
49 KeyboardConfig *dc; 49 KeyboardConfig *dc;
50}; 50};
51 51
52 52
53class Keys { 53class Keys {
54public: 54public:
55 55
56 Keys(); 56 Keys();
57 Keys(const char * filename); 57 Keys(const char * filename);
58 ~Keys(); 58 ~Keys();
59 ushort uni(const int row, const int col); 59 ushort uni(const int row, const int col);
60 int qcode(const int row, const int col); 60 int qcode(const int row, const int col);
61 int width(const int row, const int col); 61 int width(const int row, const int col);
62 bool pressed(const int row, const int col); 62 bool pressed(const int row, const int col);
63 bool *pressedPtr(const int row, const int col); 63 bool *pressedPtr(const int row, const int col);
64 ushort shift(const ushort); 64 ushort shift(const ushort);
65 ushort meta(const ushort);
65 QPixmap *pix(const int row, const int col); 66 QPixmap *pix(const int row, const int col);
66 int numKeys(const int row); 67 int numKeys(const int row);
67 void setKeysFromFile(const char *filename); 68 void setKeysFromFile(const char *filename);
68 void setKey(const int row, const int qcode, const ushort unicode, 69 void setKey(const int row, const int qcode, const ushort unicode,
69 const int width, QPixmap *pix); 70 const int width, QPixmap *pix);
70 void setPressed(const int row, const int col, const bool pressed); 71 void setPressed(const int row, const int col, const bool pressed);
71 QString lang; 72 QString lang;
72 QString label; 73 QString label;
73 74
74private: 75private:
75 76
76 typedef struct Key { 77 typedef struct Key {
77 int qcode; // are qt key codes just unicode values? 78 int qcode; // are qt key codes just unicode values?
78 ushort unicode; 79 ushort unicode;
79 int width; // not pixels but relative key width. normal key is 2 80 int width; // not pixels but relative key width. normal key is 2
80 81
81 // only needed for keys like ctrl that can have multiple keys pressed at once 82 // only needed for keys like ctrl that can have multiple keys pressed at once
82 bool *pressed; 83 bool *pressed;
83 QPixmap *pix; 84 QPixmap *pix;
84 }; 85 };
85 86
86 QList<Key> keys[6]; 87 QList<Key> keys[6];
87 QMap<ushort,ushort> shiftMap; 88 QMap<ushort,ushort> shiftMap;
89 QMap<ushort,ushort> metaMap;
88 90
89}; 91};
90 92
91class Keyboard : public QFrame 93class Keyboard : public QFrame
92{ 94{
93 Q_OBJECT 95 Q_OBJECT
94public: 96public:
95 Keyboard( QWidget* parent=0, const char* name=0, WFlags f=0 ); 97 Keyboard( QWidget* parent=0, const char* name=0, WFlags f=0 );
96 ~Keyboard(); 98 ~Keyboard();
97 99
98 void resetState(); 100 void resetState();
99 101
100 void mousePressEvent(QMouseEvent*); 102 void mousePressEvent(QMouseEvent*);
101 void mouseReleaseEvent(QMouseEvent*); 103 void mouseReleaseEvent(QMouseEvent*);
102 void resizeEvent(QResizeEvent*); 104 void resizeEvent(QResizeEvent*);
103 void paintEvent(QPaintEvent* e); 105 void paintEvent(QPaintEvent* e);
104 //void timerEvent(QTimerEvent* e); 106 //void timerEvent(QTimerEvent* e);
105 void drawKeyboard( QPainter &p, int row = -1, int col = -1); 107 void drawKeyboard( QPainter &p, int row = -1, int col = -1);
106 108
107 QSize sizeHint() const; 109 QSize sizeHint() const;
108 110
109signals: 111signals:
110 void key( ushort scancode, ushort unicode, ushort modifiers, bool, bool ); 112 void key( ushort scancode, ushort unicode, ushort modifiers, bool, bool );
111 113
112private slots: 114private slots:
113 void repeat(); 115 void repeat();
114 void togglePickboard(bool on_off); 116 void togglePickboard(bool on_off);
115 void toggleRepeat(bool on_off); 117 void toggleRepeat(bool on_off);
116 void setMapToDefault(); 118 void setMapToDefault();
117 void setMapToFile(QString map); 119 void setMapToFile(QString map);
118 120
119 // used to redraw keyboard after edited colors 121 // used to redraw keyboard after edited colors
120 void reloadKeyboard(); 122 void reloadKeyboard();
121 123
122private: 124private:
123 int getKey( int &w, int j = -1 ); 125 int getKey( int &w, int j = -1 );
124 void clearHighlight(); 126 void clearHighlight();
125 127
126 bool *shift; 128 bool *shift;
127 bool *lock; 129 bool *lock;
128 bool *ctrl; 130 bool *ctrl;
129 bool *alt; 131 bool *alt;
132 bool *meta;
130 uint useLargeKeys:1; 133 uint useLargeKeys:1;
131 uint usePicks:1; 134 uint usePicks:1;
132 uint useRepeat:1; 135 uint useRepeat:1;
133 136
134 int pressedKeyRow; 137 int pressedKeyRow;
135 int pressedKeyCol; 138 int pressedKeyCol;
136 139
137 KeyboardPicks *picks; 140 KeyboardPicks *picks;
138 141
139 int keyHeight; 142 int keyHeight;
140 int defaultKeyWidth; 143 int defaultKeyWidth;
141 int xoffs; 144 int xoffs;
142 145
143 int unicode; 146 int unicode;
144 int qkeycode; 147 int qkeycode;
145 int modifiers; 148 int modifiers;
146 149
147 int pressTid; 150 int pressTid;
148 bool pressed; 151 bool pressed;
149 152
150 Keys *keys; 153 Keys *keys;
151 154
152 /* for korean input */ 155 /* for korean input */
153 ushort schar, mchar, echar; 156 ushort schar, mchar, echar;
154 ushort parseKoreanInput(ushort c); 157 ushort parseKoreanInput(ushort c);
155 ushort combineKoreanChars(const ushort s, const ushort m, const ushort e); 158 ushort combineKoreanChars(const ushort s, const ushort m, const ushort e);
156 ushort constoe(const ushort c); 159 ushort constoe(const ushort c);
157 160
158 QTimer *repeatTimer; 161 QTimer *repeatTimer;
159 162
160 /* colors */ 163 /* colors */
161 void loadKeyboardColors(); 164 void loadKeyboardColors();
162 QColor keycolor; 165 QColor keycolor;
163 QColor keycolor_pressed; 166 QColor keycolor_pressed;
164 QColor keycolor_lines; 167 QColor keycolor_lines;
165 QColor textcolor; 168 QColor textcolor;
166 169
167 ConfigDlg *configdlg; 170 ConfigDlg *configdlg;
168}; 171};
169 172
170 173