summaryrefslogtreecommitdiff
path: root/inputmethods/multikey/keyboard.cpp
authorhash <hash>2002-09-06 21:23:05 (UTC)
committer hash <hash>2002-09-06 21:23:05 (UTC)
commitfc4808bea669f75af0c28ba65cf2c638c97e99ba (patch) (unidiff)
tree2ced268c3d31f9dded6d8332698ee8e476a081c0 /inputmethods/multikey/keyboard.cpp
parent15992c5f9b24eaf8df6f90d1993c85d73827b98f (diff)
downloadopie-fc4808bea669f75af0c28ba65cf2c638c97e99ba.zip
opie-fc4808bea669f75af0c28ba65cf2c638c97e99ba.tar.gz
opie-fc4808bea669f75af0c28ba65cf2c638c97e99ba.tar.bz2
french and other stuff fixed
Diffstat (limited to 'inputmethods/multikey/keyboard.cpp') (more/less context) (show whitespace changes)
-rw-r--r--inputmethods/multikey/keyboard.cpp315
1 files changed, 273 insertions, 42 deletions
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
@@ -37,14 +37,16 @@
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
@@ -92,13 +94,13 @@ Keyboard::~Keyboard() {
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;
@@ -179,18 +181,38 @@ void Keyboard::drawKeyboard(QPainter &p, int row, int col)
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))
188
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
186 c = keys->shift(c); 196 c = keys->shift(c);
187 if (meta) {
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
@@ -205,13 +227,13 @@ void Keyboard::drawKeyboard(QPainter &p, int row, int col)
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);
@@ -230,15 +252,33 @@ void Keyboard::drawKeyboard(QPainter &p, int row, int col)
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))
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
236 c = keys->shift(c); 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 {
@@ -286,17 +326,35 @@ void Keyboard::mousePressEvent(QMouseEvent *e)
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()),
@@ -306,12 +364,14 @@ void Keyboard::mousePressEvent(QMouseEvent *e)
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) {
@@ -356,78 +416,172 @@ void Keyboard::mousePressEvent(QMouseEvent *e)
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);
467 *meta = true;
468 }
469
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; }
475
476 // dont need to emit this key... acts same as alt
477 qkeycode = 0;
478
479 // circumflex
480 } else if (qkeycode == 0x2000) {
399 need_repaint = TRUE; 481 need_repaint = TRUE;
400 *meta = !keys->pressed(row, col); 482
483 if (circumflex) {
484
485 *circumflex = 0;
486 circumflex = 0;
487
488 } else {
489
490 circumflex = keys->pressedPtr(row, col);
491 *circumflex = true;
401 } 492 }
402 493
403 if (shift) { 494 /* no need to turn off shift or lock if circumflex
495 * keys are pressed
404 496
405 *shift = 0; 497 if (shift) { *shift = 0; shift = 0; }
406 shift = 0; 498 if (lock) { *lock = 0; lock = 0; }
499
500 */
407 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;
408 } 514 }
409 if (lock) {
410 515
411 *lock = 0; 516 qkeycode = 0;
412 lock = 0; 517
518 // diaeresis
519 } else if (qkeycode == 0x2001) {
520 need_repaint = TRUE;
521
522 if (diaeresis) {
413 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)) {
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
423 unicode = keys->shift(unicode); 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);
@@ -501,21 +655,28 @@ void Keyboard::mouseReleaseEvent(QMouseEvent*)
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
@@ -558,18 +719,24 @@ void Keyboard::clearHighlight()
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)
@@ -601,55 +768,80 @@ void Keyboard::togglePickboard(bool on_off)
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
@@ -1121,12 +1313,37 @@ void Keys::setKeysFromFile(const char * filename) {
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
@@ -1202,12 +1419,24 @@ Keys::~Keys() {
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
@@ -1235,30 +1464,32 @@ void 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];
1242 1471 else return 0;
1243 return shiftMap[uni];
1244 }
1245 else
1246 return 0;
1247
1248} 1472}
1249 1473
1250ushort Keys::meta(const ushort uni) { 1474ushort Keys::meta(const ushort uni) {
1251 1475
1252 if (metaMap[uni]) { 1476 if (metaMap[uni]) return metaMap[uni];
1477 else return 0;
1478}
1479
1480ushort Keys::circumflex(const ushort uni) {
1253 1481
1254 return metaMap[uni]; 1482 if (circumflexMap[uni]) return circumflexMap[uni];
1483 else return 0;
1255 } 1484 }
1256 else
1257 return 0;
1258 1485
1486ushort Keys::diaeresis(const ushort uni) {
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}