summaryrefslogtreecommitdiff
path: root/inputmethods/multikey
authorhash <hash>2002-08-15 09:49:41 (UTC)
committer hash <hash>2002-08-15 09:49:41 (UTC)
commit56d64478a06c6d4bf137e2e0dcf5ed7d85dadb71 (patch) (unidiff)
tree55037c6d09c9b2324a3a02d4c3a89db95e586ee1 /inputmethods/multikey
parentb54a9a4b4188ff4759574028f7ea0e231ee6bed3 (diff)
downloadopie-56d64478a06c6d4bf137e2e0dcf5ed7d85dadb71.zip
opie-56d64478a06c6d4bf137e2e0dcf5ed7d85dadb71.tar.gz
opie-56d64478a06c6d4bf137e2e0dcf5ed7d85dadb71.tar.bz2
keymap dynamic loading works, but no file select dialog. remembers your selected keymap too
Diffstat (limited to 'inputmethods/multikey') (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/multikey/configdlg.cpp26
-rw-r--r--inputmethods/multikey/configdlg.h5
-rw-r--r--inputmethods/multikey/keyboard.cpp158
-rw-r--r--inputmethods/multikey/keyboard.h8
4 files changed, 152 insertions, 45 deletions
diff --git a/inputmethods/multikey/configdlg.cpp b/inputmethods/multikey/configdlg.cpp
index e39fa6a..68c31be 100644
--- a/inputmethods/multikey/configdlg.cpp
+++ b/inputmethods/multikey/configdlg.cpp
@@ -42,6 +42,14 @@ ConfigDlg::ConfigDlg () : QTabWidget ()
42 42
43 QComboBox *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));
45
44 QString cur(tr("Current Language")); 46 QString cur(tr("Current Language"));
45 combo->insertItem(cur); 47 map_combo->insertItem(cur);
46 combo->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); 48 connect(map_combo, SIGNAL(activated(int)), SLOT(setMap(int)));
49
50 QString ko(tr("/opt/opie/share/multikey/ko.keymap"));
51 map_combo->insertItem(ko);
52
53 QString en(tr("/opt/opie/share/multikey/en.keymap"));
54 map_combo->insertItem(en);
47 55
@@ -100 +108,13 @@ void ConfigDlg::pickTog() {
100} 108}
109
110void ConfigDlg::setMap(int index) {
111
112 if (index == 0) {
113
114 emit setMapToDefault();
115 }
116 else {
117
118 emit setMapToFile(map_combo->text(index));
119 }
120}
diff --git a/inputmethods/multikey/configdlg.h b/inputmethods/multikey/configdlg.h
index 21bdb17..54127a0 100644
--- a/inputmethods/multikey/configdlg.h
+++ b/inputmethods/multikey/configdlg.h
@@ -3,2 +3,3 @@
3#include <qcheckbox.h> 3#include <qcheckbox.h>
4#include <qcombobox.h>
4 5
@@ -16,2 +17,4 @@ signals:
16 void pickboardToggled(bool on_off); 17 void pickboardToggled(bool on_off);
18 void setMapToDefault();
19 void setMapToFile(QString file);
17 20
@@ -19,2 +22,3 @@ private slots:
19 void pickTog(); 22 void pickTog();
23 void setMap(int index);
20 24
@@ -22,2 +26,3 @@ private:
22 QCheckBox *pick_button; 26 QCheckBox *pick_button;
27 QComboBox *map_combo;
23 28
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp
index a19f07a..1d91b82 100644
--- a/inputmethods/multikey/keyboard.cpp
+++ b/inputmethods/multikey/keyboard.cpp
@@ -35,2 +35,3 @@
35#include <qtextstream.h> 35#include <qtextstream.h>
36#include <iostream.h>
36 37
@@ -45,3 +46,3 @@ Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) :
45 alt(0), useLargeKeys(TRUE), usePicks(0), pressedKeyRow(-1), pressedKeyCol(-1), 46 alt(0), useLargeKeys(TRUE), usePicks(0), pressedKeyRow(-1), pressedKeyCol(-1),
46 unicode(-1), qkeycode(0), modifiers(0), LANG("ko"), schar(0), mchar(0), echar(0), 47 unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0),
47 configdlg(0) 48 configdlg(0)
@@ -50,9 +51,11 @@ Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) :
50 // get the default font 51 // get the default font
51 Config qpeConfig( "qpe" ); 52 Config *config = new Config( "qpe" );
52 qpeConfig.setGroup( "Appearance" ); 53 config->setGroup( "Appearance" );
53 QString familyStr = qpeConfig.readEntry( "FontFamily", "fixed" ); 54 QString familyStr = config->readEntry( "FontFamily", "fixed" );
55 delete config;
54 56
55 Config multiConfig ("multikey"); 57 config = new Config("multikey");
56 multiConfig.setGroup ("pickboard"); 58 config->setGroup ("pickboard");
57 usePicks = multiConfig.readBoolEntry ("open", "0"); // default closed 59 usePicks = config->readBoolEntry ("open", "0"); // default closed
60 delete config;
58 61
@@ -70,5 +73,3 @@ Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) :
70 73
71 Config config("locale"); 74 keys = new Keys();
72 config.setGroup( "Language" );
73 LANG = config.readEntry( "Language", "en" );
74 75
@@ -160,3 +161,3 @@ void Keyboard::drawKeyboard(QPainter &p, int row, int col)
160 161
161 x += keys.width(row, i) * defaultKeyWidth; 162 x += keys->width(row, i) * defaultKeyWidth;
162 } 163 }
@@ -164,3 +165,3 @@ void Keyboard::drawKeyboard(QPainter &p, int row, int col)
164 165
165 int keyWidth = keys.width(row, col); 166 int keyWidth = keys->width(row, col);
166 167
@@ -168,7 +169,7 @@ void Keyboard::drawKeyboard(QPainter &p, int row, int col)
168 keyWidth * defaultKeyWidth - 1, keyHeight - 1, 169 keyWidth * defaultKeyWidth - 1, keyHeight - 1,
169 pressed || keys.pressed(row, col) ? keycolor_pressed : keycolor); 170 pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor);
170 171
171 QPixmap *pix = keys.pix(row,col); 172 QPixmap *pix = keys->pix(row,col);
172 173
173 ushort c = keys.uni(row, col); 174 ushort c = keys->uni(row, col);
174 175
@@ -178,3 +179,3 @@ void Keyboard::drawKeyboard(QPainter &p, int row, int col)
178 defaultKeyWidth * keyWidth, keyHeight, 179 defaultKeyWidth * keyWidth, keyHeight,
179 AlignCenter, ((shift || lock) && keys.shift(c)) ? (QChar)keys.shift(c) : (QChar)c); 180 AlignCenter, ((shift || lock) && keys->shift(c)) ? (QChar)keys->shift(c) : (QChar)c);
180 } 181 }
@@ -204,6 +205,6 @@ void Keyboard::drawKeyboard(QPainter &p, int row, int col)
204 205
205 for (int col = 0; col < keys.numKeys(row); col++) { 206 for (int col = 0; col < keys->numKeys(row); col++) {
206 207
207 QPixmap *pix = keys.pix(row, col); 208 QPixmap *pix = keys->pix(row, col);
208 int keyWidth = keys.width(row, col); 209 int keyWidth = keys->width(row, col);
209 210
@@ -212,3 +213,3 @@ void Keyboard::drawKeyboard(QPainter &p, int row, int col)
212 213
213 if (keys.pressed(row, col)) 214 if (keys->pressed(row, col))
214 p.fillRect(x+1, y+1, keyWidthPix - 1, 215 p.fillRect(x+1, y+1, keyWidthPix - 1,
@@ -216,3 +217,3 @@ void Keyboard::drawKeyboard(QPainter &p, int row, int col)
216 217
217 ushort c = keys.uni(row, col); 218 ushort c = keys->uni(row, col);
218 219
@@ -222,3 +223,3 @@ void Keyboard::drawKeyboard(QPainter &p, int row, int col)
222 keyWidthPix, keyHeight, 223 keyWidthPix, keyHeight,
223 AlignCenter, ((shift || lock) && keys.shift(c)) ? (QChar)keys.shift(c) : (QChar)c); 224 AlignCenter, ((shift || lock) && keys->shift(c)) ? (QChar)keys->shift(c) : (QChar)c);
224 } 225 }
@@ -255,4 +256,4 @@ void Keyboard::mousePressEvent(QMouseEvent *e)
255 for (int w = 0; e->x() >= w; col++) 256 for (int w = 0; e->x() >= w; col++)
256 if (col < keys.numKeys(row)) // it segfaults if it trys to read past numKeys 257 if (col < keys->numKeys(row)) // it segfaults if it trys to read past numKeys
257 w += keys.width(row,col) * defaultKeyWidth; 258 w += keys->width(row,col) * defaultKeyWidth;
258 else break; 259 else break;
@@ -261,4 +262,4 @@ void Keyboard::mousePressEvent(QMouseEvent *e)
261 262
262 qkeycode = keys.qcode(row, col); 263 qkeycode = keys->qcode(row, col);
263 unicode = keys.uni(row, col); 264 unicode = keys->uni(row, col);
264 265
@@ -280,2 +281,6 @@ void Keyboard::mousePressEvent(QMouseEvent *e)
280 this, SLOT(togglePickboard(bool))); 281 this, SLOT(togglePickboard(bool)));
282 connect(configdlg, SIGNAL(setMapToDefault()),
283 this, SLOT(setMapToDefault()));
284 connect(configdlg, SIGNAL(setMapToFile(QString)),
285 this, SLOT(setMapToFile(QString)));
281 configdlg->showMaximized(); 286 configdlg->showMaximized();
@@ -286,10 +291,10 @@ void Keyboard::mousePressEvent(QMouseEvent *e)
286 } else if (qkeycode == Qt::Key_Control) { 291 } else if (qkeycode == Qt::Key_Control) {
287 ctrl = keys.pressedPtr(row, col); 292 ctrl = keys->pressedPtr(row, col);
288 need_repaint = TRUE; 293 need_repaint = TRUE;
289 *ctrl = !keys.pressed(row, col); 294 *ctrl = !keys->pressed(row, col);
290 295
291 } else if (qkeycode == Qt::Key_Alt) { 296 } else if (qkeycode == Qt::Key_Alt) {
292 alt = keys.pressedPtr(row, col); 297 alt = keys->pressedPtr(row, col);
293 need_repaint = TRUE; 298 need_repaint = TRUE;
294 *alt = !keys.pressed(row, col); 299 *alt = !keys->pressed(row, col);
295 300
@@ -303,3 +308,3 @@ void Keyboard::mousePressEvent(QMouseEvent *e)
303 else { 308 else {
304 shift = keys.pressedPtr(row, col); 309 shift = keys->pressedPtr(row, col);
305 *shift = 1; 310 *shift = 1;
@@ -319,3 +324,3 @@ void Keyboard::mousePressEvent(QMouseEvent *e)
319 else { 324 else {
320 lock = keys.pressedPtr(row, col);; 325 lock = keys->pressedPtr(row, col);;
321 *lock = 1; 326 *lock = 1;
@@ -331,4 +336,4 @@ void Keyboard::mousePressEvent(QMouseEvent *e)
331 else { // normal char 336 else { // normal char
332 if ((shift || lock) && keys.shift(unicode)) { 337 if ((shift || lock) && keys->shift(unicode)) {
333 unicode = keys.shift(unicode); 338 unicode = keys->shift(unicode);
334 } 339 }
@@ -337,3 +342,3 @@ void Keyboard::mousePressEvent(QMouseEvent *e)
337 // korean parsing 342 // korean parsing
338 if (LANG == "ko") { 343 if (keys->lang == "ko") {
339 344
@@ -491,2 +496,42 @@ void Keyboard::togglePickboard(bool on_off)
491 496
497/* Keyboard::setMapTo ... {{{1 */
498void Keyboard::setMapToDefault() {
499
500
501 /* load current locale language map */
502 Config *config = new Config("locale");
503 config->setGroup( "Language" );
504 QString l = config->readEntry( "Language" , "en" );
505 delete config;
506
507 QString key_map = QPEApplication::qpeDir() + "/share/multikey/"
508 + l + ".keymap";
509
510 /* save change to multikey config file */
511 config = new Config("multikey");
512 config->setGroup ("keymaps");
513 config->writeEntry ("current", key_map); // default closed
514 delete config;
515
516 delete keys;
517 keys = new Keys(key_map);
518
519 // have to repaint the keyboard
520 repaint(FALSE);
521}
522
523void Keyboard::setMapToFile(QString file) {
524
525 /* save change to multikey config file */
526 Config *config = new Config("multikey");
527 config->setGroup ("keymaps");
528 config->writeEntry ("current", file); // default closed
529 delete config;
530
531 delete keys;
532 keys = new Keys(file);
533 repaint(FALSE);
534
535}
536
492/* korean input functions {{{1 537/* korean input functions {{{1
@@ -797,8 +842,19 @@ Keys::Keys() {
797 842
798 Config config("locale"); 843 Config *config = new Config ("multikey");
799 config.setGroup( "Language" ); 844 config->setGroup( "keymaps" );
800 QString l = config.readEntry( "Language" , "en" ); 845 QString key_map = config->readEntry( "current" );
846 delete config;
847
848 if (key_map.isNull()) {
849
850 Config *config = new Config("locale");
851 config->setGroup( "Language" );
852 QString l = config->readEntry( "Language" , "en" );
853 delete config;
854
855 key_map = QPEApplication::qpeDir() + "/share/multikey/"
856 + l + ".keymap";
857
858 }
801 859
802 QString key_map = QPEApplication::qpeDir() + "/share/multikey/"
803 + l + ".keymap";
804 860
@@ -832,2 +888,3 @@ void Keys::setKeysFromFile(const char * filename) {
832 888
889 // key definition
833 if (buf.contains(QRegExp("^\\d+\\s+[0-1a-fx]+", FALSE, FALSE))) { 890 if (buf.contains(QRegExp("^\\d+\\s+[0-1a-fx]+", FALSE, FALSE))) {
@@ -877,2 +934,4 @@ void Keys::setKeysFromFile(const char * filename) {
877 } 934 }
935
936 // shift map
878 else if (buf.contains(QRegExp("^[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { 937 else if (buf.contains(QRegExp("^[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) {
@@ -887,2 +946,21 @@ void Keys::setKeysFromFile(const char * filename) {
887 } 946 }
947
948 // other variables like lang & title
949 else if (buf.contains(QRegExp("^\\s*[a-zA-Z]+\\s*=\\s*[a-zA-Z0-9/]+\\s*$", FALSE, FALSE))) {
950
951 QTextStream tmp (buf, IO_ReadOnly);
952 QString name, equals, value;
953
954 tmp >> name >> equals >> value;
955
956 if (name == "lang") {
957
958 lang = value;
959
960 }
961
962 cout << name << " = " << value << "\n";
963 buf = t.readLine();
964 }
965 // comments
888 else if (buf.contains(QRegExp("^\\s*#"))) { 966 else if (buf.contains(QRegExp("^\\s*#"))) {
diff --git a/inputmethods/multikey/keyboard.h b/inputmethods/multikey/keyboard.h
index e61b76c..c2efe10 100644
--- a/inputmethods/multikey/keyboard.h
+++ b/inputmethods/multikey/keyboard.h
@@ -69,2 +69,4 @@ public:
69 void setPressed(const int row, const int col, const bool pressed); 69 void setPressed(const int row, const int col, const bool pressed);
70 QString lang;
71 QString title;
70 72
@@ -110,2 +112,4 @@ private slots:
110 void togglePickboard(bool on_off); 112 void togglePickboard(bool on_off);
113 void setMapToDefault();
114 void setMapToFile(QString file);
111 115
@@ -138,4 +142,4 @@ private:
138 142
139 Keys keys; 143 Keys *keys;
140 QString LANG; 144
141 /* for korean input */ 145 /* for korean input */