summaryrefslogtreecommitdiff
path: root/inputmethods
authorhash <hash>2002-08-21 17:54:33 (UTC)
committer hash <hash>2002-08-21 17:54:33 (UTC)
commit0a61be3b42b4b152468a5ef2def4a18baeda9b4f (patch) (unidiff)
treeaa82e34a4d4984ae334ffbd31582ac60a655e499 /inputmethods
parent24ca0a148bdb23f5c890661dc2edac7ba6120c67 (diff)
downloadopie-0a61be3b42b4b152468a5ef2def4a18baeda9b4f.zip
opie-0a61be3b42b4b152468a5ef2def4a18baeda9b4f.tar.gz
opie-0a61be3b42b4b152468a5ef2def4a18baeda9b4f.tar.bz2
ctrl and alt keys should work now
Diffstat (limited to 'inputmethods') (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/multikey/configdlg.cpp1
-rw-r--r--inputmethods/multikey/keyboard.cpp8
2 files changed, 8 insertions, 1 deletions
diff --git a/inputmethods/multikey/configdlg.cpp b/inputmethods/multikey/configdlg.cpp
index 89b713e..a9137b9 100644
--- a/inputmethods/multikey/configdlg.cpp
+++ b/inputmethods/multikey/configdlg.cpp
@@ -1,100 +1,101 @@
1/* 1/*
2 * TODO 2 * TODO
3 * make a font selection thing (size too) 3 * make a font selection thing (size too)
4 * make a cursor thing 4 * make a cursor thing
5 * add meta key support for german, etc
5 * 6 *
6 * 7 *
7 * 8 *
8 */ 9 */
9 10
10#include <iostream.h> 11#include <iostream.h>
11 12
12#include <qpe/qpeapplication.h> 13#include <qpe/qpeapplication.h>
13#include <qpe/config.h> 14#include <qpe/config.h>
14 15
15#include <qwidget.h> 16#include <qwidget.h>
16#include <qdialog.h> 17#include <qdialog.h>
17#include <qtabwidget.h> 18#include <qtabwidget.h>
18#include <qvbox.h> 19#include <qvbox.h>
19#include <qgrid.h> 20#include <qgrid.h>
20#include <qgroupbox.h> 21#include <qgroupbox.h>
21#include <qlabel.h> 22#include <qlabel.h>
22#include <qcheckbox.h> 23#include <qcheckbox.h>
23#include <qsizepolicy.h> 24#include <qsizepolicy.h>
24#include <qpushbutton.h> 25#include <qpushbutton.h>
25#include <qlistbox.h> 26#include <qlistbox.h>
26#include <qstringlist.h> 27#include <qstringlist.h>
27#include <opie/ofiledialog.h> 28#include <opie/ofiledialog.h>
28#include <opie/colordialog.h> 29#include <opie/colordialog.h>
29#include <qdir.h> 30#include <qdir.h>
30#include <qfileinfo.h> 31#include <qfileinfo.h>
31#include "configdlg.h" 32#include "configdlg.h"
32#include "keyboard.h" 33#include "keyboard.h"
33 34
34// ConfigDlg::ConfigDlg() {{{1 35// ConfigDlg::ConfigDlg() {{{1
35ConfigDlg::ConfigDlg () : QTabWidget () 36ConfigDlg::ConfigDlg () : QTabWidget ()
36{ 37{
37 setCaption( tr("Multikey Configuration") ); 38 setCaption( tr("Multikey Configuration") );
38 Config config ("multikey"); 39 Config config ("multikey");
39 config.setGroup("keymaps"); 40 config.setGroup("keymaps");
40 QString current_map = config.readEntry("current", 0); 41 QString current_map = config.readEntry("current", 0);
41 42
42 /* 43 /*
43 * 'general config' tab 44 * 'general config' tab
44 */ 45 */
45 46
46 QVBox *gen_box = new QVBox (this); 47 QVBox *gen_box = new QVBox (this);
47 gen_box->setMargin(3); 48 gen_box->setMargin(3);
48 addTab(gen_box, tr("General Settings")); 49 addTab(gen_box, tr("General Settings"));
49 50
50 QGroupBox *map_group = new QGroupBox (2, Qt::Vertical, tr("Keymap File"), gen_box); 51 QGroupBox *map_group = new QGroupBox (2, Qt::Vertical, tr("Keymap File"), gen_box);
51 52
52 keymaps = new QListBox (map_group); 53 keymaps = new QListBox (map_group);
53 keymaps->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); 54 keymaps->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
54 55
55 QString cur(tr("Current Language")); 56 QString cur(tr("Current Language"));
56 keymaps->insertItem(cur); 57 keymaps->insertItem(cur);
57 keymaps->setSelected(0, true); 58 keymaps->setSelected(0, true);
58 59
59 QDir map_dir(QPEApplication::qpeDir() + "/share/multikey", "*.keymap"); 60 QDir map_dir(QPEApplication::qpeDir() + "/share/multikey", "*.keymap");
60 default_maps = map_dir.entryList(); // so i can access it in other places 61 default_maps = map_dir.entryList(); // so i can access it in other places
61 62
62 for (uint i = 0; i <map_dir.count(); i++) { 63 for (uint i = 0; i <map_dir.count(); i++) {
63 64
64 keymaps->insertItem(map_dir.absPath() + "/" + map_dir[i]); 65 keymaps->insertItem(map_dir.absPath() + "/" + map_dir[i]);
65 if (map_dir.absPath() + "/" + map_dir[i] == current_map) { 66 if (map_dir.absPath() + "/" + map_dir[i] == current_map) {
66 67
67 keymaps->setSelected(i + 1, true); 68 keymaps->setSelected(i + 1, true);
68 } 69 }
69 70
70 } 71 }
71 72
72 custom_maps = config.readListEntry("maps", QChar('|')); 73 custom_maps = config.readListEntry("maps", QChar('|'));
73 74
74 for (uint i = 0; i < custom_maps.count(); i++) { 75 for (uint i = 0; i < custom_maps.count(); i++) {
75 76
76 if (map_dir.exists(QFileInfo(custom_maps[i]).fileName(), false) 77 if (map_dir.exists(QFileInfo(custom_maps[i]).fileName(), false)
77 || !QFile::exists(custom_maps[i])) { 78 || !QFile::exists(custom_maps[i])) {
78 79
79 custom_maps.remove(custom_maps.at(i)); 80 custom_maps.remove(custom_maps.at(i));
80 81
81 // remove it from the list too 82 // remove it from the list too
82 config.writeEntry("maps", custom_maps.join("|")); 83 config.writeEntry("maps", custom_maps.join("|"));
83 84
84 85
85 } else { 86 } else {
86 87
87 keymaps->insertItem(custom_maps[i]); 88 keymaps->insertItem(custom_maps[i]);
88 if (custom_maps[i] == current_map) { 89 if (custom_maps[i] == current_map) {
89 90
90 keymaps->setSelected(map_dir.count() + i + 1, true); 91 keymaps->setSelected(map_dir.count() + i + 1, true);
91 } 92 }
92 } 93 }
93 } 94 }
94 95
95 // have to "+1" because the "current language" listItem... remember? 96 // have to "+1" because the "current language" listItem... remember?
96 97
97 connect(keymaps, SIGNAL(highlighted(int)), SLOT(setMap(int))); 98 connect(keymaps, SIGNAL(highlighted(int)), SLOT(setMap(int)));
98 99
99 100
100 QGrid *add_remove_grid = new QGrid(2, map_group); 101 QGrid *add_remove_grid = new QGrid(2, map_group);
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp
index 7334c1c..949164a 100644
--- a/inputmethods/multikey/keyboard.cpp
+++ b/inputmethods/multikey/keyboard.cpp
@@ -265,193 +265,199 @@ void Keyboard::mousePressEvent(QMouseEvent *e)
265 w += keys->width(row,col) * defaultKeyWidth; 265 w += keys->width(row,col) * defaultKeyWidth;
266 else break; 266 else break;
267 267
268 col --; // rewind one... 268 col --; // rewind one...
269 269
270 qkeycode = keys->qcode(row, col); 270 qkeycode = keys->qcode(row, col);
271 unicode = keys->uni(row, col); 271 unicode = keys->uni(row, col);
272 272
273 // might need to repaint if two or more of the same keys. 273 // might need to repaint if two or more of the same keys.
274 // should be faster if just paint one key even though multiple keys exist. 274 // should be faster if just paint one key even though multiple keys exist.
275 bool need_repaint = FALSE; 275 bool need_repaint = FALSE;
276 276
277 if (unicode == 0) { // either Qt char, or nothing 277 if (unicode == 0) { // either Qt char, or nothing
278 278
279 if (qkeycode == Qt::Key_F1) { // toggle the pickboard 279 if (qkeycode == Qt::Key_F1) { // toggle the pickboard
280 280
281 if ( configdlg ) { 281 if ( configdlg ) {
282 delete (ConfigDlg *) configdlg; 282 delete (ConfigDlg *) configdlg;
283 configdlg = 0; 283 configdlg = 0;
284 } 284 }
285 else { 285 else {
286 configdlg = new ConfigDlg (); 286 configdlg = new ConfigDlg ();
287 connect(configdlg, SIGNAL(setMapToDefault()), 287 connect(configdlg, SIGNAL(setMapToDefault()),
288 this, SLOT(setMapToDefault())); 288 this, SLOT(setMapToDefault()));
289 connect(configdlg, SIGNAL(setMapToFile(QString)), 289 connect(configdlg, SIGNAL(setMapToFile(QString)),
290 this, SLOT(setMapToFile(QString))); 290 this, SLOT(setMapToFile(QString)));
291 connect(configdlg, SIGNAL(pickboardToggled(bool)), 291 connect(configdlg, SIGNAL(pickboardToggled(bool)),
292 this, SLOT(togglePickboard(bool))); 292 this, SLOT(togglePickboard(bool)));
293 connect(configdlg, SIGNAL(repeatToggled(bool)), 293 connect(configdlg, SIGNAL(repeatToggled(bool)),
294 this, SLOT(toggleRepeat(bool))); 294 this, SLOT(toggleRepeat(bool)));
295 connect(configdlg, SIGNAL(reloadKeyboard()), 295 connect(configdlg, SIGNAL(reloadKeyboard()),
296 this, SLOT(reloadKeyboard())); 296 this, SLOT(reloadKeyboard()));
297 configdlg->showMaximized(); 297 configdlg->showMaximized();
298 configdlg->show(); 298 configdlg->show();
299 configdlg->raise(); 299 configdlg->raise();
300 } 300 }
301 301
302 } else if (qkeycode == Qt::Key_Control) { 302 } else if (qkeycode == Qt::Key_Control) {
303 ctrl = keys->pressedPtr(row, col); 303 ctrl = keys->pressedPtr(row, col);
304 need_repaint = TRUE; 304 need_repaint = TRUE;
305 *ctrl = !keys->pressed(row, col); 305 *ctrl = !keys->pressed(row, col);
306 306
307 } else if (qkeycode == Qt::Key_Alt) { 307 } else if (qkeycode == Qt::Key_Alt) {
308 alt = keys->pressedPtr(row, col); 308 alt = keys->pressedPtr(row, col);
309 need_repaint = TRUE; 309 need_repaint = TRUE;
310 *alt = !keys->pressed(row, col); 310 *alt = !keys->pressed(row, col);
311 311
312 } else if (qkeycode == Qt::Key_Shift) { 312 } else if (qkeycode == Qt::Key_Shift) {
313 need_repaint = TRUE; 313 need_repaint = TRUE;
314 314
315 if (shift) { 315 if (shift) {
316 *shift = 0; 316 *shift = 0;
317 shift = 0; 317 shift = 0;
318 } 318 }
319 else { 319 else {
320 shift = keys->pressedPtr(row, col); 320 shift = keys->pressedPtr(row, col);
321 *shift = 1; 321 *shift = 1;
322 if (lock) { 322 if (lock) {
323 *lock = 0; 323 *lock = 0;
324 lock = 0; 324 lock = 0;
325 } 325 }
326 } 326 }
327 327
328 } else if (qkeycode == Qt::Key_CapsLock) { 328 } else if (qkeycode == Qt::Key_CapsLock) {
329 need_repaint = TRUE; 329 need_repaint = TRUE;
330 330
331 if (lock) { 331 if (lock) {
332 *lock = 0; 332 *lock = 0;
333 lock = 0; 333 lock = 0;
334 } 334 }
335 else { 335 else {
336 lock = keys->pressedPtr(row, col);; 336 lock = keys->pressedPtr(row, col);;
337 *lock = 1; 337 *lock = 1;
338 if (shift) { 338 if (shift) {
339 *shift = 0; 339 *shift = 0;
340 shift = 0; 340 shift = 0;
341 } 341 }
342 } 342 }
343 343
344 } 344 }
345 345
346 } 346 }
347 else { // normal char 347 else { // normal char
348 if ((shift || lock) && keys->shift(unicode)) { 348 if ((shift || lock) && keys->shift(unicode)) {
349 unicode = keys->shift(unicode); 349 unicode = keys->shift(unicode);
350 } 350 }
351 } 351 }
352 352
353 // korean parsing 353 // korean parsing
354 if (keys->lang == "ko") { 354 if (keys->lang == "ko") {
355 355
356 unicode = parseKoreanInput(unicode); 356 unicode = parseKoreanInput(unicode);
357 } 357 }
358 358
359 modifiers = (ctrl ? Qt::ControlButton : 0) | (alt ? Qt::AltButton : 0); 359 modifiers = (ctrl ? Qt::ControlButton : 0) | (alt ? Qt::AltButton : 0);
360 360
361 emit key(unicode, qkeycode, modifiers, true, false); 361 if ('A' <= unicode && unicode <= 'z' && modifiers) {
362
363 qkeycode = QChar(unicode).upper();
364 unicode = qkeycode - '@';
365 }
366
367 QWSServer::sendKeyEvent(unicode, qkeycode, modifiers, true, false);
362 368
363 // pickboard stuff 369 // pickboard stuff
364 if (usePicks) { 370 if (usePicks) {
365 371
366 KeyboardConfig *dc = picks->dc; 372 KeyboardConfig *dc = picks->dc;
367 373
368 if (dc) { 374 if (dc) {
369 if (qkeycode == Qt::Key_Backspace) { 375 if (qkeycode == Qt::Key_Backspace) {
370 dc->input.remove(dc->input.last()); // remove last input 376 dc->input.remove(dc->input.last()); // remove last input
371 dc->decBackspaces(); 377 dc->decBackspaces();
372 } else if ( qkeycode == Qt::Key_Return || QChar(unicode).isPunct() || QChar(unicode).isSpace() || unicode == 0) { 378 } else if ( qkeycode == Qt::Key_Return || QChar(unicode).isPunct() || QChar(unicode).isSpace() || unicode == 0) {
373 dc->input.clear(); 379 dc->input.clear();
374 dc->resetBackspaces(); 380 dc->resetBackspaces();
375 } else { 381 } else {
376 dc->add(QString(QChar(unicode))); 382 dc->add(QString(QChar(unicode)));
377 dc->incBackspaces(); 383 dc->incBackspaces();
378 } 384 }
379 } 385 }
380 picks->repaint(); 386 picks->repaint();
381 } 387 }
382 388
383 389
384 // painting 390 // painting
385 pressed = TRUE; 391 pressed = TRUE;
386 392
387 pressedKeyRow = row; 393 pressedKeyRow = row;
388 pressedKeyCol = col; 394 pressedKeyCol = col;
389 395
390 if (need_repaint) repaint(FALSE); 396 if (need_repaint) repaint(FALSE);
391 else { // just paint the one key pressed 397 else { // just paint the one key pressed
392 398
393 399
394 400
395 QPainter p(this); 401 QPainter p(this);
396 drawKeyboard(p, row, col); 402 drawKeyboard(p, row, col);
397 403
398 } 404 }
399 405
400 if (useRepeat) repeatTimer->start( 800 ); 406 if (useRepeat) repeatTimer->start( 800 );
401 //pressTid = startTimer(80); 407 //pressTid = startTimer(80);
402 408
403} 409}
404 410
405 411
406/* Keyboard::mouseReleaseEvent {{{1 */ 412/* Keyboard::mouseReleaseEvent {{{1 */
407void Keyboard::mouseReleaseEvent(QMouseEvent*) 413void Keyboard::mouseReleaseEvent(QMouseEvent*)
408{ 414{
409 pressed = FALSE; 415 pressed = FALSE;
410 //if ( pressTid == 0 ) 416 //if ( pressTid == 0 )
411#if defined(Q_WS_QWS) || defined(_WS_QWS_) 417#if defined(Q_WS_QWS) || defined(_WS_QWS_)
412 if ( unicode != -1 ) { 418 if ( unicode != -1 ) {
413 emit key( unicode, qkeycode, modifiers, false, false ); 419 emit key( unicode, qkeycode, modifiers, false, false );
414 repeatTimer->stop(); 420 repeatTimer->stop();
415 } 421 }
416#endif 422#endif
417 if (shift && unicode != 0) { 423 if (shift && unicode != 0) {
418 424
419 425
420 *shift = 0; // unpress shift key 426 *shift = 0; // unpress shift key
421 shift = 0; // reset the shift pointer 427 shift = 0; // reset the shift pointer
422 repaint(FALSE); 428 repaint(FALSE);
423 429
424 } 430 }
425 else 431 else
426 432
427 clearHighlight(); 433 clearHighlight();
428} 434}
429 435
430/* Keyboard::timerEvent {{{1 */ 436/* Keyboard::timerEvent {{{1 */
431 437
432/* dont know what this does, but i think it is here so that if your screen 438/* dont know what this does, but i think it is here so that if your screen
433 * sticks (like on an ipaq) then it will stop repeating if you click another 439 * sticks (like on an ipaq) then it will stop repeating if you click another
434 * key... but who knows what anything does in this thing anyway? 440 * key... but who knows what anything does in this thing anyway?
435 441
436 void Keyboard::timerEvent(QTimerEvent* e) 442 void Keyboard::timerEvent(QTimerEvent* e)
437{ 443{
438 if ( e->timerId() == pressTid ) { 444 if ( e->timerId() == pressTid ) {
439 killTimer(pressTid); 445 killTimer(pressTid);
440 pressTid = 0; 446 pressTid = 0;
441 if ( !pressed ) 447 if ( !pressed )
442 cout << "calling clearHighlight from timerEvent\n"; 448 cout << "calling clearHighlight from timerEvent\n";
443 //clearHighlight(); 449 //clearHighlight();
444 } 450 }
445} 451}
446*/ 452*/
447 453
448void Keyboard::repeat() 454void Keyboard::repeat()
449{ 455{
450 456
451 repeatTimer->start( 200 ); 457 repeatTimer->start( 200 );
452 emit key( unicode, qkeycode, modifiers, true, true ); 458 emit key( unicode, qkeycode, modifiers, true, true );
453} 459}
454 460
455void Keyboard::clearHighlight() 461void Keyboard::clearHighlight()
456{ 462{
457 if ( pressedKeyRow >= 0 && pressedKeyCol >= 0) { 463 if ( pressedKeyRow >= 0 && pressedKeyCol >= 0) {