summaryrefslogtreecommitdiff
authorhash <hash>2002-09-06 21:23:05 (UTC)
committer hash <hash>2002-09-06 21:23:05 (UTC)
commitfc4808bea669f75af0c28ba65cf2c638c97e99ba (patch) (unidiff)
tree2ced268c3d31f9dded6d8332698ee8e476a081c0
parent15992c5f9b24eaf8df6f90d1993c85d73827b98f (diff)
downloadopie-fc4808bea669f75af0c28ba65cf2c638c97e99ba.zip
opie-fc4808bea669f75af0c28ba65cf2c638c97e99ba.tar.gz
opie-fc4808bea669f75af0c28ba65cf2c638c97e99ba.tar.bz2
french and other stuff fixed
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/multikey/configdlg.cpp11
-rw-r--r--inputmethods/multikey/configdlg.h3
-rw-r--r--inputmethods/multikey/keyboard.cpp323
-rw-r--r--inputmethods/multikey/keyboard.h11
4 files changed, 299 insertions, 49 deletions
diff --git a/inputmethods/multikey/configdlg.cpp b/inputmethods/multikey/configdlg.cpp
index 26c9233..a8206b7 100644
--- a/inputmethods/multikey/configdlg.cpp
+++ b/inputmethods/multikey/configdlg.cpp
@@ -1,17 +1,18 @@
1/* 1/*
2 * TODO 2 * TODO
3 * make a font selection thing (size too) 3 * make a font selection thing (size too)
4 * make vertical keys possible
5 * make a keymap editor 4 * make a keymap editor
5 * make keys translucent
6 * make vertical keys possible
6 * 7 *
7 * 8 *
8 */ 9 */
9 10
10#include <qpe/qpeapplication.h> 11#include <qpe/qpeapplication.h>
11#include <qpe/config.h> 12#include <qpe/config.h>
12 13
13#include <qwidget.h> 14#include <qwidget.h>
14#include <qdialog.h> 15#include <qdialog.h>
15#include <qtabwidget.h> 16#include <qtabwidget.h>
16#include <qvbox.h> 17#include <qvbox.h>
17#include <qgrid.h> 18#include <qgrid.h>
@@ -239,44 +240,50 @@ void ConfigDlg::pickTog() {
239 emit pickboardToggled(pick_button->isChecked()); 240 emit pickboardToggled(pick_button->isChecked());
240} 241}
241 242
242void ConfigDlg::repeatTog() { 243void ConfigDlg::repeatTog() {
243 244
244 Config config ("multikey"); 245 Config config ("multikey");
245 config.setGroup ("general"); 246 config.setGroup ("general");
246 config.writeEntry ("useRepeat", repeat_button->isChecked()); // default closed 247 config.writeEntry ("useRepeat", repeat_button->isChecked()); // default closed
247 248
248 emit repeatToggled(repeat_button->isChecked()); 249 emit repeatToggled(repeat_button->isChecked());
249} 250}
250 251
252void ConfigDlg::closeEvent(QCloseEvent *) {
253
254 // tell the parent it was closed, so delete me
255 emit configDlgClosed();
256}
257
251// ConfigDlg::setMap {{{1 258// ConfigDlg::setMap {{{1
252 259
253/* 260/*
254 * the index is kinda screwy, because in the config file, index 0 is just the 261 * the index is kinda screwy, because in the config file, index 0 is just the
255 * first element in the QStringList, but here it's the "Current Language" 262 * first element in the QStringList, but here it's the "Current Language"
256 * listItem. therefor you have to minus one to the index before you access it. 263 * listItem. therefor you have to minus one to the index before you access it.
257 * 264 *
258 */ 265 */
259 266
260void ConfigDlg::setMap(int index) { 267void ConfigDlg::setMap(int index) {
261 268
262 if (index == 0) { 269 if (index == 0) {
263 270
264 remove_button->setDisabled(true); 271 remove_button->setDisabled(true);
265 emit setMapToDefault(); 272 emit setMapToDefault();
266 } 273 }
267 else if ((uint)index <= default_maps.count()) { 274 else if ((uint)index <= default_maps.count()) {
268 275
269 remove_button->setDisabled(true); 276 remove_button->setDisabled(true);
270 emit setMapToFile(QPEApplication::qpeDir() + "/share/multikey/" + default_maps[index - 1]); 277 emit setMapToFile(QPEApplication::qpeDir() + "share/multikey/" + default_maps[index - 1]);
271 278
272 } else { 279 } else {
273 280
274 remove_button->setEnabled(true); 281 remove_button->setEnabled(true);
275 emit setMapToFile(custom_maps[index - default_maps.count() - 1]); 282 emit setMapToFile(custom_maps[index - default_maps.count() - 1]);
276 } 283 }
277} 284}
278 285
279// ConfigDlg::addMap() {{{1 286// ConfigDlg::addMap() {{{1
280void ConfigDlg::addMap() { 287void ConfigDlg::addMap() {
281 288
282 QString map = OFileDialog::getOpenFileName(1, QDir::home().absPath()); 289 QString map = OFileDialog::getOpenFileName(1, QDir::home().absPath());
diff --git a/inputmethods/multikey/configdlg.h b/inputmethods/multikey/configdlg.h
index 5d6403f..336932b 100644
--- a/inputmethods/multikey/configdlg.h
+++ b/inputmethods/multikey/configdlg.h
@@ -11,31 +11,34 @@ class ConfigDlg : public QTabWidget
11{ 11{
12 Q_OBJECT 12 Q_OBJECT
13 13
14public: 14public:
15 ConfigDlg (); 15 ConfigDlg ();
16 16
17signals: 17signals:
18 void pickboardToggled(bool on_off); 18 void pickboardToggled(bool on_off);
19 void repeatToggled(bool on_off); 19 void repeatToggled(bool on_off);
20 void setMapToDefault(); 20 void setMapToDefault();
21 void setMapToFile(QString map); 21 void setMapToFile(QString map);
22 void reloadKeyboard(); 22 void reloadKeyboard();
23 void configDlgClosed();
23 24
24private slots: 25private slots:
25 void pickTog(); 26 void pickTog();
26 void repeatTog(); 27 void repeatTog();
27 void setMap(int index); 28 void setMap(int index);
28 void addMap(); 29 void addMap();
29 void removeMap(); 30 void removeMap();
31 virtual void closeEvent ( QCloseEvent * );
32
30 33
31 // all those required slots for the color push buttons 34 // all those required slots for the color push buttons
32 void keyColorClicked(); 35 void keyColorClicked();
33 void keyColorPressedClicked(); 36 void keyColorPressedClicked();
34 void keyColorLinesClicked(); 37 void keyColorLinesClicked();
35 void textColorClicked(); 38 void textColorClicked();
36 39
37private: 40private:
38 QCheckBox *pick_button; 41 QCheckBox *pick_button;
39 QCheckBox *repeat_button; 42 QCheckBox *repeat_button;
40 QListBox *keymaps; 43 QListBox *keymaps;
41 QPushButton *add_button; 44 QPushButton *add_button;
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp
index 4747f59..28d5cab 100644
--- a/inputmethods/multikey/keyboard.cpp
+++ b/inputmethods/multikey/keyboard.cpp
@@ -31,26 +31,28 @@
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> 36#include <qstringlist.h>
37 37
38#include <sys/utsname.h> 38#include <sys/utsname.h>
39 39
40 40
41/* Keyboard::Keyboard {{{1 */ 41/* Keyboard::Keyboard {{{1 */
42Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : 42Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) :
43 QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), alt(0), meta(0), 43 QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), alt(0),
44 useLargeKeys(TRUE), usePicks(0), useRepeat(0), pressedKeyRow(-1), pressedKeyCol(-1), 44 meta(0), circumflex(0), diaeresis(0),
45 useLargeKeys(TRUE), usePicks(0), useRepeat(0),
46 pressedKeyRow(-1), pressedKeyCol(-1),
45 unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0), 47 unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0),
46 configdlg(0) 48 configdlg(0)
47 49
48{ 50{
49 51
50 // get the default font 52 // get the default font
51 Config *config = new Config( "qpe" ); 53 Config *config = new Config( "qpe" );
52 config->setGroup( "Appearance" ); 54 config->setGroup( "Appearance" );
53 QString familyStr = config->readEntry( "FontFamily", "fixed" ); 55 QString familyStr = config->readEntry( "FontFamily", "fixed" );
54 delete config; 56 delete config;
55 57
56 config = new Config("multikey"); 58 config = new Config("multikey");
@@ -86,25 +88,25 @@ Keyboard::~Keyboard() {
86 if ( configdlg ) { 88 if ( configdlg ) {
87 delete (ConfigDlg *) configdlg; 89 delete (ConfigDlg *) configdlg;
88 configdlg = 0; 90 configdlg = 0;
89 } 91 }
90 92
91} 93}
92 94
93/* Keyboard::resizeEvent {{{1 */ 95/* Keyboard::resizeEvent {{{1 */
94void Keyboard::resizeEvent(QResizeEvent*) 96void Keyboard::resizeEvent(QResizeEvent*)
95{ 97{
96 int ph = picks->sizeHint().height(); 98 int ph = picks->sizeHint().height();
97 picks->setGeometry( 0, 0, width(), ph ); 99 picks->setGeometry( 0, 0, width(), ph );
98 keyHeight = (height()-(usePicks ? ph : 0))/5; 100 keyHeight = (height()-(usePicks ? ph : 0))/keys->rows();
99 101
100 int nk; // number of keys? 102 int nk; // number of keys?
101 if ( useLargeKeys ) { 103 if ( useLargeKeys ) {
102 nk = 15; 104 nk = 15;
103 } else { 105 } else {
104 nk = 19; 106 nk = 19;
105 } 107 }
106 defaultKeyWidth = (width()/nk)/2; 108 defaultKeyWidth = (width()/nk)/2;
107 xoffs = (width()-defaultKeyWidth*nk)/2; // empty key spaces? 109 xoffs = (width()-defaultKeyWidth*nk)/2; // empty key spaces?
108 110
109} 111}
110 112
@@ -173,78 +175,116 @@ void Keyboard::drawKeyboard(QPainter &p, int row, int col)
173 int keyWidth = keys->width(row, col); 175 int keyWidth = keys->width(row, col);
174 176
175 p.fillRect(x + 1, y + 1, 177 p.fillRect(x + 1, y + 1,
176 keyWidth * defaultKeyWidth - 1, keyHeight - 1, 178 keyWidth * defaultKeyWidth - 1, keyHeight - 1,
177 pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor); 179 pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor);
178 180
179 QImage *pix = keys->pix(row,col); 181 QImage *pix = keys->pix(row,col);
180 182
181 ushort c = keys->uni(row, col); 183 ushort c = keys->uni(row, col);
182 184
183 p.setPen(textcolor); 185 p.setPen(textcolor);
184 if (!pix) { 186 if (!pix) {
185 if (shift || lock) 187 if ((shift || lock) && keys->shift(c))
186 c = keys->shift(c); 188
187 if (meta) { 189 if (circumflex && keys->circumflex(keys->shift(c)))
190 c = keys->circumflex(keys->shift(c));
191 else if (diaeresis && keys->diaeresis(keys->shift(c)))
192 c = keys->diaeresis(keys->shift(c));
193 else if (meta && keys->meta(keys->shift(c)))
194 c = keys->meta(keys->shift(c));
195 else
196 c = keys->shift(c);
188 197
198 else if (meta && keys->meta(c))
189 c = keys->meta(c); 199 c = keys->meta(c);
200 else if (circumflex && keys->circumflex(c))
201 c = keys->circumflex(c);
202 else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) {
203
204 // the diaeresis key itself has to be in the diaeresisMap,
205 // or just do this to make it display the diaeresis char.
206
207 if (c == 0x2c6)
208 c = 0xa8;
209 else
210 c = keys->diaeresis(c);
190 } 211 }
212
191 p.drawText(x, y, 213 p.drawText(x, y,
192 defaultKeyWidth * keyWidth + 3, keyHeight, 214 defaultKeyWidth * keyWidth + 3, keyHeight,
193 AlignCenter, (QChar)c); 215 AlignCenter, (QChar)c);
194 } 216 }
195 else 217 else
196 // center the image in the middle of the key 218 // center the image in the middle of the key
197 p.drawImage( x + (defaultKeyWidth * keyWidth - pix->width())/2 + 1, 219 p.drawImage( x + (defaultKeyWidth * keyWidth - pix->width())/2 + 1,
198 y + (keyHeight - pix->height())/2 + 1, 220 y + (keyHeight - pix->height())/2 + 1,
199 *pix ); 221 *pix );
200 222
201 // this fixes the problem that the very right end of the board's vertical line 223 // this fixes the problem that the very right end of the board's vertical line
202 // gets painted over, because it's one pixel shorter than all other keys 224 // gets painted over, because it's one pixel shorter than all other keys
203 p.setPen(keycolor_lines); 225 p.setPen(keycolor_lines);
204 p.drawLine(width() - 1, 0, width() - 1, height()); 226 p.drawLine(width() - 1, 0, width() - 1, height());
205 227
206 } else { 228 } else {
207 229
208 230
209 p.fillRect(0, 0, width(), height(), keycolor); 231 p.fillRect(0, 0, width(), height(), keycolor);
210 232
211 for (row = 1; row <= 5; row++) { 233 for (row = 1; row <= keys->rows(); row++) {
212 234
213 int x = 0; 235 int x = 0;
214 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); 236 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0);
215 237
216 p.setPen(keycolor_lines); 238 p.setPen(keycolor_lines);
217 p.drawLine(x, y, x + width(), y); 239 p.drawLine(x, y, x + width(), y);
218 240
219 for (int col = 0; col < keys->numKeys(row); col++) { 241 for (int col = 0; col < keys->numKeys(row); col++) {
220 242
221 QImage *pix = keys->pix(row, col); 243 QImage *pix = keys->pix(row, col);
222 int keyWidth = keys->width(row, col); 244 int keyWidth = keys->width(row, col);
223 245
224 246
225 int keyWidthPix = defaultKeyWidth * keyWidth; 247 int keyWidthPix = defaultKeyWidth * keyWidth;
226 248
227 if (keys->pressed(row, col)) 249 if (keys->pressed(row, col))
228 p.fillRect(x+1, y+1, keyWidthPix - 1, 250 p.fillRect(x+1, y+1, keyWidthPix - 1,
229 keyHeight - 1, keycolor_pressed); 251 keyHeight - 1, keycolor_pressed);
230 252
231 ushort c = keys->uni(row, col); 253 ushort c = keys->uni(row, col);
232 254
233 p.setPen(textcolor); 255 p.setPen(textcolor);
234 if (!pix) { 256 if (!pix) {
235 if ((shift || lock) && keys->shift(c)) 257 if ((shift || lock) && keys->shift(c))
236 c = keys->shift(c); 258
259 if (circumflex && keys->circumflex(keys->shift(c)))
260 c = keys->circumflex(keys->shift(c));
261 else if (diaeresis && keys->diaeresis(keys->shift(c)))
262 c = keys->diaeresis(keys->shift(c));
263 else if (meta && keys->meta(keys->shift(c)))
264 c = keys->meta(keys->shift(c));
265 else
266 c = keys->shift(c);
267
237 else if (meta && keys->meta(c)) 268 else if (meta && keys->meta(c))
238 c = keys->meta(c); 269 c = keys->meta(c);
270 else if (circumflex && keys->circumflex(c))
271 c = keys->circumflex(c);
272 else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) {
273
274 if (c == 0x2c6)
275 c = 0xa8;
276 else
277 c = keys->diaeresis(c);
278 }
239 279
240 p.drawText(x, y, 280 p.drawText(x, y,
241 keyWidthPix + 3, keyHeight, 281 keyWidthPix + 3, keyHeight,
242 AlignCenter, (QChar)c); 282 AlignCenter, (QChar)c);
243 } 283 }
244 else { 284 else {
245 // center the image in the middle of the key 285 // center the image in the middle of the key
246 pix->setColor(1, textcolor.rgb()); 286 pix->setColor(1, textcolor.rgb());
247 p.drawImage( x + (keyWidthPix - pix->width())/2 + 1, 287 p.drawImage( x + (keyWidthPix - pix->width())/2 + 1,
248 y + (keyHeight - pix->height())/2 + 1, 288 y + (keyHeight - pix->height())/2 + 1,
249 QImage(*pix) ); 289 QImage(*pix) );
250 } 290 }
@@ -280,44 +320,64 @@ void Keyboard::mousePressEvent(QMouseEvent *e)
280 320
281 if (col <= 0) return; 321 if (col <= 0) return;
282 322
283 col --; // rewind one... 323 col --; // rewind one...
284 324
285 qkeycode = keys->qcode(row, col); 325 qkeycode = keys->qcode(row, col);
286 unicode = keys->uni(row, col); 326 unicode = keys->uni(row, col);
287 327
288 // might need to repaint if two or more of the same keys. 328 // might need to repaint if two or more of the same keys.
289 // should be faster if just paint one key even though multiple keys exist. 329 // should be faster if just paint one key even though multiple keys exist.
290 bool need_repaint = FALSE; 330 bool need_repaint = FALSE;
291 331
332 // circumflex and diaeresis support
333 // messy to have this here, but too hard to implement any other method
334 if (unicode == 0x2c6) {
335
336 unicode = 0;
337 if (shift || lock) {
338
339 // diaeresis
340 qkeycode = 0x2001;
341 }
342 else {
343
344 // circumflex
345 qkeycode = 0x2000;
346 }
347 }
348
292 if (unicode == 0) { // either Qt char, or nothing 349 if (unicode == 0) { // either Qt char, or nothing
293 350
294 if (qkeycode == Qt::Key_F1) { // toggle the pickboard 351 if (qkeycode == Qt::Key_F1) { // toggle the pickboard
295 352
296 if ( configdlg ) { 353 if ( configdlg ) {
354
297 delete (ConfigDlg *) configdlg; 355 delete (ConfigDlg *) configdlg;
298 configdlg = 0; 356 configdlg = 0;
299 } 357 }
300 else { 358 else {
301 configdlg = new ConfigDlg (); 359 configdlg = new ConfigDlg ();
302 connect(configdlg, SIGNAL(setMapToDefault()), 360 connect(configdlg, SIGNAL(setMapToDefault()),
303 this, SLOT(setMapToDefault())); 361 this, SLOT(setMapToDefault()));
304 connect(configdlg, SIGNAL(setMapToFile(QString)), 362 connect(configdlg, SIGNAL(setMapToFile(QString)),
305 this, SLOT(setMapToFile(QString))); 363 this, SLOT(setMapToFile(QString)));
306 connect(configdlg, SIGNAL(pickboardToggled(bool)), 364 connect(configdlg, SIGNAL(pickboardToggled(bool)),
307 this, SLOT(togglePickboard(bool))); 365 this, SLOT(togglePickboard(bool)));
308 connect(configdlg, SIGNAL(repeatToggled(bool)), 366 connect(configdlg, SIGNAL(repeatToggled(bool)),
309 this, SLOT(toggleRepeat(bool))); 367 this, SLOT(toggleRepeat(bool)));
310 connect(configdlg, SIGNAL(reloadKeyboard()), 368 connect(configdlg, SIGNAL(reloadKeyboard()),
311 this, SLOT(reloadKeyboard())); 369 this, SLOT(reloadKeyboard()));
370 connect(configdlg, SIGNAL(configDlgClosed()),
371 this, SLOT(cleanupConfigDlg()));
312 configdlg->showMaximized(); 372 configdlg->showMaximized();
313 configdlg->show(); 373 configdlg->show();
314 configdlg->raise(); 374 configdlg->raise();
315 } 375 }
316 376
317 } else if (qkeycode == Qt::Key_Control) { 377 } else if (qkeycode == Qt::Key_Control) {
318 need_repaint = TRUE; 378 need_repaint = TRUE;
319 379
320 if (ctrl) { 380 if (ctrl) {
321 381
322 *ctrl = 0; 382 *ctrl = 0;
323 ctrl = 0; 383 ctrl = 0;
@@ -350,90 +410,184 @@ void Keyboard::mousePressEvent(QMouseEvent *e)
350 if (shift) { 410 if (shift) {
351 *shift = 0; 411 *shift = 0;
352 shift = 0; 412 shift = 0;
353 } 413 }
354 else { 414 else {
355 shift = keys->pressedPtr(row, col); 415 shift = keys->pressedPtr(row, col);
356 *shift = 1; 416 *shift = 1;
357 if (lock) { 417 if (lock) {
358 *lock = 0; 418 *lock = 0;
359 lock = 0; 419 lock = 0;
360 } 420 }
361 } 421 }
362 if (meta) {
363 422
364 *meta = 0; 423
365 meta = 0; 424 /*
366 } 425 * want to be able to hit circumflex/diaeresis -> shift
426 * to type in shifted circumflex/diaeresis chars.
427 * same thing with meta
428
429 if (meta) { *meta = 0; meta = 0; }
430 if (circumflex) { *circumflex = 0; circumflex = 0; }
431 if (diaeresis) { *diaeresis = 0; diaeresis = 0; }
432
433 */
367 434
368 } else if (qkeycode == Qt::Key_CapsLock) { 435 } else if (qkeycode == Qt::Key_CapsLock) {
369 need_repaint = TRUE; 436 need_repaint = TRUE;
370 437
371 if (lock) { 438 if (lock) {
372 *lock = 0; 439 *lock = 0;
373 lock = 0; 440 lock = 0;
374 } 441 }
375 else { 442 else {
376 lock = keys->pressedPtr(row, col);; 443 lock = keys->pressedPtr(row, col);;
377 *lock = 1; 444 *lock = true;;
378 if (shift) { 445 if (shift) {
379 *shift = 0; 446 *shift = 0;
380 shift = 0; 447 shift = 0;
381 } 448 }
382 } 449 }
383 if (meta) {
384 450
385 *meta = 0; 451 /*
386 meta = 0; 452 if (meta) { *meta = 0; meta = 0; }
387 } 453 if (circumflex) { *circumflex = 0; circumflex = 0; }
454 if (diaeresis) { *diaeresis = 0; diaeresis = 0; }
455 */
388 456
389 } else if (qkeycode == Qt::Key_Meta) { 457 } else if (qkeycode == Qt::Key_Meta) {
390 need_repaint = TRUE; 458 need_repaint = TRUE;
391 459
392 if (meta) { 460 if (meta) {
393 *meta = 0; 461 *meta = 0;
394 meta = 0; 462 meta = 0;
395 463
396 } else { 464 } else {
397 465
398 meta = keys->pressedPtr(row, col); 466 meta = keys->pressedPtr(row, col);
399 need_repaint = TRUE; 467 *meta = true;
400 *meta = !keys->pressed(row, col);
401 } 468 }
402 469
403 if (shift) { 470 // reset all the other keys
471 if (shift) { *shift = 0; shift = 0; }
472 if (lock) { *lock = 0; lock = 0; }
473 if (circumflex) { *circumflex = 0; circumflex = 0; }
474 if (diaeresis) { *diaeresis = 0; diaeresis = 0; }
404 475
405 *shift = 0; 476 // dont need to emit this key... acts same as alt
406 shift = 0; 477 qkeycode = 0;
478
479 // circumflex
480 } else if (qkeycode == 0x2000) {
481 need_repaint = TRUE;
482
483 if (circumflex) {
484
485 *circumflex = 0;
486 circumflex = 0;
487
488 } else {
407 489
490 circumflex = keys->pressedPtr(row, col);
491 *circumflex = true;
408 } 492 }
409 if (lock) {
410 493
411 *lock = 0; 494 /* no need to turn off shift or lock if circumflex
412 lock = 0; 495 * keys are pressed
496
497 if (shift) { *shift = 0; shift = 0; }
498 if (lock) { *lock = 0; lock = 0; }
499
500 */
501
502 // have to reset all the other keys
503 if (meta) { *meta = 0; meta = 0; }
504 if (diaeresis) {
505
506 // *diaeresis and *circumflex point to the same thing
507 // when diaeresis is enabled and you hit the circumflex
508 // since they are the same key, it should turn off the
509 // key
510
511 *diaeresis = 0;
512 diaeresis = 0;
513 circumflex = 0;
514 }
515
516 qkeycode = 0;
413 517
518 // diaeresis
519 } else if (qkeycode == 0x2001) {
520 need_repaint = TRUE;
521
522 if (diaeresis) {
523
524 *diaeresis = 0;
525 diaeresis = 0;
526
527 } else {
528
529 diaeresis = keys->pressedPtr(row, col);
530 *diaeresis = true;
414 } 531 }
415 532
416 // dont need to emit this key... acts same as alt 533
534 if (shift) { *shift = 0; shift = 0; }
535
536 /*
537 *
538 if (lock) { *lock = 0; lock = 0; }
539 *
540 */
541
542 if (meta) { *meta = 0; meta = 0; }
543 if (circumflex) {
544
545 // *circumflex = 0;
546 //
547 // same thing the diaeresis pointer points too
548
549 circumflex = 0;
550 }
551
552
417 qkeycode = 0; 553 qkeycode = 0;
418 } 554 }
419 555
420 } 556 }
421 else { // normal char 557 else { // normal char
422 if ((shift || lock) && keys->shift(unicode)) { 558 if ((shift || lock) && keys->shift(unicode)) {
423 unicode = keys->shift(unicode); 559
560 // make diaeresis/circumflex -> shift input shifted
561 // diaeresis/circumflex chars
562
563 if (circumflex && keys->circumflex(keys->shift(unicode)))
564 unicode = keys->circumflex(keys->shift(unicode));
565 else if (diaeresis && keys->diaeresis(keys->shift(unicode)))
566 unicode = keys->diaeresis(keys->shift(unicode));
567 else if (meta && keys->meta(keys->shift(unicode)))
568 unicode = keys->meta(keys->shift(unicode));
569 else
570 unicode = keys->shift(unicode);
424 } 571 }
425 if (meta && keys->meta(unicode)) { 572 else if (meta && keys->meta(unicode)) {
426 unicode = keys->meta(unicode); 573 unicode = keys->meta(unicode);
427 } 574 }
575 else if (circumflex && keys->circumflex(unicode)) {
576 unicode = keys->circumflex(unicode);
577 }
578 else if (diaeresis && keys->diaeresis(unicode)) {
579
580 unicode = keys->diaeresis(unicode);
581 }
428 } 582 }
429 583
430 // korean parsing 584 // korean parsing
431 if (keys->lang == "ko") { 585 if (keys->lang == "ko") {
432 586
433 unicode = parseKoreanInput(unicode); 587 unicode = parseKoreanInput(unicode);
434 } 588 }
435 589
436 modifiers = (ctrl ? Qt::ControlButton : 0) | (alt ? Qt::AltButton : 0); 590 modifiers = (ctrl ? Qt::ControlButton : 0) | (alt ? Qt::AltButton : 0);
437 591
438 if ('A' <= unicode && unicode <= 'z' && modifiers) { 592 if ('A' <= unicode && unicode <= 'z' && modifiers) {
439 593
@@ -495,33 +649,40 @@ void Keyboard::mouseReleaseEvent(QMouseEvent*)
495 if ( unicode != -1 ) { 649 if ( unicode != -1 ) {
496 emit key( unicode, qkeycode, modifiers, false, false ); 650 emit key( unicode, qkeycode, modifiers, false, false );
497 repeatTimer->stop(); 651 repeatTimer->stop();
498 } 652 }
499#endif 653#endif
500 if (shift && unicode != 0) { 654 if (shift && unicode != 0) {
501 655
502 656
503 *shift = 0; // unpress shift key 657 *shift = 0; // unpress shift key
504 shift = 0; // reset the shift pointer 658 shift = 0; // reset the shift pointer
505 repaint(FALSE); 659 repaint(FALSE);
506 660
507 } else if (meta && unicode != 0) { 661 }
662
663 /*
664 * do not make the meta key release after being pressed
665 *
666
667 else if (meta && unicode != 0) {
508 668
509 *meta = 0; 669 *meta = 0;
510 meta = 0; 670 meta = 0;
511 repaint(FALSE); 671 repaint(FALSE);
512 } 672 }
513 else
514 673
515 clearHighlight(); 674 */
675
676 else clearHighlight();
516} 677}
517 678
518/* Keyboard::timerEvent {{{1 */ 679/* Keyboard::timerEvent {{{1 */
519 680
520/* dont know what this does, but i think it is here so that if your screen 681/* dont know what this does, but i think it is here so that if your screen
521 * sticks (like on an ipaq) then it will stop repeating if you click another 682 * sticks (like on an ipaq) then it will stop repeating if you click another
522 * key... but who knows what anything does in this thing anyway? 683 * key... but who knows what anything does in this thing anyway?
523 684
524 void Keyboard::timerEvent(QTimerEvent* e) 685 void Keyboard::timerEvent(QTimerEvent* e)
525{ 686{
526 if ( e->timerId() == pressTid ) { 687 if ( e->timerId() == pressTid ) {
527 killTimer(pressTid); 688 killTimer(pressTid);
@@ -552,30 +713,36 @@ void Keyboard::clearHighlight()
552 QPainter p(this); 713 QPainter p(this);
553 drawKeyboard(p, tmpRow, tmpCol); 714 drawKeyboard(p, tmpRow, tmpCol);
554 } 715 }
555} 716}
556 717
557 718
558/* Keyboard::sizeHint {{{1 */ 719/* Keyboard::sizeHint {{{1 */
559QSize Keyboard::sizeHint() const 720QSize Keyboard::sizeHint() const
560{ 721{
561 QFontMetrics fm=fontMetrics(); 722 QFontMetrics fm=fontMetrics();
562 int keyHeight = fm.lineSpacing() + 2; 723 int keyHeight = fm.lineSpacing() + 2;
563 724
564 return QSize( 240, keyHeight * 5 + (usePicks ? picks->sizeHint().height() : 0) + 1); 725 return QSize( 240, keyHeight * keys->rows() + (usePicks ? picks->sizeHint().height() : 0) + 1);
565} 726}
566 727
567 728
568void Keyboard::resetState() 729void Keyboard::resetState()
569{ 730{
731 if (shift) { *shift = 0; shift = 0; }
732 if (lock) {*lock = 0; lock = 0; }
733 if (meta) { *meta = 0; meta = 0; }
734 if (circumflex) { *circumflex = 0; circumflex = 0; }
735 if (diaeresis) { *diaeresis = 0; diaeresis = 0; }
736
570 schar = mchar = echar = 0; 737 schar = mchar = echar = 0;
571 picks->resetState(); 738 picks->resetState();
572} 739}
573 740
574/* Keyboard::togglePickboard {{{1 */ 741/* Keyboard::togglePickboard {{{1 */
575void Keyboard::togglePickboard(bool on_off) 742void Keyboard::togglePickboard(bool on_off)
576{ 743{
577 usePicks = on_off; 744 usePicks = on_off;
578 if (usePicks) { 745 if (usePicks) {
579 picks->show(); 746 picks->show();
580 //move(x(), y() - picks->height()); // not required anymore because QCopChannel::send 747 //move(x(), y() - picks->height()); // not required anymore because QCopChannel::send
581 //adjustSize(); 748 //adjustSize();
@@ -595,67 +762,92 @@ void Keyboard::togglePickboard(bool on_off)
595 * this closes && opens the input method 762 * this closes && opens the input method
596 */ 763 */
597 QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); 764 QCopChannel::send ("QPE/TaskBar", "hideInputMethod()");
598 QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); 765 QCopChannel::send ("QPE/TaskBar", "showInputMethod()");
599} 766}
600 767
601void Keyboard::toggleRepeat(bool on) { 768void Keyboard::toggleRepeat(bool on) {
602 769
603 useRepeat = on; 770 useRepeat = on;
604 //cout << "setting useRepeat to: " << useRepeat << "\n"; 771 //cout << "setting useRepeat to: " << useRepeat << "\n";
605} 772}
606 773
774void Keyboard::cleanupConfigDlg() {
775
776 if ( configdlg ) {
777 delete (ConfigDlg *) configdlg;
778 configdlg = 0;
779 }
780}
781
607/* Keyboard::setMapTo ... {{{1 */ 782/* Keyboard::setMapTo ... {{{1 */
608void Keyboard::setMapToDefault() { 783void Keyboard::setMapToDefault() {
609 784
610 785
611 /* load current locale language map */ 786 /* load current locale language map */
612 Config *config = new Config("locale"); 787 Config *config = new Config("locale");
613 config->setGroup( "Language" ); 788 config->setGroup( "Language" );
614 QString l = config->readEntry( "Language" , "en" ); 789 QString l = config->readEntry( "Language" , "en" );
615 delete config; 790 delete config;
616 791
617 QString key_map = QPEApplication::qpeDir() + "/share/multikey/" 792 QString key_map = QPEApplication::qpeDir() + "share/multikey/"
618 + l + ".keymap"; 793 + l + ".keymap";
619 794
620 /* save change to multikey config file */ 795 /* save change to multikey config file */
621 config = new Config("multikey"); 796 config = new Config("multikey");
622 config->setGroup ("keymaps"); 797 config->setGroup ("keymaps");
623 config->writeEntry ("current", key_map); // default closed 798 config->writeEntry ("current", key_map); // default closed
624 delete config; 799 delete config;
625 800
801 int prevRows = keys->rows();
802
626 delete keys; 803 delete keys;
627 keys = new Keys(key_map); 804 keys = new Keys(key_map);
628 805
629 // have to repaint the keyboard 806 // have to repaint the keyboard
630 repaint(FALSE); 807 if (prevRows != keys->rows()) {
808
809 QCopChannel::send ("QPE/TaskBar", "hideInputMethod()");
810 QCopChannel::send ("QPE/TaskBar", "showInputMethod()");
811
812 } else repaint(FALSE);
813
814 resetState();
631} 815}
632 816
633void Keyboard::setMapToFile(QString map) { 817void Keyboard::setMapToFile(QString map) {
634 818
635 /* save change to multikey config file */ 819 /* save change to multikey config file */
636 Config *config = new Config("multikey"); 820 Config *config = new Config("multikey");
637 config->setGroup ("keymaps"); 821 config->setGroup ("keymaps");
638 config->writeEntry ("current", map); // default closed 822 config->writeEntry ("current", map); // default closed
639 823
640 delete config; 824 delete config;
641 825
826 int prevRows = keys->rows();
827
642 delete keys; 828 delete keys;
643 if (QFile(map).exists()) 829 if (QFile(map).exists())
644 keys = new Keys(map); 830 keys = new Keys(map);
645 else 831 else
646 keys = new Keys(); 832 keys = new Keys();
647 833
648 repaint(FALSE); 834 if (keys->rows() != prevRows) {
835
836 QCopChannel::send ("QPE/TaskBar", "hideInputMethod()");
837 QCopChannel::send ("QPE/TaskBar", "showInputMethod()");
838 }
839 else repaint(FALSE);
649 840
841 resetState();
650} 842}
651 843
652/* Keybaord::reloadKeyboard {{{1 */ 844/* Keybaord::reloadKeyboard {{{1 */
653void Keyboard::reloadKeyboard() { 845void Keyboard::reloadKeyboard() {
654 846
655 // reload colors and redraw 847 // reload colors and redraw
656 loadKeyboardColors(); 848 loadKeyboardColors();
657 repaint(); 849 repaint();
658 850
659} 851}
660 852
661void Keyboard::loadKeyboardColors() { 853void Keyboard::loadKeyboardColors() {
@@ -1115,24 +1307,49 @@ void Keys::setKeysFromFile(const char * filename) {
1115 else if (buf.contains(QRegExp("^\\s*m\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { 1307 else if (buf.contains(QRegExp("^\\s*m\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) {
1116 1308
1117 QTextStream tmp (buf, IO_ReadOnly); 1309 QTextStream tmp (buf, IO_ReadOnly);
1118 ushort lower, shift; 1310 ushort lower, shift;
1119 QChar m; 1311 QChar m;
1120 tmp >> m >> lower >> shift; 1312 tmp >> m >> lower >> shift;
1121 1313
1122 metaMap.insert(lower, shift); 1314 metaMap.insert(lower, shift);
1123 1315
1124 buf = t.readLine(); 1316 buf = t.readLine();
1125 } 1317 }
1126 1318
1319 // circumflex
1320 else if (buf.contains(QRegExp("^\\s*c\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) {
1321
1322 QTextStream tmp (buf, IO_ReadOnly);
1323 ushort lower, shift;
1324 QChar c;
1325 tmp >> c >> lower >> shift;
1326
1327 circumflexMap.insert(lower, shift);
1328
1329 buf = t.readLine();
1330 }
1331 // diaeresis
1332 else if (buf.contains(QRegExp("^\\s*d\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) {
1333
1334 QTextStream tmp (buf, IO_ReadOnly);
1335 ushort lower, shift;
1336 QChar d;
1337 tmp >> d >> lower >> shift;
1338
1339 diaeresisMap.insert(lower, shift);
1340
1341 buf = t.readLine();
1342 }
1343
1127 // other variables like lang & title 1344 // other variables like lang & title
1128 else if (buf.contains(QRegExp("^\\s*[a-zA-Z]+\\s*=\\s*[a-zA-Z0-9/]+\\s*$", FALSE, FALSE))) { 1345 else if (buf.contains(QRegExp("^\\s*[a-zA-Z]+\\s*=\\s*[a-zA-Z0-9/]+\\s*$", FALSE, FALSE))) {
1129 1346
1130 QTextStream tmp (buf, IO_ReadOnly); 1347 QTextStream tmp (buf, IO_ReadOnly);
1131 QString name, equals, value; 1348 QString name, equals, value;
1132 1349
1133 tmp >> name >> equals >> value; 1350 tmp >> name >> equals >> value;
1134 1351
1135 if (name == "lang") { 1352 if (name == "lang") {
1136 1353
1137 lang = value; 1354 lang = value;
1138 1355
@@ -1196,24 +1413,36 @@ Keys::~Keys() {
1196 for (int i = 1; i <= 5; i++) 1413 for (int i = 1; i <= 5; i++)
1197 for (unsigned int j = 0; j < keys[i].count(); j++) 1414 for (unsigned int j = 0; j < keys[i].count(); j++)
1198 delete keys[i].at(j); 1415 delete keys[i].at(j);
1199 1416
1200} 1417}
1201 1418
1202// Keys:: other functions {{{2 1419// Keys:: other functions {{{2
1203int Keys::width(const int row, const int col) { 1420int Keys::width(const int row, const int col) {
1204 1421
1205 return keys[row].at(col)->width; 1422 return keys[row].at(col)->width;
1206 1423
1207} 1424}
1425
1426int Keys::rows() {
1427
1428 for (int i = 1; i <= 5; i++) {
1429
1430 if (keys[i].count() == 0)
1431 return i - 1;
1432
1433 }
1434 return 5;
1435}
1436
1208ushort Keys::uni(const int row, const int col) { 1437ushort Keys::uni(const int row, const int col) {
1209 1438
1210 return keys[row].at(col)->unicode; 1439 return keys[row].at(col)->unicode;
1211 1440
1212} 1441}
1213 1442
1214int Keys::qcode(const int row, const int col) { 1443int Keys::qcode(const int row, const int col) {
1215 1444
1216 return keys[row].at(col)->qcode; 1445 return keys[row].at(col)->qcode;
1217} 1446}
1218 1447
1219QImage *Keys::pix(const int row, const int col) { 1448QImage *Keys::pix(const int row, const int col) {
@@ -1229,36 +1458,38 @@ bool Keys::pressed(const int row, const int col) {
1229int Keys::numKeys(const int row) { 1458int Keys::numKeys(const int row) {
1230 1459
1231 return keys[row].count(); 1460 return keys[row].count();
1232} 1461}
1233 1462
1234void Keys::setPressed(const int row, const int col, const bool pressed) { 1463void Keys::setPressed(const int row, const int col, const bool pressed) {
1235 1464
1236 *(keys[row].at(col)->pressed) = pressed; 1465 *(keys[row].at(col)->pressed) = pressed;
1237} 1466}
1238 1467
1239ushort Keys::shift(const ushort uni) { 1468ushort Keys::shift(const ushort uni) {
1240 1469
1241 if (shiftMap[uni]) { 1470 if (shiftMap[uni]) return shiftMap[uni];
1471 else return 0;
1472}
1242 1473
1243 return shiftMap[uni]; 1474ushort Keys::meta(const ushort uni) {
1244 }
1245 else
1246 return 0;
1247 1475
1476 if (metaMap[uni]) return metaMap[uni];
1477 else return 0;
1248} 1478}
1249 1479
1250ushort Keys::meta(const ushort uni) { 1480ushort Keys::circumflex(const ushort uni) {
1251 1481
1252 if (metaMap[uni]) { 1482 if (circumflexMap[uni]) return circumflexMap[uni];
1483 else return 0;
1484}
1253 1485
1254 return metaMap[uni]; 1486ushort Keys::diaeresis(const ushort uni) {
1255 }
1256 else
1257 return 0;
1258 1487
1488 if(diaeresisMap[uni]) return diaeresisMap[uni];
1489 else return 0;
1259} 1490}
1260 1491
1261bool *Keys::pressedPtr(const int row, const int col) { 1492bool *Keys::pressedPtr(const int row, const int col) {
1262 1493
1263 return keys[row].at(col)->pressed; 1494 return keys[row].at(col)->pressed;
1264} 1495}
diff --git a/inputmethods/multikey/keyboard.h b/inputmethods/multikey/keyboard.h
index 1aa7a35..8af80d0 100644
--- a/inputmethods/multikey/keyboard.h
+++ b/inputmethods/multikey/keyboard.h
@@ -47,55 +47,60 @@ public:
47 void initialise(); 47 void initialise();
48 virtual QSize sizeHint() const; 48 virtual QSize sizeHint() const;
49 KeyboardConfig *dc; 49 KeyboardConfig *dc;
50}; 50};
51 51
52 52
53class Keys { 53class Keys {
54public: 54public:
55 55
56 Keys(); 56 Keys();
57 Keys(const char * filename); 57 Keys(const char * filename);
58 ~Keys(); 58 ~Keys();
59 int width(const int row, const int col);
60 int rows();
59 ushort uni(const int row, const int col); 61 ushort uni(const int row, const int col);
60 int qcode(const int row, const int col); 62 int qcode(const int row, const int col);
61 int width(const int row, const int col);
62 bool pressed(const int row, const int col); 63 bool pressed(const int row, const int col);
63 bool *pressedPtr(const int row, const int col); 64 bool *pressedPtr(const int row, const int col);
64 ushort shift(const ushort); 65 ushort shift(const ushort);
65 ushort meta(const ushort); 66 ushort meta(const ushort);
67 ushort circumflex(const ushort);
68 ushort diaeresis(const ushort);
66 QImage *pix(const int row, const int col); 69 QImage *pix(const int row, const int col);
67 int numKeys(const int row); 70 int numKeys(const int row);
68 void setKeysFromFile(const char *filename); 71 void setKeysFromFile(const char *filename);
69 void setKey(const int row, const int qcode, const ushort unicode, 72 void setKey(const int row, const int qcode, const ushort unicode,
70 const int width, QImage *pix); 73 const int width, QImage *pix);
71 void setPressed(const int row, const int col, const bool pressed); 74 void setPressed(const int row, const int col, const bool pressed);
72 QString lang; 75 QString lang;
73 QString label; 76 QString label;
74 77
75private: 78private:
76 79
77 typedef struct Key { 80 typedef struct Key {
78 int qcode; // are qt key codes just unicode values? 81 int qcode; // are qt key codes just unicode values?
79 ushort unicode; 82 ushort unicode;
80 int width; // not pixels but relative key width. normal key is 2 83 int width; // not pixels but relative key width. normal key is 2
81 84
82 // only needed for keys like ctrl that can have multiple keys pressed at once 85 // only needed for keys like ctrl that can have multiple keys pressed at once
83 bool *pressed; 86 bool *pressed;
84 QImage *pix; 87 QImage *pix;
85 }; 88 };
86 89
87 QList<Key> keys[6]; 90 QList<Key> keys[6];
88 QMap<ushort,ushort> shiftMap; 91 QMap<ushort,ushort> shiftMap;
89 QMap<ushort,ushort> metaMap; 92 QMap<ushort,ushort> metaMap;
93 QMap<ushort,ushort> circumflexMap;
94 QMap<ushort,ushort> diaeresisMap;
90 95
91}; 96};
92 97
93class Keyboard : public QFrame 98class Keyboard : public QFrame
94{ 99{
95 Q_OBJECT 100 Q_OBJECT
96public: 101public:
97 Keyboard( QWidget* parent=0, const char* name=0, WFlags f=0 ); 102 Keyboard( QWidget* parent=0, const char* name=0, WFlags f=0 );
98 ~Keyboard(); 103 ~Keyboard();
99 104
100 void resetState(); 105 void resetState();
101 106
@@ -108,37 +113,41 @@ public:
108 113
109 QSize sizeHint() const; 114 QSize sizeHint() const;
110 115
111signals: 116signals:
112 void key( ushort scancode, ushort unicode, ushort modifiers, bool, bool ); 117 void key( ushort scancode, ushort unicode, ushort modifiers, bool, bool );
113 118
114private slots: 119private slots:
115 void repeat(); 120 void repeat();
116 void togglePickboard(bool on_off); 121 void togglePickboard(bool on_off);
117 void toggleRepeat(bool on_off); 122 void toggleRepeat(bool on_off);
118 void setMapToDefault(); 123 void setMapToDefault();
119 void setMapToFile(QString map); 124 void setMapToFile(QString map);
125 void cleanupConfigDlg();
120 126
121 // used to redraw keyboard after edited colors 127 // used to redraw keyboard after edited colors
122 void reloadKeyboard(); 128 void reloadKeyboard();
123 129
124private: 130private:
125 int getKey( int &w, int j = -1 ); 131 int getKey( int &w, int j = -1 );
126 void clearHighlight(); 132 void clearHighlight();
127 133
128 bool *shift; 134 bool *shift;
129 bool *lock; 135 bool *lock;
130 bool *ctrl; 136 bool *ctrl;
131 bool *alt; 137 bool *alt;
132 bool *meta; 138 bool *meta;
139 bool *circumflex;
140 bool *diaeresis;
141
133 uint useLargeKeys:1; 142 uint useLargeKeys:1;
134 uint usePicks:1; 143 uint usePicks:1;
135 uint useRepeat:1; 144 uint useRepeat:1;
136 145
137 int pressedKeyRow; 146 int pressedKeyRow;
138 int pressedKeyCol; 147 int pressedKeyCol;
139 148
140 KeyboardPicks *picks; 149 KeyboardPicks *picks;
141 150
142 int keyHeight; 151 int keyHeight;
143 int defaultKeyWidth; 152 int defaultKeyWidth;
144 int xoffs; 153 int xoffs;