summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/multikey/configdlg.cpp3
-rw-r--r--inputmethods/multikey/keyboard.cpp2
2 files changed, 4 insertions, 1 deletions
diff --git a/inputmethods/multikey/configdlg.cpp b/inputmethods/multikey/configdlg.cpp
index 68c31be..6ec8d0e 100644
--- a/inputmethods/multikey/configdlg.cpp
+++ b/inputmethods/multikey/configdlg.cpp
@@ -1,120 +1,123 @@
1/* 1/*
2 * TODO 2 * TODO
3 * make a font selection thing 3 * make a font selection thing
4 * 4 *
5 * FIXME 5 * FIXME
6 * if you open the config dialog and close it from the little (x) button on the title bar, 6 * if you open the config dialog and close it from the little (x) button on the title bar,
7 * you have to hit the button on the keyboard twice for it to open the next time 7 * you have to hit the button on the keyboard twice for it to open the next time
8 * 8 *
9 * 9 *
10 */ 10 */
11 11
12#include <qpe/qpeapplication.h> 12#include <qpe/qpeapplication.h>
13#include <qpe/config.h> 13#include <qpe/config.h>
14 14
15#include <qwidget.h> 15#include <qwidget.h>
16#include <qdialog.h> 16#include <qdialog.h>
17#include <qtabwidget.h> 17#include <qtabwidget.h>
18#include <qvbox.h> 18#include <qvbox.h>
19#include <qgrid.h> 19#include <qgrid.h>
20#include <qgroupbox.h> 20#include <qgroupbox.h>
21#include <qlabel.h> 21#include <qlabel.h>
22#include <qcheckbox.h> 22#include <qcheckbox.h>
23#include <qsizepolicy.h> 23#include <qsizepolicy.h>
24#include <qpushbutton.h> 24#include <qpushbutton.h>
25#include <qcombobox.h> 25#include <qcombobox.h>
26#include "configdlg.h" 26#include "configdlg.h"
27#include "keyboard.h" 27#include "keyboard.h"
28 28
29ConfigDlg::ConfigDlg () : QTabWidget () 29ConfigDlg::ConfigDlg () : QTabWidget ()
30{ 30{
31 setCaption( tr("Multikey Configuration") ); 31 setCaption( tr("Multikey Configuration") );
32 32
33 /* 33 /*
34 * 'general config' tab 34 * 'general config' tab
35 */ 35 */
36 36
37 QVBox *gen_box = new QVBox (this); 37 QVBox *gen_box = new QVBox (this);
38 gen_box->setMargin(3); 38 gen_box->setMargin(3);
39 addTab(gen_box, tr("General Settings")); 39 addTab(gen_box, tr("General Settings"));
40 40
41 QGroupBox *map_group = new QGroupBox (2, Qt::Horizontal, tr("Keymap File"), gen_box); 41 QGroupBox *map_group = new QGroupBox (2, Qt::Horizontal, tr("Keymap File"), gen_box);
42 42
43 map_combo = new QComboBox ((bool)0, map_group); 43 map_combo = new QComboBox ((bool)0, map_group);
44 map_combo->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); 44 map_combo->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
45 45
46 QString cur(tr("Current Language")); 46 QString cur(tr("Current Language"));
47 map_combo->insertItem(cur); 47 map_combo->insertItem(cur);
48 connect(map_combo, SIGNAL(activated(int)), SLOT(setMap(int))); 48 connect(map_combo, SIGNAL(activated(int)), SLOT(setMap(int)));
49 49
50 QString ko(tr("/opt/opie/share/multikey/ko.keymap")); 50 QString ko(tr("/opt/opie/share/multikey/ko.keymap"));
51 map_combo->insertItem(ko); 51 map_combo->insertItem(ko);
52 52
53 QString en(tr("/opt/opie/share/multikey/en.keymap")); 53 QString en(tr("/opt/opie/share/multikey/en.keymap"));
54 map_combo->insertItem(en); 54 map_combo->insertItem(en);
55 55
56 QString de(tr("/opt/opie/share/multikey/de.keymap"));
57 map_combo->insertItem(de);
58
56 QPushButton *button = new QPushButton(tr("Browse..."), map_group); 59 QPushButton *button = new QPushButton(tr("Browse..."), map_group);
57 button->setFlat((bool)1); 60 button->setFlat((bool)1);
58 61
59 pick_button = new QCheckBox(tr("Pickboard"), gen_box); 62 pick_button = new QCheckBox(tr("Pickboard"), gen_box);
60 63
61 Config config ("multikey"); 64 Config config ("multikey");
62 config.setGroup ("pickboard"); 65 config.setGroup ("pickboard");
63 bool pick_open = config.readBoolEntry ("open", "0"); // default closed 66 bool pick_open = config.readBoolEntry ("open", "0"); // default closed
64 if (pick_open) { 67 if (pick_open) {
65 68
66 pick_button->setChecked(true); 69 pick_button->setChecked(true);
67 } 70 }
68 71
69 // by connecting it after checking it, the signal isn't emmited 72 // by connecting it after checking it, the signal isn't emmited
70 connect (pick_button, SIGNAL(clicked()), this, SLOT(pickTog())); 73 connect (pick_button, SIGNAL(clicked()), this, SLOT(pickTog()));
71 74
72 /* 75 /*
73 * 'color' tab 76 * 'color' tab
74 */ 77 */
75 78
76 QGrid *color_box = new QGrid(2, this); 79 QGrid *color_box = new QGrid(2, this);
77 color_box->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); 80 color_box->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
78 color_box->setMargin(3); 81 color_box->setMargin(3);
79 addTab(color_box, tr("Colors")); 82 addTab(color_box, tr("Colors"));
80 83
81 QLabel *label; 84 QLabel *label;
82 85
83 label = new QLabel(tr("Key Color"), color_box); 86 label = new QLabel(tr("Key Color"), color_box);
84 button = new QPushButton(color_box); 87 button = new QPushButton(color_box);
85 button->setFlat((bool)1); 88 button->setFlat((bool)1);
86 label = new QLabel(tr("Key Pressed Color"), color_box); 89 label = new QLabel(tr("Key Pressed Color"), color_box);
87 button = new QPushButton(color_box); 90 button = new QPushButton(color_box);
88 button->setFlat((bool)1); 91 button->setFlat((bool)1);
89 label = new QLabel(tr("Line Color"), color_box); 92 label = new QLabel(tr("Line Color"), color_box);
90 button = new QPushButton(color_box); 93 button = new QPushButton(color_box);
91 button->setFlat((bool)1); 94 button->setFlat((bool)1);
92 label = new QLabel(tr("Text Color"), color_box); 95 label = new QLabel(tr("Text Color"), color_box);
93 button = new QPushButton(color_box); 96 button = new QPushButton(color_box);
94 button->setFlat((bool)1); 97 button->setFlat((bool)1);
95 98
96 label = new QLabel("", color_box); // a spacer so the above buttons dont expand 99 label = new QLabel("", color_box); // a spacer so the above buttons dont expand
97 label->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); 100 label->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
98 101
99} 102}
100 103
101void ConfigDlg::pickTog() { 104void ConfigDlg::pickTog() {
102 105
103 Config config ("multikey"); 106 Config config ("multikey");
104 config.setGroup ("pickboard"); 107 config.setGroup ("pickboard");
105 config.writeEntry ("open", pick_button->isChecked()); // default closed 108 config.writeEntry ("open", pick_button->isChecked()); // default closed
106 109
107 emit pickboardToggled(pick_button->isChecked()); 110 emit pickboardToggled(pick_button->isChecked());
108} 111}
109 112
110void ConfigDlg::setMap(int index) { 113void ConfigDlg::setMap(int index) {
111 114
112 if (index == 0) { 115 if (index == 0) {
113 116
114 emit setMapToDefault(); 117 emit setMapToDefault();
115 } 118 }
116 else { 119 else {
117 120
118 emit setMapToFile(map_combo->text(index)); 121 emit setMapToFile(map_combo->text(index));
119 } 122 }
120} 123}
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp
index 1d91b82..b793391 100644
--- a/inputmethods/multikey/keyboard.cpp
+++ b/inputmethods/multikey/keyboard.cpp
@@ -362,193 +362,193 @@ void Keyboard::mousePressEvent(QMouseEvent *e)
362 dc->input.clear(); 362 dc->input.clear();
363 dc->resetBackspaces(); 363 dc->resetBackspaces();
364 } else { 364 } else {
365 dc->add(QString(QChar(unicode))); 365 dc->add(QString(QChar(unicode)));
366 dc->incBackspaces(); 366 dc->incBackspaces();
367 } 367 }
368 } 368 }
369 picks->repaint(); 369 picks->repaint();
370 } 370 }
371 371
372 372
373 // painting 373 // painting
374 pressed = TRUE; 374 pressed = TRUE;
375 375
376 pressedKeyRow = row; 376 pressedKeyRow = row;
377 pressedKeyCol = col; 377 pressedKeyCol = col;
378 378
379 if (need_repaint) repaint(FALSE); 379 if (need_repaint) repaint(FALSE);
380 else { // just paint the one key pressed 380 else { // just paint the one key pressed
381 381
382 382
383 383
384 QPainter p(this); 384 QPainter p(this);
385 drawKeyboard(p, row, col); 385 drawKeyboard(p, row, col);
386 386
387 } 387 }
388 388
389 pressTid = startTimer(80); 389 pressTid = startTimer(80);
390 390
391} 391}
392 392
393 393
394/* Keyboard::mouseReleaseEvent {{{1 */ 394/* Keyboard::mouseReleaseEvent {{{1 */
395void Keyboard::mouseReleaseEvent(QMouseEvent*) 395void Keyboard::mouseReleaseEvent(QMouseEvent*)
396{ 396{
397 pressed = FALSE; 397 pressed = FALSE;
398 if ( pressTid == 0 ) 398 if ( pressTid == 0 )
399#if defined(Q_WS_QWS) || defined(_WS_QWS_) 399#if defined(Q_WS_QWS) || defined(_WS_QWS_)
400 if ( unicode != -1 ) { 400 if ( unicode != -1 ) {
401 emit key( unicode, qkeycode, modifiers, false, false ); 401 emit key( unicode, qkeycode, modifiers, false, false );
402 repeatTimer->stop(); 402 repeatTimer->stop();
403 } 403 }
404#endif 404#endif
405 if (shift && unicode != 0) { 405 if (shift && unicode != 0) {
406 406
407 407
408 *shift = 0; // unpress shift key 408 *shift = 0; // unpress shift key
409 shift = 0; // reset the shift pointer 409 shift = 0; // reset the shift pointer
410 repaint(FALSE); 410 repaint(FALSE);
411 411
412 } 412 }
413 else 413 else
414 414
415 clearHighlight(); 415 clearHighlight();
416} 416}
417 417
418/* Keyboard::timerEvent {{{1 */ 418/* Keyboard::timerEvent {{{1 */
419/* 419/*
420void Keyboard::timerEvent(QTimerEvent* e) 420void Keyboard::timerEvent(QTimerEvent* e)
421{ 421{
422 if ( e->timerId() == pressTid ) { 422 if ( e->timerId() == pressTid ) {
423 killTimer(pressTid); 423 killTimer(pressTid);
424 pressTid = 0; 424 pressTid = 0;
425 if ( !pressed ) 425 if ( !pressed )
426 cout << "calling clearHighlight from timerEvent\n"; 426 cout << "calling clearHighlight from timerEvent\n";
427 clearHighlight(); 427 clearHighlight();
428 } 428 }
429} 429}
430*/ 430*/
431 431
432void Keyboard::repeat() 432void Keyboard::repeat()
433{ 433{
434 434
435 repeatTimer->start( 200 ); 435 repeatTimer->start( 200 );
436 emit key( unicode, 0, modifiers, true, true ); 436 emit key( unicode, 0, modifiers, true, true );
437} 437}
438 438
439void Keyboard::clearHighlight() 439void Keyboard::clearHighlight()
440{ 440{
441 if ( pressedKeyRow >= 0 && pressedKeyCol >= 0) { 441 if ( pressedKeyRow >= 0 && pressedKeyCol >= 0) {
442 int tmpRow = pressedKeyRow; 442 int tmpRow = pressedKeyRow;
443 int tmpCol = pressedKeyCol; 443 int tmpCol = pressedKeyCol;
444 444
445 pressedKeyRow = -1; 445 pressedKeyRow = -1;
446 pressedKeyCol = -1; 446 pressedKeyCol = -1;
447 447
448 QPainter p(this); 448 QPainter p(this);
449 drawKeyboard(p, tmpRow, tmpCol); 449 drawKeyboard(p, tmpRow, tmpCol);
450 } 450 }
451} 451}
452 452
453 453
454/* Keyboard::sizeHint {{{1 */ 454/* Keyboard::sizeHint {{{1 */
455QSize Keyboard::sizeHint() const 455QSize Keyboard::sizeHint() const
456{ 456{
457 QFontMetrics fm=fontMetrics(); 457 QFontMetrics fm=fontMetrics();
458 int keyHeight = fm.lineSpacing(); 458 int keyHeight = fm.lineSpacing() + 2;
459 459
460 return QSize( 240, keyHeight * 5 + (usePicks ? picks->sizeHint().height() : 0) + 1); 460 return QSize( 240, keyHeight * 5 + (usePicks ? picks->sizeHint().height() : 0) + 1);
461} 461}
462 462
463 463
464void Keyboard::resetState() 464void Keyboard::resetState()
465{ 465{
466 schar = mchar = echar = 0; 466 schar = mchar = echar = 0;
467 picks->resetState(); 467 picks->resetState();
468} 468}
469 469
470/* Keyboard::togglePickboard {{{1 */ 470/* Keyboard::togglePickboard {{{1 */
471void Keyboard::togglePickboard(bool on_off) 471void Keyboard::togglePickboard(bool on_off)
472{ 472{
473 usePicks = on_off; 473 usePicks = on_off;
474 if (usePicks) { 474 if (usePicks) {
475 picks->show(); 475 picks->show();
476 //move(x(), y() - picks->height()); // not required anymore because QCopChannel::send 476 //move(x(), y() - picks->height()); // not required anymore because QCopChannel::send
477 //adjustSize(); 477 //adjustSize();
478 QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), 478 QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ),
479 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); 479 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) );
480 } else { 480 } else {
481 481
482 picks->hide(); 482 picks->hide();
483 picks->resetState(); 483 picks->resetState();
484 //move(x(), y() + picks->height()); 484 //move(x(), y() + picks->height());
485 //adjustSize(); 485 //adjustSize();
486 QObject::disconnect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), 486 QObject::disconnect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ),
487 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); 487 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) );
488 488
489 } 489 }
490 /* 490 /*
491 * this closes && opens the input method 491 * this closes && opens the input method
492 */ 492 */
493 QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); 493 QCopChannel::send ("QPE/TaskBar", "hideInputMethod()");
494 QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); 494 QCopChannel::send ("QPE/TaskBar", "showInputMethod()");
495} 495}
496 496
497/* Keyboard::setMapTo ... {{{1 */ 497/* Keyboard::setMapTo ... {{{1 */
498void Keyboard::setMapToDefault() { 498void Keyboard::setMapToDefault() {
499 499
500 500
501 /* load current locale language map */ 501 /* load current locale language map */
502 Config *config = new Config("locale"); 502 Config *config = new Config("locale");
503 config->setGroup( "Language" ); 503 config->setGroup( "Language" );
504 QString l = config->readEntry( "Language" , "en" ); 504 QString l = config->readEntry( "Language" , "en" );
505 delete config; 505 delete config;
506 506
507 QString key_map = QPEApplication::qpeDir() + "/share/multikey/" 507 QString key_map = QPEApplication::qpeDir() + "/share/multikey/"
508 + l + ".keymap"; 508 + l + ".keymap";
509 509
510 /* save change to multikey config file */ 510 /* save change to multikey config file */
511 config = new Config("multikey"); 511 config = new Config("multikey");
512 config->setGroup ("keymaps"); 512 config->setGroup ("keymaps");
513 config->writeEntry ("current", key_map); // default closed 513 config->writeEntry ("current", key_map); // default closed
514 delete config; 514 delete config;
515 515
516 delete keys; 516 delete keys;
517 keys = new Keys(key_map); 517 keys = new Keys(key_map);
518 518
519 // have to repaint the keyboard 519 // have to repaint the keyboard
520 repaint(FALSE); 520 repaint(FALSE);
521} 521}
522 522
523void Keyboard::setMapToFile(QString file) { 523void Keyboard::setMapToFile(QString file) {
524 524
525 /* save change to multikey config file */ 525 /* save change to multikey config file */
526 Config *config = new Config("multikey"); 526 Config *config = new Config("multikey");
527 config->setGroup ("keymaps"); 527 config->setGroup ("keymaps");
528 config->writeEntry ("current", file); // default closed 528 config->writeEntry ("current", file); // default closed
529 delete config; 529 delete config;
530 530
531 delete keys; 531 delete keys;
532 keys = new Keys(file); 532 keys = new Keys(file);
533 repaint(FALSE); 533 repaint(FALSE);
534 534
535} 535}
536 536
537/* korean input functions {{{1 537/* korean input functions {{{1
538 * 538 *
539 * TODO 539 * TODO
540 * one major problem with this implementation is that you can't move the 540 * one major problem with this implementation is that you can't move the
541 * cursor after inputing korean chars, otherwise it will eat up and replace 541 * cursor after inputing korean chars, otherwise it will eat up and replace
542 * the char before the cursor you move to. fix that 542 * the char before the cursor you move to. fix that
543 * 543 *
544 * make backspace delete one single char, not the whole thing if still 544 * make backspace delete one single char, not the whole thing if still
545 * editing. 545 * editing.
546 * 546 *
547 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 547 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
548 * 548 *
549 * how korean input works 549 * how korean input works
550 * 550 *
551 * all following chars means unicode char value and are in hex 551 * all following chars means unicode char value and are in hex
552 * 552 *
553 * ÃÊÀ½ = schar (start char) 553 * ÃÊÀ½ = schar (start char)
554 * ÁßÀ½ = mchar (middle char) 554 * ÁßÀ½ = mchar (middle char)