author | hash <hash> | 2002-08-14 05:39:42 (UTC) |
---|---|---|
committer | hash <hash> | 2002-08-14 05:39:42 (UTC) |
commit | 13a1334cca686bf512c4a8f94a648ba969b38d22 (patch) (unidiff) | |
tree | 13e46c6b4157b0348f38d952ddc70f6e0fda619b | |
parent | 29ffa9119abaf753b165c5c241b22938eeaef301 (diff) | |
download | opie-13a1334cca686bf512c4a8f94a648ba969b38d22.zip opie-13a1334cca686bf512c4a8f94a648ba969b38d22.tar.gz opie-13a1334cca686bf512c4a8f94a648ba969b38d22.tar.bz2 |
added config dialog. only open/closing pickboard works
-rw-r--r-- | inputmethods/multikey/keyboard.cpp | 67 | ||||
-rw-r--r-- | inputmethods/multikey/keyboard.h | 4 | ||||
-rw-r--r-- | inputmethods/multikey/multikey.pro | 2 |
3 files changed, 53 insertions, 20 deletions
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp index 8f4d562..a19f07a 100644 --- a/inputmethods/multikey/keyboard.cpp +++ b/inputmethods/multikey/keyboard.cpp | |||
@@ -6,61 +6,69 @@ | |||
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "keyboard.h" | 21 | #include "keyboard.h" |
22 | #include "configdlg.h" | ||
22 | 23 | ||
23 | #include <qpe/global.h> | 24 | #include <qpe/global.h> |
25 | #include <qpe/qcopenvelope_qws.h> | ||
24 | 26 | ||
25 | #include <qwindowsystem_qws.h> | 27 | #include <qwindowsystem_qws.h> |
26 | #include <qpainter.h> | 28 | #include <qpainter.h> |
27 | #include <qfontmetrics.h> | 29 | #include <qfontmetrics.h> |
28 | #include <qtimer.h> | 30 | #include <qtimer.h> |
29 | #include <qpe/qpeapplication.h> | 31 | #include <qpe/qpeapplication.h> |
30 | #include <qpe/config.h> | 32 | #include <qpe/config.h> |
31 | #include <ctype.h> | 33 | #include <ctype.h> |
32 | #include <qfile.h> | 34 | #include <qfile.h> |
33 | #include <qtextstream.h> | 35 | #include <qtextstream.h> |
34 | 36 | ||
35 | #include <sys/utsname.h> | 37 | #include <sys/utsname.h> |
36 | 38 | ||
37 | 39 | ||
38 | #define USE_SMALL_BACKSPACE | 40 | #define USE_SMALL_BACKSPACE |
39 | 41 | ||
40 | /* Keyboard::Keyboard {{{1 */ | 42 | /* Keyboard::Keyboard {{{1 */ |
41 | Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : | 43 | Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : |
42 | QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), | 44 | QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), |
43 | alt(0), useLargeKeys(TRUE), usePicks(0), pressedKeyRow(-1), pressedKeyCol(-1), | 45 | alt(0), useLargeKeys(TRUE), usePicks(0), pressedKeyRow(-1), pressedKeyCol(-1), |
44 | unicode(-1), qkeycode(0), modifiers(0), LANG("ko"), schar(0), mchar(0), echar(0) | 46 | unicode(-1), qkeycode(0), modifiers(0), LANG("ko"), schar(0), mchar(0), echar(0), |
47 | configdlg(0) | ||
48 | |||
45 | { | 49 | { |
46 | // get the default font | 50 | // get the default font |
47 | Config qpeConfig( "qpe" ); | 51 | Config qpeConfig( "qpe" ); |
48 | qpeConfig.setGroup( "Appearance" ); | 52 | qpeConfig.setGroup( "Appearance" ); |
49 | QString familyStr = qpeConfig.readEntry( "FontFamily", "fixed" ); | 53 | QString familyStr = qpeConfig.readEntry( "FontFamily", "fixed" ); |
50 | 54 | ||
55 | Config multiConfig ("multikey"); | ||
56 | multiConfig.setGroup ("pickboard"); | ||
57 | usePicks = multiConfig.readBoolEntry ("open", "0"); // default closed | ||
58 | |||
51 | setFont( QFont( familyStr, 8 ) ); | 59 | setFont( QFont( familyStr, 8 ) ); |
52 | 60 | ||
53 | picks = new KeyboardPicks( this ); | 61 | picks = new KeyboardPicks( this ); |
54 | picks->setFont( QFont( familyStr, 8 ) ); | 62 | picks->setFont( QFont( familyStr, 8 ) ); |
55 | picks->initialise(); | 63 | picks->initialise(); |
56 | if (usePicks) { | 64 | if (usePicks) { |
57 | 65 | ||
58 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), | 66 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), |
59 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); | 67 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); |
60 | 68 | ||
61 | } else picks->hide(); | 69 | } else picks->hide(); |
62 | 70 | ||
63 | Config config("locale"); | 71 | Config config("locale"); |
64 | config.setGroup( "Language" ); | 72 | config.setGroup( "Language" ); |
65 | LANG = config.readEntry( "Language", "en" ); | 73 | LANG = config.readEntry( "Language", "en" ); |
66 | 74 | ||
@@ -249,53 +257,45 @@ void Keyboard::mousePressEvent(QMouseEvent *e) | |||
249 | w += keys.width(row,col) * defaultKeyWidth; | 257 | w += keys.width(row,col) * defaultKeyWidth; |
250 | else break; | 258 | else break; |
251 | 259 | ||
252 | col --; // rewind one... | 260 | col --; // rewind one... |
253 | 261 | ||
254 | qkeycode = keys.qcode(row, col); | 262 | qkeycode = keys.qcode(row, col); |
255 | unicode = keys.uni(row, col); | 263 | unicode = keys.uni(row, col); |
256 | 264 | ||
257 | // might need to repaint if two or more of the same keys. | 265 | // might need to repaint if two or more of the same keys. |
258 | // should be faster if just paint one key even though multiple keys exist. | 266 | // should be faster if just paint one key even though multiple keys exist. |
259 | bool need_repaint = FALSE; | 267 | bool need_repaint = FALSE; |
260 | 268 | ||
261 | if (unicode == 0) { // either Qt char, or nothing | 269 | if (unicode == 0) { // either Qt char, or nothing |
262 | 270 | ||
263 | if (qkeycode == Qt::Key_F1) { // toggle the pickboard | 271 | if (qkeycode == Qt::Key_F1) { // toggle the pickboard |
264 | 272 | ||
265 | usePicks = !usePicks; | 273 | if ( configdlg ) { |
266 | if (usePicks) { | 274 | delete (ConfigDlg *) configdlg; |
267 | picks->show(); | 275 | configdlg = 0; |
268 | move(x(), y() - picks->height()); | 276 | } |
269 | adjustSize(); | 277 | else { |
270 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), | 278 | configdlg = new ConfigDlg (); |
271 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); | 279 | connect(configdlg, SIGNAL(pickboardToggled(bool)), |
272 | } else { | 280 | this, SLOT(togglePickboard(bool))); |
273 | 281 | configdlg->showMaximized(); | |
274 | picks->hide(); | 282 | configdlg->show(); |
275 | picks->resetState(); | 283 | configdlg->raise(); |
276 | move(x(), y() + picks->height()); | ||
277 | adjustSize(); | ||
278 | QObject::disconnect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), | ||
279 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); | ||
280 | |||
281 | } | 284 | } |
282 | 285 | ||
283 | keys.setPressed(row, col, usePicks); | ||
284 | need_repaint = TRUE; | ||
285 | qkeycode = 0; // don't need to emit Key_F1 | ||
286 | } else if (qkeycode == Qt::Key_Control) { | 286 | } else if (qkeycode == Qt::Key_Control) { |
287 | ctrl = keys.pressedPtr(row, col); | 287 | ctrl = keys.pressedPtr(row, col); |
288 | need_repaint = TRUE; | 288 | need_repaint = TRUE; |
289 | *ctrl = !keys.pressed(row, col); | 289 | *ctrl = !keys.pressed(row, col); |
290 | 290 | ||
291 | } else if (qkeycode == Qt::Key_Alt) { | 291 | } else if (qkeycode == Qt::Key_Alt) { |
292 | alt = keys.pressedPtr(row, col); | 292 | alt = keys.pressedPtr(row, col); |
293 | need_repaint = TRUE; | 293 | need_repaint = TRUE; |
294 | *alt = !keys.pressed(row, col); | 294 | *alt = !keys.pressed(row, col); |
295 | 295 | ||
296 | } else if (qkeycode == Qt::Key_Shift) { | 296 | } else if (qkeycode == Qt::Key_Shift) { |
297 | need_repaint = TRUE; | 297 | need_repaint = TRUE; |
298 | 298 | ||
299 | if (shift) { | 299 | if (shift) { |
300 | *shift = 0; | 300 | *shift = 0; |
301 | shift = 0; | 301 | shift = 0; |
@@ -449,32 +449,59 @@ void Keyboard::clearHighlight() | |||
449 | /* Keyboard::sizeHint {{{1 */ | 449 | /* Keyboard::sizeHint {{{1 */ |
450 | QSize Keyboard::sizeHint() const | 450 | QSize Keyboard::sizeHint() const |
451 | { | 451 | { |
452 | QFontMetrics fm=fontMetrics(); | 452 | QFontMetrics fm=fontMetrics(); |
453 | int keyHeight = fm.lineSpacing(); | 453 | int keyHeight = fm.lineSpacing(); |
454 | 454 | ||
455 | return QSize( 240, keyHeight * 5 + (usePicks ? picks->sizeHint().height() : 0) + 1); | 455 | return QSize( 240, keyHeight * 5 + (usePicks ? picks->sizeHint().height() : 0) + 1); |
456 | } | 456 | } |
457 | 457 | ||
458 | 458 | ||
459 | void Keyboard::resetState() | 459 | void Keyboard::resetState() |
460 | { | 460 | { |
461 | schar = mchar = echar = 0; | 461 | schar = mchar = echar = 0; |
462 | picks->resetState(); | 462 | picks->resetState(); |
463 | } | 463 | } |
464 | 464 | ||
465 | /* Keyboard::togglePickboard {{{1 */ | ||
466 | void Keyboard::togglePickboard(bool on_off) | ||
467 | { | ||
468 | usePicks = on_off; | ||
469 | if (usePicks) { | ||
470 | picks->show(); | ||
471 | //move(x(), y() - picks->height()); // not required anymore because QCopChannel::send | ||
472 | //adjustSize(); | ||
473 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), | ||
474 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); | ||
475 | } else { | ||
476 | |||
477 | picks->hide(); | ||
478 | picks->resetState(); | ||
479 | //move(x(), y() + picks->height()); | ||
480 | //adjustSize(); | ||
481 | QObject::disconnect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), | ||
482 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); | ||
483 | |||
484 | } | ||
485 | /* | ||
486 | * this closes && opens the input method | ||
487 | */ | ||
488 | QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); | ||
489 | QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); | ||
490 | } | ||
491 | |||
465 | /* korean input functions {{{1 | 492 | /* korean input functions {{{1 |
466 | * | 493 | * |
467 | * TODO | 494 | * TODO |
468 | * one major problem with this implementation is that you can't move the | 495 | * one major problem with this implementation is that you can't move the |
469 | * cursor after inputing korean chars, otherwise it will eat up and replace | 496 | * cursor after inputing korean chars, otherwise it will eat up and replace |
470 | * the char before the cursor you move to. fix that | 497 | * the char before the cursor you move to. fix that |
471 | * | 498 | * |
472 | * make backspace delete one single char, not the whole thing if still | 499 | * make backspace delete one single char, not the whole thing if still |
473 | * editing. | 500 | * editing. |
474 | * | 501 | * |
475 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | 502 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
476 | * | 503 | * |
477 | * how korean input works | 504 | * how korean input works |
478 | * | 505 | * |
479 | * all following chars means unicode char value and are in hex | 506 | * all following chars means unicode char value and are in hex |
480 | * | 507 | * |
diff --git a/inputmethods/multikey/keyboard.h b/inputmethods/multikey/keyboard.h index b524195..e61b76c 100644 --- a/inputmethods/multikey/keyboard.h +++ b/inputmethods/multikey/keyboard.h | |||
@@ -8,32 +8,33 @@ | |||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qframe.h> | 20 | #include <qframe.h> |
21 | #include <qmap.h> | 21 | #include <qmap.h> |
22 | #include "../pickboard/pickboardcfg.h" | 22 | #include "../pickboard/pickboardcfg.h" |
23 | #include "../pickboard/pickboardpicks.h" | 23 | #include "../pickboard/pickboardpicks.h" |
24 | #include "configdlg.h" | ||
24 | 25 | ||
25 | class QTimer; | 26 | class QTimer; |
26 | 27 | ||
27 | class KeyboardConfig : public DictFilterConfig | 28 | class KeyboardConfig : public DictFilterConfig |
28 | { | 29 | { |
29 | public: | 30 | public: |
30 | KeyboardConfig(PickboardPicks* p) : DictFilterConfig(p), backspaces(0) { nrows = 1; } | 31 | KeyboardConfig(PickboardPicks* p) : DictFilterConfig(p), backspaces(0) { nrows = 1; } |
31 | virtual void generateText(const QString &s); | 32 | virtual void generateText(const QString &s); |
32 | void decBackspaces() { if (backspaces) backspaces--; } | 33 | void decBackspaces() { if (backspaces) backspaces--; } |
33 | void incBackspaces() { backspaces++; } | 34 | void incBackspaces() { backspaces++; } |
34 | void resetBackspaces() { backspaces = 0; } | 35 | void resetBackspaces() { backspaces = 0; } |
35 | private: | 36 | private: |
36 | int backspaces; | 37 | int backspaces; |
37 | }; | 38 | }; |
38 | 39 | ||
39 | 40 | ||
@@ -93,32 +94,33 @@ public: | |||
93 | void resetState(); | 94 | void resetState(); |
94 | 95 | ||
95 | void mousePressEvent(QMouseEvent*); | 96 | void mousePressEvent(QMouseEvent*); |
96 | void mouseReleaseEvent(QMouseEvent*); | 97 | void mouseReleaseEvent(QMouseEvent*); |
97 | void resizeEvent(QResizeEvent*); | 98 | void resizeEvent(QResizeEvent*); |
98 | void paintEvent(QPaintEvent* e); | 99 | void paintEvent(QPaintEvent* e); |
99 | //void timerEvent(QTimerEvent* e); | 100 | //void timerEvent(QTimerEvent* e); |
100 | void drawKeyboard( QPainter &p, int row = -1, int col = -1); | 101 | void drawKeyboard( QPainter &p, int row = -1, int col = -1); |
101 | 102 | ||
102 | QSize sizeHint() const; | 103 | QSize sizeHint() const; |
103 | 104 | ||
104 | signals: | 105 | signals: |
105 | void key( ushort scancode, ushort unicode, ushort modifiers, bool, bool ); | 106 | void key( ushort scancode, ushort unicode, ushort modifiers, bool, bool ); |
106 | 107 | ||
107 | private slots: | 108 | private slots: |
108 | void repeat(); | 109 | void repeat(); |
110 | void togglePickboard(bool on_off); | ||
109 | 111 | ||
110 | private: | 112 | private: |
111 | int getKey( int &w, int j = -1 ); | 113 | int getKey( int &w, int j = -1 ); |
112 | void clearHighlight(); | 114 | void clearHighlight(); |
113 | 115 | ||
114 | bool *shift; | 116 | bool *shift; |
115 | bool *lock; | 117 | bool *lock; |
116 | bool *ctrl; | 118 | bool *ctrl; |
117 | bool *alt; | 119 | bool *alt; |
118 | uint useLargeKeys:1; | 120 | uint useLargeKeys:1; |
119 | uint usePicks:1; | 121 | uint usePicks:1; |
120 | 122 | ||
121 | int pressedKeyRow; | 123 | int pressedKeyRow; |
122 | int pressedKeyCol; | 124 | int pressedKeyCol; |
123 | 125 | ||
124 | KeyboardPicks *picks; | 126 | KeyboardPicks *picks; |
@@ -130,19 +132,21 @@ private: | |||
130 | int unicode; | 132 | int unicode; |
131 | int qkeycode; | 133 | int qkeycode; |
132 | int modifiers; | 134 | int modifiers; |
133 | 135 | ||
134 | int pressTid; | 136 | int pressTid; |
135 | bool pressed; | 137 | bool pressed; |
136 | 138 | ||
137 | Keys keys; | 139 | Keys keys; |
138 | QString LANG; | 140 | QString LANG; |
139 | /* for korean input */ | 141 | /* for korean input */ |
140 | ushort schar, mchar, echar; | 142 | ushort schar, mchar, echar; |
141 | ushort parseKoreanInput(ushort c); | 143 | ushort parseKoreanInput(ushort c); |
142 | ushort combineKoreanChars(const ushort s, const ushort m, const ushort e); | 144 | ushort combineKoreanChars(const ushort s, const ushort m, const ushort e); |
143 | ushort constoe(const ushort c); | 145 | ushort constoe(const ushort c); |
144 | 146 | ||
145 | QTimer *repeatTimer; | 147 | QTimer *repeatTimer; |
148 | |||
149 | ConfigDlg *configdlg; | ||
146 | }; | 150 | }; |
147 | 151 | ||
148 | 152 | ||
diff --git a/inputmethods/multikey/multikey.pro b/inputmethods/multikey/multikey.pro index 2e92e06..9d76a3d 100644 --- a/inputmethods/multikey/multikey.pro +++ b/inputmethods/multikey/multikey.pro | |||
@@ -1,23 +1,25 @@ | |||
1 | TEMPLATE= lib | 1 | TEMPLATE= lib |
2 | CONFIG += qt warn_on release | 2 | CONFIG += qt warn_on release |
3 | HEADERS= keyboard.h \ | 3 | HEADERS= keyboard.h \ |
4 | configdlg.h \ | ||
4 | ../pickboard/pickboardcfg.h \ | 5 | ../pickboard/pickboardcfg.h \ |
5 | ../pickboard/pickboardpicks.h \ | 6 | ../pickboard/pickboardpicks.h \ |
6 | keyboardimpl.h | 7 | keyboardimpl.h |
7 | SOURCES= keyboard.cpp \ | 8 | SOURCES= keyboard.cpp \ |
9 | configdlg.cpp \ | ||
8 | ../pickboard/pickboardcfg.cpp \ | 10 | ../pickboard/pickboardcfg.cpp \ |
9 | ../pickboard/pickboardpicks.cpp \ | 11 | ../pickboard/pickboardpicks.cpp \ |
10 | keyboardimpl.cpp | 12 | keyboardimpl.cpp |
11 | TARGET = qmultikey | 13 | TARGET = qmultikey |
12 | DESTDIR = ../../plugins/inputmethods | 14 | DESTDIR = ../../plugins/inputmethods |
13 | INCLUDEPATH += $(OPIEDIR)/include | 15 | INCLUDEPATH += $(OPIEDIR)/include |
14 | DEPENDPATH += ../$(OPIEDIR)/include ../../launcher | 16 | DEPENDPATH += ../$(OPIEDIR)/include ../../launcher |
15 | LIBS += -lqpe | 17 | LIBS += -lqpe |
16 | VERSION = 1.0.0 | 18 | VERSION = 1.0.0 |
17 | 19 | ||
18 | TRANSLATIONS = ../../i18n/pt_BR/libqmultikey.ts | 20 | TRANSLATIONS = ../../i18n/pt_BR/libqmultikey.ts |
19 | TRANSLATIONS += ../../i18n/de/libqmultikey.ts | 21 | TRANSLATIONS += ../../i18n/de/libqmultikey.ts |
20 | TRANSLATIONS += ../../i18n/en/libqmultikey.ts | 22 | TRANSLATIONS += ../../i18n/en/libqmultikey.ts |
21 | TRANSLATIONS += ../../i18n/hu/libqmultikey.ts | 23 | TRANSLATIONS += ../../i18n/hu/libqmultikey.ts |
22 | TRANSLATIONS += ../../i18n/sl/libqmultikey.ts | 24 | TRANSLATIONS += ../../i18n/sl/libqmultikey.ts |
23 | TRANSLATIONS += ../../i18n/ja/libqmultikey.ts | 25 | TRANSLATIONS += ../../i18n/ja/libqmultikey.ts |