Diffstat (limited to 'inputmethods/multikey/keyboard.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | inputmethods/multikey/keyboard.cpp | 35 |
1 files changed, 12 insertions, 23 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 | |||
@@ -287,14 +287,14 @@ void Keyboard::mousePressEvent(QMouseEvent *e) | |||
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) { |
@@ -516,39 +516,36 @@ void Keyboard::setMapToDefault() { | |||
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 | ||
532 | void Keyboard::setMapToFile(int index) { | 532 | void 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 |
@@ -856,36 +853,28 @@ ushort Keyboard::constoe(const ushort c) { | |||
856 | // Keys::Keys {{{1 | 853 | // Keys::Keys {{{1 |
857 | 854 | ||
858 | Keys::Keys() { | 855 | Keys::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 { | ||
880 | |||
881 | key_map = maps[index]; | ||
882 | } | 872 | } |
883 | 873 | ||
884 | 874 | setKeysFromFile(map); | |
885 | setKeysFromFile(key_map); | ||
886 | } | 875 | } |
887 | 876 | ||
888 | Keys::Keys(const char * filename) { | 877 | Keys::Keys(const char * filename) { |
889 | 878 | ||
890 | setKeysFromFile(filename); | 879 | setKeysFromFile(filename); |
891 | } | 880 | } |