summaryrefslogtreecommitdiff
path: root/inputmethods/multikey/keyboard.cpp
Unidiff
Diffstat (limited to 'inputmethods/multikey/keyboard.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/multikey/keyboard.cpp37
1 files changed, 13 insertions, 24 deletions
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp
index c53ae6c..ac3d9be 100644
--- a/inputmethods/multikey/keyboard.cpp
+++ b/inputmethods/multikey/keyboard.cpp
@@ -269,50 +269,50 @@ void Keyboard::mousePressEvent(QMouseEvent *e)
269 269
270 col --; // rewind one... 270 col --; // rewind one...
271 271
272 qkeycode = keys->qcode(row, col); 272 qkeycode = keys->qcode(row, col);
273 unicode = keys->uni(row, col); 273 unicode = keys->uni(row, col);
274 274
275 // might need to repaint if two or more of the same keys. 275 // 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. 276 // should be faster if just paint one key even though multiple keys exist.
277 bool need_repaint = FALSE; 277 bool need_repaint = FALSE;
278 278
279 if (unicode == 0) { // either Qt char, or nothing 279 if (unicode == 0) { // either Qt char, or nothing
280 280
281 if (qkeycode == Qt::Key_F1) { // toggle the pickboard 281 if (qkeycode == Qt::Key_F1) { // toggle the pickboard
282 282
283 if ( configdlg ) { 283 if ( configdlg ) {
284 delete (ConfigDlg *) configdlg; 284 delete (ConfigDlg *) configdlg;
285 configdlg = 0; 285 configdlg = 0;
286 } 286 }
287 else { 287 else {
288 configdlg = new ConfigDlg (); 288 configdlg = new ConfigDlg ();
289 connect(configdlg, SIGNAL(pickboardToggled(bool)), 289 connect(configdlg, SIGNAL(pickboardToggled(bool)),
290 this, SLOT(togglePickboard(bool))); 290 this, SLOT(togglePickboard(bool)));
291 connect(configdlg, SIGNAL(setMapToDefault()), 291 connect(configdlg, SIGNAL(setMapToDefault()),
292 this, SLOT(setMapToDefault())); 292 this, SLOT(setMapToDefault()));
293 connect(configdlg, SIGNAL(setMapToFile(int)), 293 connect(configdlg, SIGNAL(setMapToFile(QString)),
294 this, SLOT(setMapToFile(int))); 294 this, SLOT(setMapToFile(QString)));
295 configdlg->showMaximized(); 295 configdlg->showMaximized();
296 configdlg->show(); 296 configdlg->show();
297 configdlg->raise(); 297 configdlg->raise();
298 } 298 }
299 299
300 } else if (qkeycode == Qt::Key_Control) { 300 } else if (qkeycode == Qt::Key_Control) {
301 ctrl = keys->pressedPtr(row, col); 301 ctrl = keys->pressedPtr(row, col);
302 need_repaint = TRUE; 302 need_repaint = TRUE;
303 *ctrl = !keys->pressed(row, col); 303 *ctrl = !keys->pressed(row, col);
304 304
305 } else if (qkeycode == Qt::Key_Alt) { 305 } else if (qkeycode == Qt::Key_Alt) {
306 alt = keys->pressedPtr(row, col); 306 alt = keys->pressedPtr(row, col);
307 need_repaint = TRUE; 307 need_repaint = TRUE;
308 *alt = !keys->pressed(row, col); 308 *alt = !keys->pressed(row, col);
309 309
310 } else if (qkeycode == Qt::Key_Shift) { 310 } else if (qkeycode == Qt::Key_Shift) {
311 need_repaint = TRUE; 311 need_repaint = TRUE;
312 312
313 if (shift) { 313 if (shift) {
314 *shift = 0; 314 *shift = 0;
315 shift = 0; 315 shift = 0;
316 } 316 }
317 else { 317 else {
318 shift = keys->pressedPtr(row, col); 318 shift = keys->pressedPtr(row, col);
@@ -498,75 +498,72 @@ void Keyboard::togglePickboard(bool on_off)
498 } 498 }
499 /* 499 /*
500 * this closes && opens the input method 500 * this closes && opens the input method
501 */ 501 */
502 QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); 502 QCopChannel::send ("QPE/TaskBar", "hideInputMethod()");
503 QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); 503 QCopChannel::send ("QPE/TaskBar", "showInputMethod()");
504} 504}
505 505
506/* Keyboard::setMapTo ... {{{1 */ 506/* Keyboard::setMapTo ... {{{1 */
507void Keyboard::setMapToDefault() { 507void Keyboard::setMapToDefault() {
508 508
509 509
510 /* load current locale language map */ 510 /* load current locale language map */
511 Config *config = new Config("locale"); 511 Config *config = new Config("locale");
512 config->setGroup( "Language" ); 512 config->setGroup( "Language" );
513 QString l = config->readEntry( "Language" , "en" ); 513 QString l = config->readEntry( "Language" , "en" );
514 delete config; 514 delete config;
515 515
516 QString key_map = QPEApplication::qpeDir() + "/share/multikey/" 516 QString key_map = QPEApplication::qpeDir() + "/share/multikey/"
517 + l + ".keymap"; 517 + l + ".keymap";
518 518
519 /* save change to multikey config file */ 519 /* save change to multikey config file */
520 config = new Config("multikey"); 520 config = new Config("multikey");
521 config->setGroup ("keymaps"); 521 config->setGroup ("keymaps");
522 config->writeEntry ("current", -1); // default closed 522 config->writeEntry ("current", key_map); // default closed
523 delete config; 523 delete config;
524 524
525 delete keys; 525 delete keys;
526 keys = new Keys(key_map); 526 keys = new Keys(key_map);
527 527
528 // have to repaint the keyboard 528 // have to repaint the keyboard
529 repaint(FALSE); 529 repaint(FALSE);
530} 530}
531 531
532void Keyboard::setMapToFile(int index) { 532void Keyboard::setMapToFile(QString map) {
533 533
534 /* save change to multikey config file */ 534 /* save change to multikey config file */
535 Config *config = new Config("multikey"); 535 Config *config = new Config("multikey");
536 config->setGroup ("keymaps"); 536 config->setGroup ("keymaps");
537 config->writeEntry ("current", index); // default closed 537 config->writeEntry ("current", map); // default closed
538 538
539
540 /* now you have to retrieve the map */
541 QStringList maps = config->readListEntry("maps", QChar('|'));
542 delete config; 539 delete config;
543 540
544 delete keys; 541 delete keys;
545 if (index < 0 || (int)maps.count() <= index) 542 if (QFile(map).exists())
546 keys = new Keys(); 543 keys = new Keys(map);
547 else 544 else
548 keys = new Keys(maps[index]); 545 keys = new Keys();
549 546
550 repaint(FALSE); 547 repaint(FALSE);
551 548
552} 549}
553 550
554/* korean input functions {{{1 551/* korean input functions {{{1
555 * 552 *
556 * TODO 553 * TODO
557 * one major problem with this implementation is that you can't move the 554 * one major problem with this implementation is that you can't move the
558 * cursor after inputing korean chars, otherwise it will eat up and replace 555 * cursor after inputing korean chars, otherwise it will eat up and replace
559 * the char before the cursor you move to. fix that 556 * the char before the cursor you move to. fix that
560 * 557 *
561 * make backspace delete one single char, not the whole thing if still 558 * make backspace delete one single char, not the whole thing if still
562 * editing. 559 * editing.
563 * 560 *
564 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 561 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
565 * 562 *
566 * how korean input works 563 * how korean input works
567 * 564 *
568 * all following chars means unicode char value and are in hex 565 * all following chars means unicode char value and are in hex
569 * 566 *
570 * ÃÊÀ½ = schar (start char) 567 * ÃÊÀ½ = schar (start char)
571 * ÁßÀ½ = mchar (middle char) 568 * ÁßÀ½ = mchar (middle char)
572 * ³¡À½ = echar (end char) 569 * ³¡À½ = echar (end char)
@@ -838,72 +835,64 @@ ushort Keyboard::constoe(const ushort c) {
838 case 0x11b8: return 0x1107; 835 case 0x11b8: return 0x1107;
839 case 0x11ba: return 0x1109; 836 case 0x11ba: return 0x1109;
840 case 0x11bb: return 0x110a; 837 case 0x11bb: return 0x110a;
841 case 0x11bc: return 0x110b; 838 case 0x11bc: return 0x110b;
842 case 0x11bd: return 0x110c; 839 case 0x11bd: return 0x110c;
843 case 0x11be: return 0x110e; 840 case 0x11be: return 0x110e;
844 case 0x11bf: return 0x110f; 841 case 0x11bf: return 0x110f;
845 case 0x11c0: return 0x1110; 842 case 0x11c0: return 0x1110;
846 case 0x11c1: return 0x1111; 843 case 0x11c1: return 0x1111;
847 case 0x11c2: return 0x1112; 844 case 0x11c2: return 0x1112;
848 default: return 0; 845 default: return 0;
849 846
850 } 847 }
851 848
852 } 849 }
853} 850}
854 851
855 852
856// Keys::Keys {{{1 853// Keys::Keys {{{1
857 854
858Keys::Keys() { 855Keys::Keys() {
859 856
860 Config *config = new Config ("multikey"); 857 Config *config = new Config ("multikey");
861 config->setGroup( "keymaps" ); 858 config->setGroup( "keymaps" );
862 QStringList maps = config->readListEntry ("maps", QChar('|')); 859 QString map = config->readEntry( "current" );
863
864 int index = config->readNumEntry( "current", -1 );
865 delete config; 860 delete config;
866 861
867 QString key_map; 862 if (map.isNull() || !(QFile(map).exists())) {
868
869 if (index < 0 || (int)maps.count() <= index) {
870 863
871 Config *config = new Config("locale"); 864 Config *config = new Config("locale");
872 config->setGroup( "Language" ); 865 config->setGroup( "Language" );
873 QString l = config->readEntry( "Language" , "en" ); 866 QString l = config->readEntry( "Language" , "en" );
874 delete config; 867 delete config;
875 868
876 key_map = QPEApplication::qpeDir() + "/share/multikey/" 869 map = QPEApplication::qpeDir() + "/share/multikey/"
877 + l + ".keymap"; 870 + l + ".keymap";
878 871
879 } else { 872 }
880
881 key_map = maps[index];
882 }
883
884 873
885 setKeysFromFile(key_map); 874 setKeysFromFile(map);
886} 875}
887 876
888Keys::Keys(const char * filename) { 877Keys::Keys(const char * filename) {
889 878
890 setKeysFromFile(filename); 879 setKeysFromFile(filename);
891} 880}
892 881
893// Keys::setKeysFromFile {{{2 882// Keys::setKeysFromFile {{{2
894void Keys::setKeysFromFile(const char * filename) { 883void Keys::setKeysFromFile(const char * filename) {
895 884
896 QFile f(filename); 885 QFile f(filename);
897 886
898 if (f.open(IO_ReadOnly)) { 887 if (f.open(IO_ReadOnly)) {
899 888
900 QTextStream t(&f); 889 QTextStream t(&f);
901 int row; 890 int row;
902 int qcode; 891 int qcode;
903 ushort unicode; 892 ushort unicode;
904 int width; 893 int width;
905 QString buf; 894 QString buf;
906 QString comment; 895 QString comment;
907 char * xpm[256]; //couldnt be larger than that... could it? 896 char * xpm[256]; //couldnt be larger than that... could it?
908 QPixmap *xpm2pix = 0; 897 QPixmap *xpm2pix = 0;
909 898