summaryrefslogtreecommitdiff
authorhash <hash>2002-08-14 05:39:42 (UTC)
committer hash <hash>2002-08-14 05:39:42 (UTC)
commit13a1334cca686bf512c4a8f94a648ba969b38d22 (patch) (unidiff)
tree13e46c6b4157b0348f38d952ddc70f6e0fda619b
parent29ffa9119abaf753b165c5c241b22938eeaef301 (diff)
downloadopie-13a1334cca686bf512c4a8f94a648ba969b38d22.zip
opie-13a1334cca686bf512c4a8f94a648ba969b38d22.tar.gz
opie-13a1334cca686bf512c4a8f94a648ba969b38d22.tar.bz2
added config dialog. only open/closing pickboard works
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/multikey/keyboard.cpp67
-rw-r--r--inputmethods/multikey/keyboard.h4
-rw-r--r--inputmethods/multikey/multikey.pro2
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
@@ -1,720 +1,747 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
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 */
41Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : 43Keyboard::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
67 repeatTimer = new QTimer( this ); 75 repeatTimer = new QTimer( this );
68 connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); 76 connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) );
69 77
70} 78}
71 79
72/* Keyboard::resizeEvent {{{1 */ 80/* Keyboard::resizeEvent {{{1 */
73void Keyboard::resizeEvent(QResizeEvent*) 81void Keyboard::resizeEvent(QResizeEvent*)
74{ 82{
75 int ph = picks->sizeHint().height(); 83 int ph = picks->sizeHint().height();
76 picks->setGeometry( 0, 0, width(), ph ); 84 picks->setGeometry( 0, 0, width(), ph );
77 keyHeight = (height()-(usePicks ? ph : 0))/5; 85 keyHeight = (height()-(usePicks ? ph : 0))/5;
78 86
79 int nk; // number of keys? 87 int nk; // number of keys?
80 if ( useLargeKeys ) { 88 if ( useLargeKeys ) {
81 nk = 15; 89 nk = 15;
82 } else { 90 } else {
83 nk = 19; 91 nk = 19;
84 } 92 }
85 defaultKeyWidth = (width()/nk)/2; 93 defaultKeyWidth = (width()/nk)/2;
86 xoffs = (width()-defaultKeyWidth*nk)/2; // empty key spaces? 94 xoffs = (width()-defaultKeyWidth*nk)/2; // empty key spaces?
87 95
88} 96}
89 97
90/* KeyboardPicks::initialize {{{1 */ 98/* KeyboardPicks::initialize {{{1 */
91void KeyboardPicks::initialise() 99void KeyboardPicks::initialise()
92{ 100{
93 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); 101 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
94 mode = 0; 102 mode = 0;
95 dc = new KeyboardConfig(this); 103 dc = new KeyboardConfig(this);
96 configs.append(dc); 104 configs.append(dc);
97} 105}
98 106
99/* KeyboardPicks::sizeHint {{{1 */ 107/* KeyboardPicks::sizeHint {{{1 */
100QSize KeyboardPicks::sizeHint() const 108QSize KeyboardPicks::sizeHint() const
101{ 109{
102 return QSize(240,fontMetrics().lineSpacing()); 110 return QSize(240,fontMetrics().lineSpacing());
103} 111}
104 112
105 113
106/* KeyboardConfig::generateText {{{1 */ 114/* KeyboardConfig::generateText {{{1 */
107void KeyboardConfig::generateText(const QString &s) 115void KeyboardConfig::generateText(const QString &s)
108{ 116{
109#if defined(Q_WS_QWS) || defined(_WS_QWS_) 117#if defined(Q_WS_QWS) || defined(_WS_QWS_)
110 for (int i=0; i<(int)backspaces; i++) { 118 for (int i=0; i<(int)backspaces; i++) {
111 parent->emitKey( 0, Qt::Key_Backspace, 0, true, false ); 119 parent->emitKey( 0, Qt::Key_Backspace, 0, true, false );
112 parent->emitKey( 0, Qt::Key_Backspace, 0, false, false ); 120 parent->emitKey( 0, Qt::Key_Backspace, 0, false, false );
113 } 121 }
114 for (int i=0; i<(int)s.length(); i++) { 122 for (int i=0; i<(int)s.length(); i++) {
115 parent->emitKey( s[i].unicode(), 0, 0, true, false ); 123 parent->emitKey( s[i].unicode(), 0, 0, true, false );
116 parent->emitKey( s[i].unicode(), 0, 0, false, false ); 124 parent->emitKey( s[i].unicode(), 0, 0, false, false );
117 } 125 }
118 parent->emitKey( 0, Qt::Key_Space, 0, true, false ); 126 parent->emitKey( 0, Qt::Key_Space, 0, true, false );
119 parent->emitKey( 0, Qt::Key_Space, 0, false, false ); 127 parent->emitKey( 0, Qt::Key_Space, 0, false, false );
120 backspaces = 0; 128 backspaces = 0;
121#endif 129#endif
122} 130}
123 131
124 132
125 133
126 134
127/* Keyboard::paintEvent {{{1 */ 135/* Keyboard::paintEvent {{{1 */
128void Keyboard::paintEvent(QPaintEvent* e) 136void Keyboard::paintEvent(QPaintEvent* e)
129{ 137{
130 QPainter painter(this); 138 QPainter painter(this);
131 painter.setClipRect(e->rect()); 139 painter.setClipRect(e->rect());
132 drawKeyboard( painter ); 140 drawKeyboard( painter );
133 picks->dc->draw( &painter ); 141 picks->dc->draw( &painter );
134} 142}
135 143
136 144
137/* Keyboard::drawKeyboard {{{1 */ 145/* Keyboard::drawKeyboard {{{1 */
138 146
139void Keyboard::drawKeyboard(QPainter &p, int row, int col) 147void Keyboard::drawKeyboard(QPainter &p, int row, int col)
140{ 148{
141 QColor keycolor = 149 QColor keycolor =
142 QColor(240,240,240); 150 QColor(240,240,240);
143 QColor keycolor_pressed = QColor(171,183,198); 151 QColor keycolor_pressed = QColor(171,183,198);
144 QColor keycolor_lines = QColor(138,148,160); 152 QColor keycolor_lines = QColor(138,148,160);
145 QColor textcolor = QColor(43,54,68); 153 QColor textcolor = QColor(43,54,68);
146 154
147 155
148 if (row != -1 && col != -1) { //just redraw one key 156 if (row != -1 && col != -1) { //just redraw one key
149 157
150 int x = 0; 158 int x = 0;
151 for (int i = 0; i < col; i++) { 159 for (int i = 0; i < col; i++) {
152 160
153 x += keys.width(row, i) * defaultKeyWidth; 161 x += keys.width(row, i) * defaultKeyWidth;
154 } 162 }
155 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); 163 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0);
156 164
157 int keyWidth = keys.width(row, col); 165 int keyWidth = keys.width(row, col);
158 166
159 p.fillRect(x + 1, y + 1, 167 p.fillRect(x + 1, y + 1,
160 keyWidth * defaultKeyWidth - 1, keyHeight - 1, 168 keyWidth * defaultKeyWidth - 1, keyHeight - 1,
161 pressed || keys.pressed(row, col) ? keycolor_pressed : keycolor); 169 pressed || keys.pressed(row, col) ? keycolor_pressed : keycolor);
162 170
163 QPixmap *pix = keys.pix(row,col); 171 QPixmap *pix = keys.pix(row,col);
164 172
165 ushort c = keys.uni(row, col); 173 ushort c = keys.uni(row, col);
166 174
167 if (!pix) { 175 if (!pix) {
168 p.setPen(textcolor); 176 p.setPen(textcolor);
169 p.drawText(x, y, 177 p.drawText(x, y,
170 defaultKeyWidth * keyWidth, keyHeight, 178 defaultKeyWidth * keyWidth, keyHeight,
171 AlignCenter, ((shift || lock) && keys.shift(c)) ? (QChar)keys.shift(c) : (QChar)c); 179 AlignCenter, ((shift || lock) && keys.shift(c)) ? (QChar)keys.shift(c) : (QChar)c);
172 } 180 }
173 else 181 else
174 // center the image in the middle of the key 182 // center the image in the middle of the key
175 p.drawPixmap( x + (defaultKeyWidth * keyWidth - pix->width())/2, 183 p.drawPixmap( x + (defaultKeyWidth * keyWidth - pix->width())/2,
176 y + (keyHeight - pix->height())/2 + 1, 184 y + (keyHeight - pix->height())/2 + 1,
177 *pix ); 185 *pix );
178 186
179 // this fixes the problem that the very right end of the board's vertical line 187 // this fixes the problem that the very right end of the board's vertical line
180 // gets painted over, because it's one pixel shorter than all other keys 188 // gets painted over, because it's one pixel shorter than all other keys
181 p.setPen(keycolor_lines); 189 p.setPen(keycolor_lines);
182 p.drawLine(width() - 1, 0, width() - 1, height()); 190 p.drawLine(width() - 1, 0, width() - 1, height());
183 191
184 } else { 192 } else {
185 193
186 194
187 p.fillRect(0, 0, width(), height(), keycolor); 195 p.fillRect(0, 0, width(), height(), keycolor);
188 196
189 for (row = 1; row <= 5; row++) { 197 for (row = 1; row <= 5; row++) {
190 198
191 int x = 0; 199 int x = 0;
192 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); 200 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0);
193 201
194 p.setPen(keycolor_lines); 202 p.setPen(keycolor_lines);
195 p.drawLine(x, y, x + width(), y); 203 p.drawLine(x, y, x + width(), y);
196 204
197 for (int col = 0; col < keys.numKeys(row); col++) { 205 for (int col = 0; col < keys.numKeys(row); col++) {
198 206
199 QPixmap *pix = keys.pix(row, col); 207 QPixmap *pix = keys.pix(row, col);
200 int keyWidth = keys.width(row, col); 208 int keyWidth = keys.width(row, col);
201 209
202 210
203 int keyWidthPix = defaultKeyWidth * keyWidth; 211 int keyWidthPix = defaultKeyWidth * keyWidth;
204 212
205 if (keys.pressed(row, col)) 213 if (keys.pressed(row, col))
206 p.fillRect(x+1, y+1, keyWidthPix - 1, 214 p.fillRect(x+1, y+1, keyWidthPix - 1,
207 keyHeight - 1, keycolor_pressed); 215 keyHeight - 1, keycolor_pressed);
208 216
209 ushort c = keys.uni(row, col); 217 ushort c = keys.uni(row, col);
210 218
211 if (!pix) { 219 if (!pix) {
212 p.setPen(textcolor); 220 p.setPen(textcolor);
213 p.drawText(x, y, 221 p.drawText(x, y,
214 keyWidthPix, keyHeight, 222 keyWidthPix, keyHeight,
215 AlignCenter, ((shift || lock) && keys.shift(c)) ? (QChar)keys.shift(c) : (QChar)c); 223 AlignCenter, ((shift || lock) && keys.shift(c)) ? (QChar)keys.shift(c) : (QChar)c);
216 } 224 }
217 else { 225 else {
218 // center the image in the middle of the key 226 // center the image in the middle of the key
219 p.drawPixmap( x + (keyWidthPix - pix->width())/2, 227 p.drawPixmap( x + (keyWidthPix - pix->width())/2,
220 y + (keyHeight - pix->height())/2 + 1, 228 y + (keyHeight - pix->height())/2 + 1,
221 QPixmap(*pix) ); 229 QPixmap(*pix) );
222 } 230 }
223 231
224 p.setPen(keycolor_lines); 232 p.setPen(keycolor_lines);
225 p.drawLine(x, y, x, y + keyHeight); 233 p.drawLine(x, y, x, y + keyHeight);
226 234
227 x += keyWidthPix; 235 x += keyWidthPix;
228 } 236 }
229 237
230 238
231 } 239 }
232 p.drawLine(0, height() - 1, width(), height() - 1); 240 p.drawLine(0, height() - 1, width(), height() - 1);
233 p.drawLine(width() - 1, 0, width() - 1, height()); 241 p.drawLine(width() - 1, 0, width() - 1, height());
234 } 242 }
235 243
236} 244}
237 245
238 246
239/* Keyboard::mousePressEvent {{{1 */ 247/* Keyboard::mousePressEvent {{{1 */
240void Keyboard::mousePressEvent(QMouseEvent *e) 248void Keyboard::mousePressEvent(QMouseEvent *e)
241{ 249{
242 int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1; 250 int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1;
243 if (row > 5) row = 5; 251 if (row > 5) row = 5;
244 252
245 // figure out the column 253 // figure out the column
246 int col = 0; 254 int col = 0;
247 for (int w = 0; e->x() >= w; col++) 255 for (int w = 0; e->x() >= w; col++)
248 if (col < keys.numKeys(row)) // it segfaults if it trys to read past numKeys 256 if (col < keys.numKeys(row)) // it segfaults if it trys to read past numKeys
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;
302 } 302 }
303 else { 303 else {
304 shift = keys.pressedPtr(row, col); 304 shift = keys.pressedPtr(row, col);
305 *shift = 1; 305 *shift = 1;
306 if (lock) { 306 if (lock) {
307 *lock = 0; 307 *lock = 0;
308 lock = 0; 308 lock = 0;
309 } 309 }
310 } 310 }
311 311
312 } else if (qkeycode == Qt::Key_CapsLock) { 312 } else if (qkeycode == Qt::Key_CapsLock) {
313 need_repaint = TRUE; 313 need_repaint = TRUE;
314 314
315 if (lock) { 315 if (lock) {
316 *lock = 0; 316 *lock = 0;
317 lock = 0; 317 lock = 0;
318 } 318 }
319 else { 319 else {
320 lock = keys.pressedPtr(row, col);; 320 lock = keys.pressedPtr(row, col);;
321 *lock = 1; 321 *lock = 1;
322 if (shift) { 322 if (shift) {
323 *shift = 0; 323 *shift = 0;
324 shift = 0; 324 shift = 0;
325 } 325 }
326 } 326 }
327 327
328 } 328 }
329 329
330 } 330 }
331 else { // normal char 331 else { // normal char
332 if ((shift || lock) && keys.shift(unicode)) { 332 if ((shift || lock) && keys.shift(unicode)) {
333 unicode = keys.shift(unicode); 333 unicode = keys.shift(unicode);
334 } 334 }
335 } 335 }
336 336
337 // korean parsing 337 // korean parsing
338 if (LANG == "ko") { 338 if (LANG == "ko") {
339 339
340 unicode = parseKoreanInput(unicode); 340 unicode = parseKoreanInput(unicode);
341 } 341 }
342 342
343 modifiers = (ctrl ? Qt::ControlButton : 0) | (alt ? Qt::AltButton : 0); 343 modifiers = (ctrl ? Qt::ControlButton : 0) | (alt ? Qt::AltButton : 0);
344 344
345 emit key(unicode, qkeycode, modifiers, true, false); 345 emit key(unicode, qkeycode, modifiers, true, false);
346 346
347 // pickboard stuff 347 // pickboard stuff
348 if (usePicks) { 348 if (usePicks) {
349 349
350 KeyboardConfig *dc = picks->dc; 350 KeyboardConfig *dc = picks->dc;
351 351
352 if (dc) { 352 if (dc) {
353 if (qkeycode == Qt::Key_Backspace) { 353 if (qkeycode == Qt::Key_Backspace) {
354 dc->input.remove(dc->input.last()); // remove last input 354 dc->input.remove(dc->input.last()); // remove last input
355 dc->decBackspaces(); 355 dc->decBackspaces();
356 } else if ( qkeycode == Qt::Key_Return || QChar(unicode).isPunct() || QChar(unicode).isSpace() || unicode == 0) { 356 } else if ( qkeycode == Qt::Key_Return || QChar(unicode).isPunct() || QChar(unicode).isSpace() || unicode == 0) {
357 dc->input.clear(); 357 dc->input.clear();
358 dc->resetBackspaces(); 358 dc->resetBackspaces();
359 } else { 359 } else {
360 dc->add(QString(QChar(unicode))); 360 dc->add(QString(QChar(unicode)));
361 dc->incBackspaces(); 361 dc->incBackspaces();
362 } 362 }
363 } 363 }
364 picks->repaint(); 364 picks->repaint();
365 } 365 }
366 366
367 367
368 // painting 368 // painting
369 pressed = TRUE; 369 pressed = TRUE;
370 370
371 pressedKeyRow = row; 371 pressedKeyRow = row;
372 pressedKeyCol = col; 372 pressedKeyCol = col;
373 373
374 if (need_repaint) repaint(FALSE); 374 if (need_repaint) repaint(FALSE);
375 else { // just paint the one key pressed 375 else { // just paint the one key pressed
376 376
377 377
378 378
379 QPainter p(this); 379 QPainter p(this);
380 drawKeyboard(p, row, col); 380 drawKeyboard(p, row, col);
381 381
382 } 382 }
383 383
384 pressTid = startTimer(80); 384 pressTid = startTimer(80);
385 385
386} 386}
387 387
388 388
389/* Keyboard::mouseReleaseEvent {{{1 */ 389/* Keyboard::mouseReleaseEvent {{{1 */
390void Keyboard::mouseReleaseEvent(QMouseEvent*) 390void Keyboard::mouseReleaseEvent(QMouseEvent*)
391{ 391{
392 pressed = FALSE; 392 pressed = FALSE;
393 if ( pressTid == 0 ) 393 if ( pressTid == 0 )
394#if defined(Q_WS_QWS) || defined(_WS_QWS_) 394#if defined(Q_WS_QWS) || defined(_WS_QWS_)
395 if ( unicode != -1 ) { 395 if ( unicode != -1 ) {
396 emit key( unicode, qkeycode, modifiers, false, false ); 396 emit key( unicode, qkeycode, modifiers, false, false );
397 repeatTimer->stop(); 397 repeatTimer->stop();
398 } 398 }
399#endif 399#endif
400 if (shift && unicode != 0) { 400 if (shift && unicode != 0) {
401 401
402 402
403 *shift = 0; // unpress shift key 403 *shift = 0; // unpress shift key
404 shift = 0; // reset the shift pointer 404 shift = 0; // reset the shift pointer
405 repaint(FALSE); 405 repaint(FALSE);
406 406
407 } 407 }
408 else 408 else
409 409
410 clearHighlight(); 410 clearHighlight();
411} 411}
412 412
413/* Keyboard::timerEvent {{{1 */ 413/* Keyboard::timerEvent {{{1 */
414/* 414/*
415void Keyboard::timerEvent(QTimerEvent* e) 415void Keyboard::timerEvent(QTimerEvent* e)
416{ 416{
417 if ( e->timerId() == pressTid ) { 417 if ( e->timerId() == pressTid ) {
418 killTimer(pressTid); 418 killTimer(pressTid);
419 pressTid = 0; 419 pressTid = 0;
420 if ( !pressed ) 420 if ( !pressed )
421 cout << "calling clearHighlight from timerEvent\n"; 421 cout << "calling clearHighlight from timerEvent\n";
422 clearHighlight(); 422 clearHighlight();
423 } 423 }
424} 424}
425*/ 425*/
426 426
427void Keyboard::repeat() 427void Keyboard::repeat()
428{ 428{
429 429
430 repeatTimer->start( 200 ); 430 repeatTimer->start( 200 );
431 emit key( unicode, 0, modifiers, true, true ); 431 emit key( unicode, 0, modifiers, true, true );
432} 432}
433 433
434void Keyboard::clearHighlight() 434void Keyboard::clearHighlight()
435{ 435{
436 if ( pressedKeyRow >= 0 && pressedKeyCol >= 0) { 436 if ( pressedKeyRow >= 0 && pressedKeyCol >= 0) {
437 int tmpRow = pressedKeyRow; 437 int tmpRow = pressedKeyRow;
438 int tmpCol = pressedKeyCol; 438 int tmpCol = pressedKeyCol;
439 439
440 pressedKeyRow = -1; 440 pressedKeyRow = -1;
441 pressedKeyCol = -1; 441 pressedKeyCol = -1;
442 442
443 QPainter p(this); 443 QPainter p(this);
444 drawKeyboard(p, tmpRow, tmpCol); 444 drawKeyboard(p, tmpRow, tmpCol);
445 } 445 }
446} 446}
447 447
448 448
449/* Keyboard::sizeHint {{{1 */ 449/* Keyboard::sizeHint {{{1 */
450QSize Keyboard::sizeHint() const 450QSize 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
459void Keyboard::resetState() 459void 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 */
466void 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 *
481 * ÃÊÀ½ = schar (start char) 508 * ÃÊÀ½ = schar (start char)
482 * ÁßÀ½ = mchar (middle char) 509 * ÁßÀ½ = mchar (middle char)
483 * ³¡À½ = echar (end char) 510 * ³¡À½ = echar (end char)
484 * 511 *
485 * there are 19 schars. unicode position is at 1100 - 1112 512 * there are 19 schars. unicode position is at 1100 - 1112
486 * there are 21 mchars. unicode position is at 1161 - 1175 513 * there are 21 mchars. unicode position is at 1161 - 1175
487 * there are 27 echars. unicode position is at 11a8 - 11c2 514 * there are 27 echars. unicode position is at 11a8 - 11c2
488 * 515 *
489 * the map with everything combined is at ac00 - d7a3 516 * the map with everything combined is at ac00 - d7a3
490 * 517 *
491 */ 518 */
492 519
493ushort Keyboard::parseKoreanInput (ushort c) { 520ushort Keyboard::parseKoreanInput (ushort c) {
494 521
495 if ((c != 0 && (c < 0x1100 || 0x11c2 < c) && (c < 0xac00 || 0xd7a3 < c)) 522 if ((c != 0 && (c < 0x1100 || 0x11c2 < c) && (c < 0xac00 || 0xd7a3 < c))
496 || 523 ||
497 (c == 0 && qkeycode != Qt::Key_Shift && Qt::Key_CapsLock != qkeycode 524 (c == 0 && qkeycode != Qt::Key_Shift && Qt::Key_CapsLock != qkeycode
498 && qkeycode != Qt::Key_Control && qkeycode != Qt::Key_Alt)) { 525 && qkeycode != Qt::Key_Control && qkeycode != Qt::Key_Alt)) {
499 526
500 schar = 0, mchar = 0, echar = 0; 527 schar = 0, mchar = 0, echar = 0;
501 return c; 528 return c;
502 } 529 }
503 530
504 if ( 0x1100 <= c && c <= 0x1112 ) { // schar or echar was input 531 if ( 0x1100 <= c && c <= 0x1112 ) { // schar or echar was input
505 532
506 if (schar == 0 || (schar != 0 && mchar == 0)) { 533 if (schar == 0 || (schar != 0 && mchar == 0)) {
507 schar = c; mchar = 0; echar = 0; 534 schar = c; mchar = 0; echar = 0;
508 return c; 535 return c;
509 } 536 }
510 else if (mchar != 0) { 537 else if (mchar != 0) {
511 538
512 if (echar == 0) { 539 if (echar == 0) {
513 540
514 if (!(echar = constoe(c))) { 541 if (!(echar = constoe(c))) {
515 542
516 schar = c; mchar = 0; echar = 0; 543 schar = c; mchar = 0; echar = 0;
517 return c; 544 return c;
518 } 545 }
519 546
520 } 547 }
521 else { // must figure out what the echar is 548 else { // must figure out what the echar is
522 549
523 if (echar == 0x11a8) { // ¤¡ 550 if (echar == 0x11a8) { // ¤¡
524 551
525 if (c == 0x1100) echar = 0x11a9; // ¤¡ + ¤¡ 552 if (c == 0x1100) echar = 0x11a9; // ¤¡ + ¤¡
526 else if (c == 0x1109) echar = 0x11aa; // ¤¡ + ¤µ 553 else if (c == 0x1109) echar = 0x11aa; // ¤¡ + ¤µ
527 else { 554 else {
528 schar = c; mchar = 0; echar = 0; 555 schar = c; mchar = 0; echar = 0;
529 return c; 556 return c;
530 } 557 }
531 558
532 } else if (echar == 0x11ab) { // ¤¤ 559 } else if (echar == 0x11ab) { // ¤¤
533 560
534 if (c == 0x110c) echar = 0x11ac; // ¤¤ + ¤¸ 561 if (c == 0x110c) echar = 0x11ac; // ¤¤ + ¤¸
535 else if (c == 0x1112) echar = 0x11ad; // ¤¤ + ¤¾ 562 else if (c == 0x1112) echar = 0x11ad; // ¤¤ + ¤¾
536 else { 563 else {
537 schar = c; mchar = 0; echar = 0; 564 schar = c; mchar = 0; echar = 0;
538 return c; 565 return c;
539 } 566 }
540 567
541 } else if (echar == 0x11af) { // ¤© 568 } else if (echar == 0x11af) { // ¤©
542 569
543 if (c == 0x1100) echar = 0x11b0; // ¤© + ¤¡ 570 if (c == 0x1100) echar = 0x11b0; // ¤© + ¤¡
544 else if (c == 0x1106) echar = 0x11b1; // ¤© + ¤± 571 else if (c == 0x1106) echar = 0x11b1; // ¤© + ¤±
545 else if (c == 0x1107) echar = 0x11b2; // ¤© + ¤² 572 else if (c == 0x1107) echar = 0x11b2; // ¤© + ¤²
546 else if (c == 0x1109) echar = 0x11b3; // ¤© + ¤µ 573 else if (c == 0x1109) echar = 0x11b3; // ¤© + ¤µ
547 else if (c == 0x1110) echar = 0x11b4; // ¤© + ¤¼ 574 else if (c == 0x1110) echar = 0x11b4; // ¤© + ¤¼
548 else if (c == 0x1111) echar = 0x11b5; // ¤© + ¤½ 575 else if (c == 0x1111) echar = 0x11b5; // ¤© + ¤½
549 else if (c == 0x1112) echar = 0x11b6; // ¤© + ¤¾ 576 else if (c == 0x1112) echar = 0x11b6; // ¤© + ¤¾
550 else { 577 else {
551 schar = c; mchar = 0; echar = 0; 578 schar = c; mchar = 0; echar = 0;
552 return c; 579 return c;
553 } 580 }
554 581
555 } else if (echar == 0x11b8) { // ¤² 582 } else if (echar == 0x11b8) { // ¤²
556 583
557 if (c == 0x1109) echar = 0x11b9; // ¤² + ¤µ 584 if (c == 0x1109) echar = 0x11b9; // ¤² + ¤µ
558 else { 585 else {
559 schar = c; mchar = 0; echar = 0; 586 schar = c; mchar = 0; echar = 0;
560 return c; 587 return c;
561 } 588 }
562 589
563 } else if (echar == 0x11ba) { // ¤µ 590 } else if (echar == 0x11ba) { // ¤µ
564 591
565 if (c == 0x1109) echar = 0x11bb; // ¤µ + ¤µ 592 if (c == 0x1109) echar = 0x11bb; // ¤µ + ¤µ
566 else { 593 else {
567 schar = c; mchar = 0; echar = 0; 594 schar = c; mchar = 0; echar = 0;
568 return c; 595 return c;
569 } 596 }
570 597
571 } else { // if any other char, cannot combine chars 598 } else { // if any other char, cannot combine chars
572 599
573 schar = c; mchar = 0; echar = 0; 600 schar = c; mchar = 0; echar = 0;
574 return c; 601 return c;
575 } 602 }
576 603
577 unicode = echar; 604 unicode = echar;
578 } 605 }
579 } 606 }
580 607
581 } 608 }
582 else if (0x1161 <= c && c <= 0x1175) { // mchar was input 609 else if (0x1161 <= c && c <= 0x1175) { // mchar was input
583 610
584 if (schar != 0 && mchar == 0) { mchar = c; } 611 if (schar != 0 && mchar == 0) { mchar = c; }
585 612
586 else if (schar != 0 && mchar != 0 && echar == 0) { 613 else if (schar != 0 && mchar != 0 && echar == 0) {
587 614
588 switch (mchar) { 615 switch (mchar) {
589 case 0x1169: 616 case 0x1169:
590 if (c == 0x1161) mchar = 0x116a; 617 if (c == 0x1161) mchar = 0x116a;
591 else if (c == 0x1162) mchar = 0x116b; 618 else if (c == 0x1162) mchar = 0x116b;
592 else if (c == 0x1175) mchar = 0x116c; 619 else if (c == 0x1175) mchar = 0x116c;
593 else { 620 else {
594 schar = 0; mchar = 0; echar = 0; 621 schar = 0; mchar = 0; echar = 0;
595 return c; 622 return c;
596 } 623 }
597 break; 624 break;
598 case 0x116e: 625 case 0x116e:
599 if (c == 0x1165) mchar = 0x116f; 626 if (c == 0x1165) mchar = 0x116f;
600 else if (c == 0x1166) mchar = 0x1170; 627 else if (c == 0x1166) mchar = 0x1170;
601 else if (c == 0x1175) mchar = 0x1171; 628 else if (c == 0x1175) mchar = 0x1171;
602 else { 629 else {
603 schar = 0; mchar = 0; echar = 0; 630 schar = 0; mchar = 0; echar = 0;
604 return c; 631 return c;
605 } 632 }
606 break; 633 break;
607 case 0x1173: 634 case 0x1173:
608 if (c == 0x1175) mchar = 0x1174; 635 if (c == 0x1175) mchar = 0x1174;
609 else { 636 else {
610 schar = 0; mchar = 0; echar = 0; 637 schar = 0; mchar = 0; echar = 0;
611 return c; 638 return c;
612 } 639 }
613 break; 640 break;
614 default: 641 default:
615 schar = 0; mchar = 0; echar = 0; 642 schar = 0; mchar = 0; echar = 0;
616 return c; 643 return c;
617 } 644 }
618 } 645 }
619 else if (schar != 0 && mchar != 0 && echar != 0) { 646 else if (schar != 0 && mchar != 0 && echar != 0) {
620 647
621 emit key( 8, Qt::Key_Backspace, 0, true, false ); 648 emit key( 8, Qt::Key_Backspace, 0, true, false );
622 649
623 ushort prev = 0; 650 ushort prev = 0;
624 switch (echar) { 651 switch (echar) {
625 /* 652 /*
626 case 0x11a9: 653 case 0x11a9:
627 prev = combineKoreanChars(schar, mchar, 0x11a8); 654 prev = combineKoreanChars(schar, mchar, 0x11a8);
628 schar = 0x1100; 655 schar = 0x1100;
629 break; 656 break;
630 */ 657 */
631 case 0x11aa: 658 case 0x11aa:
632 prev = combineKoreanChars(schar, mchar, 0x11a8); 659 prev = combineKoreanChars(schar, mchar, 0x11a8);
633 schar = 0x1109; 660 schar = 0x1109;
634 break; 661 break;
635 case 0x11ac: 662 case 0x11ac:
636 prev = combineKoreanChars(schar, mchar, 0x11ab); 663 prev = combineKoreanChars(schar, mchar, 0x11ab);
637 schar = 0x110c; 664 schar = 0x110c;
638 break; 665 break;
639 case 0x11ad: 666 case 0x11ad:
640 prev = combineKoreanChars(schar, mchar, 0x11ab); 667 prev = combineKoreanChars(schar, mchar, 0x11ab);
641 schar = 0x1112; 668 schar = 0x1112;
642 break; 669 break;
643 case 0x11b0: 670 case 0x11b0:
644 prev = combineKoreanChars(schar, mchar, 0x11af); 671 prev = combineKoreanChars(schar, mchar, 0x11af);
645 schar = 0x1100; 672 schar = 0x1100;
646 break; 673 break;
647 case 0x11b1: 674 case 0x11b1:
648 prev = combineKoreanChars(schar, mchar, 0x11af); 675 prev = combineKoreanChars(schar, mchar, 0x11af);
649 schar = 0x1106; 676 schar = 0x1106;
650 break; 677 break;
651 case 0x11b2: 678 case 0x11b2:
652 prev = combineKoreanChars(schar, mchar, 0x11af); 679 prev = combineKoreanChars(schar, mchar, 0x11af);
653 schar = 0x1107; 680 schar = 0x1107;
654 break; 681 break;
655 case 0x11b3: 682 case 0x11b3:
656 prev = combineKoreanChars(schar, mchar, 0x11af); 683 prev = combineKoreanChars(schar, mchar, 0x11af);
657 schar = 0x1109; 684 schar = 0x1109;
658 break; 685 break;
659 case 0x11b4: 686 case 0x11b4:
660 prev = combineKoreanChars(schar, mchar, 0x11af); 687 prev = combineKoreanChars(schar, mchar, 0x11af);
661 schar = 0x1110; 688 schar = 0x1110;
662 break; 689 break;
663 case 0x11b9: 690 case 0x11b9:
664 prev = combineKoreanChars(schar, mchar, 0x11b8); 691 prev = combineKoreanChars(schar, mchar, 0x11b8);
665 schar = 0x1109; 692 schar = 0x1109;
666 break; 693 break;
667 /* 694 /*
668 case 0x11bb: 695 case 0x11bb:
669 prev = combineKoreanChars(schar, mchar, 0x11ba); 696 prev = combineKoreanChars(schar, mchar, 0x11ba);
670 schar = 0x1109; 697 schar = 0x1109;
671 break; 698 break;
672 */ 699 */
673 default: 700 default:
674 701
675 if (constoe(echar)) { 702 if (constoe(echar)) {
676 703
677 prev = combineKoreanChars(schar, mchar, 0); 704 prev = combineKoreanChars(schar, mchar, 0);
678 schar = constoe(echar); 705 schar = constoe(echar);
679 } 706 }
680 break; 707 break;
681 } 708 }
682 709
683 emit key( prev, prev, 0, true, false ); 710 emit key( prev, prev, 0, true, false );
684 711
685 mchar = c; echar = 0; 712 mchar = c; echar = 0;
686 713
687 return combineKoreanChars(schar, mchar, 0); 714 return combineKoreanChars(schar, mchar, 0);
688 715
689 } 716 }
690 else { 717 else {
691 schar = 0; mchar = 0; echar = 0; 718 schar = 0; mchar = 0; echar = 0;
692 return c; 719 return c;
693 } 720 }
694 721
695 } 722 }
696 else /*if (c == ' ')*/ return c; 723 else /*if (c == ' ')*/ return c;
697 724
698 725
699 // and now... finally delete previous char, and return new char 726 // and now... finally delete previous char, and return new char
700 emit key( 8, Qt::Key_Backspace, 0, true, false ); 727 emit key( 8, Qt::Key_Backspace, 0, true, false );
701 728
702 729
703 return combineKoreanChars( schar, mchar, echar); 730 return combineKoreanChars( schar, mchar, echar);
704 731
705} 732}
706 733
707ushort Keyboard::combineKoreanChars(const ushort s, const ushort m, const ushort e) { 734ushort Keyboard::combineKoreanChars(const ushort s, const ushort m, const ushort e) {
708 735
709 return ((s - 0x1100) * 588) + ((m - 0x1161) * 28) + (e ? e - 0x11a7 : 0) + 0xac00; 736 return ((s - 0x1100) * 588) + ((m - 0x1161) * 28) + (e ? e - 0x11a7 : 0) + 0xac00;
710 737
711} 738}
712 739
713ushort Keyboard::constoe(const ushort c) { 740ushort Keyboard::constoe(const ushort c) {
714 741
715 // converts schars to echars if possible 742 // converts schars to echars if possible
716 743
717 if (0x1100 <= c && c <= 0x1112) { // schar to echar 744 if (0x1100 <= c && c <= 0x1112) { // schar to echar
718 745
719 switch (c) { 746 switch (c) {
720 case 0x1100: return 0x11a8; 747 case 0x1100: return 0x11a8;
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
@@ -1,148 +1,152 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
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#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
25class QTimer; 26class QTimer;
26 27
27class KeyboardConfig : public DictFilterConfig 28class KeyboardConfig : public DictFilterConfig
28{ 29{
29public: 30public:
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; }
35private: 36private:
36 int backspaces; 37 int backspaces;
37}; 38};
38 39
39 40
40class KeyboardPicks : public PickboardPicks 41class KeyboardPicks : public PickboardPicks
41{ 42{
42 Q_OBJECT 43 Q_OBJECT
43public: 44public:
44 KeyboardPicks(QWidget* parent=0, const char* name=0, WFlags f=0) 45 KeyboardPicks(QWidget* parent=0, const char* name=0, WFlags f=0)
45 : PickboardPicks(parent, name, f) { } 46 : PickboardPicks(parent, name, f) { }
46 void initialise(); 47 void initialise();
47 virtual QSize sizeHint() const; 48 virtual QSize sizeHint() const;
48 KeyboardConfig *dc; 49 KeyboardConfig *dc;
49}; 50};
50 51
51 52
52class Keys { 53class Keys {
53public: 54public:
54 55
55 Keys(); 56 Keys();
56 Keys(const char * filename); 57 Keys(const char * filename);
57 ushort uni(const int row, const int col); 58 ushort uni(const int row, const int col);
58 int qcode(const int row, const int col); 59 int qcode(const int row, const int col);
59 int width(const int row, const int col); 60 int width(const int row, const int col);
60 bool pressed(const int row, const int col); 61 bool pressed(const int row, const int col);
61 bool *pressedPtr(const int row, const int col); 62 bool *pressedPtr(const int row, const int col);
62 ushort shift(const ushort); 63 ushort shift(const ushort);
63 QPixmap *pix(const int row, const int col); 64 QPixmap *pix(const int row, const int col);
64 int numKeys(const int row); 65 int numKeys(const int row);
65 void setKeysFromFile(const char *filename); 66 void setKeysFromFile(const char *filename);
66 void setKey(const int row, const int qcode, const ushort unicode, 67 void setKey(const int row, const int qcode, const ushort unicode,
67 const int width, QPixmap *pix); 68 const int width, QPixmap *pix);
68 void setPressed(const int row, const int col, const bool pressed); 69 void setPressed(const int row, const int col, const bool pressed);
69 70
70private: 71private:
71 72
72 typedef struct Key { 73 typedef struct Key {
73 int qcode; // are qt key codes just unicode values? 74 int qcode; // are qt key codes just unicode values?
74 ushort unicode; 75 ushort unicode;
75 int width; // not pixels but relative key width. normal key is 2 76 int width; // not pixels but relative key width. normal key is 2
76 77
77 // only needed for keys like ctrl that can have multiple keys pressed at once 78 // only needed for keys like ctrl that can have multiple keys pressed at once
78 bool *pressed; 79 bool *pressed;
79 QPixmap *pix; 80 QPixmap *pix;
80 }; 81 };
81 82
82 QList<Key> keys[6]; 83 QList<Key> keys[6];
83 QMap<ushort,ushort> shiftMap; 84 QMap<ushort,ushort> shiftMap;
84 85
85}; 86};
86 87
87class Keyboard : public QFrame 88class Keyboard : public QFrame
88{ 89{
89 Q_OBJECT 90 Q_OBJECT
90public: 91public:
91 Keyboard( QWidget* parent=0, const char* name=0, WFlags f=0 ); 92 Keyboard( QWidget* parent=0, const char* name=0, WFlags f=0 );
92 93
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
104signals: 105signals:
105 void key( ushort scancode, ushort unicode, ushort modifiers, bool, bool ); 106 void key( ushort scancode, ushort unicode, ushort modifiers, bool, bool );
106 107
107private slots: 108private slots:
108 void repeat(); 109 void repeat();
110 void togglePickboard(bool on_off);
109 111
110private: 112private:
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;
125 127
126 int keyHeight; 128 int keyHeight;
127 int defaultKeyWidth; 129 int defaultKeyWidth;
128 int xoffs; 130 int xoffs;
129 131
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,29 +1,31 @@
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
13INCLUDEPATH += $(OPIEDIR)/include 15INCLUDEPATH += $(OPIEDIR)/include
14DEPENDPATH += ../$(OPIEDIR)/include ../../launcher 16DEPENDPATH += ../$(OPIEDIR)/include ../../launcher
15LIBS += -lqpe 17LIBS += -lqpe
16 VERSION = 1.0.0 18 VERSION = 1.0.0
17 19
18TRANSLATIONS = ../../i18n/pt_BR/libqmultikey.ts 20TRANSLATIONS = ../../i18n/pt_BR/libqmultikey.ts
19TRANSLATIONS += ../../i18n/de/libqmultikey.ts 21TRANSLATIONS += ../../i18n/de/libqmultikey.ts
20TRANSLATIONS += ../../i18n/en/libqmultikey.ts 22TRANSLATIONS += ../../i18n/en/libqmultikey.ts
21TRANSLATIONS += ../../i18n/hu/libqmultikey.ts 23TRANSLATIONS += ../../i18n/hu/libqmultikey.ts
22TRANSLATIONS += ../../i18n/sl/libqmultikey.ts 24TRANSLATIONS += ../../i18n/sl/libqmultikey.ts
23TRANSLATIONS += ../../i18n/ja/libqmultikey.ts 25TRANSLATIONS += ../../i18n/ja/libqmultikey.ts
24TRANSLATIONS += ../../i18n/ko/libqmultikey.ts 26TRANSLATIONS += ../../i18n/ko/libqmultikey.ts
25TRANSLATIONS += ../../i18n/pl/libqmultikey.ts 27TRANSLATIONS += ../../i18n/pl/libqmultikey.ts
26TRANSLATIONS += ../../i18n/no/libqmultikey.ts 28TRANSLATIONS += ../../i18n/no/libqmultikey.ts
27TRANSLATIONS += ../../i18n/zh_CN/libqmultikey.ts 29TRANSLATIONS += ../../i18n/zh_CN/libqmultikey.ts
28TRANSLATIONS += ../../i18n/zh_TW/libqmultikey.ts 30TRANSLATIONS += ../../i18n/zh_TW/libqmultikey.ts
29TRANSLATIONS += ../../i18n/fr/libqmultikey.ts 31TRANSLATIONS += ../../i18n/fr/libqmultikey.ts