summaryrefslogtreecommitdiff
path: root/inputmethods/multikey/keyboard.cpp
authorhash <hash>2002-08-19 05:35:38 (UTC)
committer hash <hash>2002-08-19 05:35:38 (UTC)
commit64a00421be85d223072e087d4d3c9ecdad464095 (patch) (unidiff)
tree66cf285aa1a8d17126c5b59125c7d91fc2c08c45 /inputmethods/multikey/keyboard.cpp
parentd92fbca743e676182a8f33ae4c28044031143fb0 (diff)
downloadopie-64a00421be85d223072e087d4d3c9ecdad464095.zip
opie-64a00421be85d223072e087d4d3c9ecdad464095.tar.gz
opie-64a00421be85d223072e087d4d3c9ecdad464095.tar.bz2
now reads maps in default dir, and also lets you add/remove your own maps
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
@@ -290,8 +290,8 @@ void Keyboard::mousePressEvent(QMouseEvent *e)
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();
@@ -519,7 +519,7 @@ void Keyboard::setMapToDefault() {
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;
@@ -529,23 +529,20 @@ void Keyboard::setMapToDefault() {
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
@@ -859,30 +856,22 @@ 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 { 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) {