author | hash <hash> | 2002-08-18 06:18:18 (UTC) |
---|---|---|
committer | hash <hash> | 2002-08-18 06:18:18 (UTC) |
commit | 229a66f5a955ec71bd5973ac6961cd694692856a (patch) (unidiff) | |
tree | e2fa7e43d90728b972933e3fca77a897aa376287 /inputmethods/multikey/keyboard.cpp | |
parent | 5f271187a72b18339310f12a2c753e9b8548c078 (diff) | |
download | opie-229a66f5a955ec71bd5973ac6961cd694692856a.zip opie-229a66f5a955ec71bd5973ac6961cd694692856a.tar.gz opie-229a66f5a955ec71bd5973ac6961cd694692856a.tar.bz2 |
paths to maps are now saved in config dialog
Diffstat (limited to 'inputmethods/multikey/keyboard.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | inputmethods/multikey/keyboard.cpp | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp index 671868c..c53ae6c 100644 --- a/inputmethods/multikey/keyboard.cpp +++ b/inputmethods/multikey/keyboard.cpp | |||
@@ -24,24 +24,26 @@ | |||
24 | #include <qpe/global.h> | 24 | #include <qpe/global.h> |
25 | #include <qpe/qcopenvelope_qws.h> | 25 | #include <qpe/qcopenvelope_qws.h> |
26 | 26 | ||
27 | #include <qwindowsystem_qws.h> | 27 | #include <qwindowsystem_qws.h> |
28 | #include <qpainter.h> | 28 | #include <qpainter.h> |
29 | #include <qfontmetrics.h> | 29 | #include <qfontmetrics.h> |
30 | #include <qtimer.h> | 30 | #include <qtimer.h> |
31 | #include <qpe/qpeapplication.h> | 31 | #include <qpe/qpeapplication.h> |
32 | #include <qpe/config.h> | 32 | #include <qpe/config.h> |
33 | #include <ctype.h> | 33 | #include <ctype.h> |
34 | #include <qfile.h> | 34 | #include <qfile.h> |
35 | #include <qtextstream.h> | 35 | #include <qtextstream.h> |
36 | #include <qstringlist.h> | ||
37 | #include <iostream.h> | ||
36 | 38 | ||
37 | #include <sys/utsname.h> | 39 | #include <sys/utsname.h> |
38 | 40 | ||
39 | 41 | ||
40 | #define USE_SMALL_BACKSPACE | 42 | #define USE_SMALL_BACKSPACE |
41 | 43 | ||
42 | /* Keyboard::Keyboard {{{1 */ | 44 | /* Keyboard::Keyboard {{{1 */ |
43 | Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : | 45 | Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : |
44 | QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), | 46 | QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), |
45 | alt(0), useLargeKeys(TRUE), usePicks(0), pressedKeyRow(-1), pressedKeyCol(-1), | 47 | alt(0), useLargeKeys(TRUE), usePicks(0), pressedKeyRow(-1), pressedKeyCol(-1), |
46 | unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0), | 48 | unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0), |
47 | configdlg(0) | 49 | configdlg(0) |
@@ -279,26 +281,26 @@ void Keyboard::mousePressEvent(QMouseEvent *e) | |||
279 | if (qkeycode == Qt::Key_F1) { // toggle the pickboard | 281 | if (qkeycode == Qt::Key_F1) { // toggle the pickboard |
280 | 282 | ||
281 | if ( configdlg ) { | 283 | if ( configdlg ) { |
282 | delete (ConfigDlg *) configdlg; | 284 | delete (ConfigDlg *) configdlg; |
283 | configdlg = 0; | 285 | configdlg = 0; |
284 | } | 286 | } |
285 | else { | 287 | else { |
286 | configdlg = new ConfigDlg (); | 288 | configdlg = new ConfigDlg (); |
287 | connect(configdlg, SIGNAL(pickboardToggled(bool)), | 289 | connect(configdlg, SIGNAL(pickboardToggled(bool)), |
288 | this, SLOT(togglePickboard(bool))); | 290 | this, SLOT(togglePickboard(bool))); |
289 | connect(configdlg, SIGNAL(setMapToDefault()), | 291 | connect(configdlg, SIGNAL(setMapToDefault()), |
290 | this, SLOT(setMapToDefault())); | 292 | this, SLOT(setMapToDefault())); |
291 | connect(configdlg, SIGNAL(setMapToFile(QString)), | 293 | connect(configdlg, SIGNAL(setMapToFile(int)), |
292 | this, SLOT(setMapToFile(QString))); | 294 | this, SLOT(setMapToFile(int))); |
293 | configdlg->showMaximized(); | 295 | configdlg->showMaximized(); |
294 | configdlg->show(); | 296 | configdlg->show(); |
295 | configdlg->raise(); | 297 | configdlg->raise(); |
296 | } | 298 | } |
297 | 299 | ||
298 | } else if (qkeycode == Qt::Key_Control) { | 300 | } else if (qkeycode == Qt::Key_Control) { |
299 | ctrl = keys->pressedPtr(row, col); | 301 | ctrl = keys->pressedPtr(row, col); |
300 | need_repaint = TRUE; | 302 | need_repaint = TRUE; |
301 | *ctrl = !keys->pressed(row, col); | 303 | *ctrl = !keys->pressed(row, col); |
302 | 304 | ||
303 | } else if (qkeycode == Qt::Key_Alt) { | 305 | } else if (qkeycode == Qt::Key_Alt) { |
304 | alt = keys->pressedPtr(row, col); | 306 | alt = keys->pressedPtr(row, col); |
@@ -508,44 +510,52 @@ void Keyboard::setMapToDefault() { | |||
508 | /* load current locale language map */ | 510 | /* load current locale language map */ |
509 | Config *config = new Config("locale"); | 511 | Config *config = new Config("locale"); |
510 | config->setGroup( "Language" ); | 512 | config->setGroup( "Language" ); |
511 | QString l = config->readEntry( "Language" , "en" ); | 513 | QString l = config->readEntry( "Language" , "en" ); |
512 | delete config; | 514 | delete config; |
513 | 515 | ||
514 | QString key_map = QPEApplication::qpeDir() + "/share/multikey/" | 516 | QString key_map = QPEApplication::qpeDir() + "/share/multikey/" |
515 | + l + ".keymap"; | 517 | + l + ".keymap"; |
516 | 518 | ||
517 | /* save change to multikey config file */ | 519 | /* save change to multikey config file */ |
518 | config = new Config("multikey"); | 520 | config = new Config("multikey"); |
519 | config->setGroup ("keymaps"); | 521 | config->setGroup ("keymaps"); |
520 | config->writeEntry ("current", key_map); // default closed | 522 | config->writeEntry ("current", -1); // default closed |
521 | delete config; | 523 | delete config; |
522 | 524 | ||
523 | delete keys; | 525 | delete keys; |
524 | keys = new Keys(key_map); | 526 | keys = new Keys(key_map); |
525 | 527 | ||
526 | // have to repaint the keyboard | 528 | // have to repaint the keyboard |
527 | repaint(FALSE); | 529 | repaint(FALSE); |
528 | } | 530 | } |
529 | 531 | ||
530 | void Keyboard::setMapToFile(QString file) { | 532 | void Keyboard::setMapToFile(int index) { |
531 | 533 | ||
532 | /* save change to multikey config file */ | 534 | /* save change to multikey config file */ |
533 | Config *config = new Config("multikey"); | 535 | Config *config = new Config("multikey"); |
534 | config->setGroup ("keymaps"); | 536 | config->setGroup ("keymaps"); |
535 | config->writeEntry ("current", file); // default closed | 537 | config->writeEntry ("current", index); // default closed |
538 | |||
539 | |||
540 | /* now you have to retrieve the map */ | ||
541 | QStringList maps = config->readListEntry("maps", QChar('|')); | ||
536 | delete config; | 542 | delete config; |
537 | 543 | ||
538 | delete keys; | 544 | delete keys; |
539 | keys = new Keys(file); | 545 | if (index < 0 || (int)maps.count() <= index) |
546 | keys = new Keys(); | ||
547 | else | ||
548 | keys = new Keys(maps[index]); | ||
549 | |||
540 | repaint(FALSE); | 550 | repaint(FALSE); |
541 | 551 | ||
542 | } | 552 | } |
543 | 553 | ||
544 | /* korean input functions {{{1 | 554 | /* korean input functions {{{1 |
545 | * | 555 | * |
546 | * TODO | 556 | * TODO |
547 | * one major problem with this implementation is that you can't move the | 557 | * one major problem with this implementation is that you can't move the |
548 | * cursor after inputing korean chars, otherwise it will eat up and replace | 558 | * cursor after inputing korean chars, otherwise it will eat up and replace |
549 | * the char before the cursor you move to. fix that | 559 | * the char before the cursor you move to. fix that |
550 | * | 560 | * |
551 | * make backspace delete one single char, not the whole thing if still | 561 | * make backspace delete one single char, not the whole thing if still |
@@ -840,37 +850,44 @@ ushort Keyboard::constoe(const ushort c) { | |||
840 | } | 850 | } |
841 | 851 | ||
842 | } | 852 | } |
843 | } | 853 | } |
844 | 854 | ||
845 | 855 | ||
846 | // Keys::Keys {{{1 | 856 | // Keys::Keys {{{1 |
847 | 857 | ||
848 | Keys::Keys() { | 858 | Keys::Keys() { |
849 | 859 | ||
850 | Config *config = new Config ("multikey"); | 860 | Config *config = new Config ("multikey"); |
851 | config->setGroup( "keymaps" ); | 861 | config->setGroup( "keymaps" ); |
852 | QString key_map = config->readEntry( "current" ); | 862 | QStringList maps = config->readListEntry ("maps", QChar('|')); |
863 | |||
864 | int index = config->readNumEntry( "current", -1 ); | ||
853 | delete config; | 865 | delete config; |
854 | 866 | ||
855 | if (key_map.isNull()) { | 867 | QString key_map; |
868 | |||
869 | if (index < 0 || (int)maps.count() <= index) { | ||
856 | 870 | ||
857 | Config *config = new Config("locale"); | 871 | Config *config = new Config("locale"); |
858 | config->setGroup( "Language" ); | 872 | config->setGroup( "Language" ); |
859 | QString l = config->readEntry( "Language" , "en" ); | 873 | QString l = config->readEntry( "Language" , "en" ); |
860 | delete config; | 874 | delete config; |
861 | 875 | ||
862 | key_map = QPEApplication::qpeDir() + "/share/multikey/" | 876 | key_map = QPEApplication::qpeDir() + "/share/multikey/" |
863 | + l + ".keymap"; | 877 | + l + ".keymap"; |
864 | 878 | ||
879 | } else { | ||
880 | |||
881 | key_map = maps[index]; | ||
865 | } | 882 | } |
866 | 883 | ||
867 | 884 | ||
868 | setKeysFromFile(key_map); | 885 | setKeysFromFile(key_map); |
869 | } | 886 | } |
870 | 887 | ||
871 | Keys::Keys(const char * filename) { | 888 | Keys::Keys(const char * filename) { |
872 | 889 | ||
873 | setKeysFromFile(filename); | 890 | setKeysFromFile(filename); |
874 | } | 891 | } |
875 | 892 | ||
876 | // Keys::setKeysFromFile {{{2 | 893 | // Keys::setKeysFromFile {{{2 |