author | zecke <zecke> | 2004-03-27 20:18:11 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-03-27 20:18:11 (UTC) |
commit | 0821e9018b0a3b1ea11ff5a4454db2e047d94d88 (patch) (unidiff) | |
tree | 5a712141869f84167a29b92b97489001ce205148 /libopie2 | |
parent | 9202a4007eb3866acf07264d234da59b310f0a8c (diff) | |
download | opie-0821e9018b0a3b1ea11ff5a4454db2e047d94d88.zip opie-0821e9018b0a3b1ea11ff5a4454db2e047d94d88.tar.gz opie-0821e9018b0a3b1ea11ff5a4454db2e047d94d88.tar.bz2 |
Fix key events.
On true hardware events Shift/Ctrl/Alt are not equal with the ButtonState
On virtual keyboard events no key() is sent...
-rw-r--r-- | libopie2/opieui/okeyconfigwidget.cpp | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/libopie2/opieui/okeyconfigwidget.cpp b/libopie2/opieui/okeyconfigwidget.cpp index b4f1c5e..2ea0bd5 100644 --- a/libopie2/opieui/okeyconfigwidget.cpp +++ b/libopie2/opieui/okeyconfigwidget.cpp | |||
@@ -495,46 +495,83 @@ void OKeyConfigManager::load() { | |||
495 | */ | 495 | */ |
496 | void OKeyConfigManager::save() { | 496 | void OKeyConfigManager::save() { |
497 | m_conf->setGroup( m_group ); | 497 | m_conf->setGroup( m_group ); |
498 | 498 | ||
499 | /* | 499 | /* |
500 | * Write each item | 500 | * Write each item |
501 | */ | 501 | */ |
502 | for( OKeyConfigItem::List::Iterator it = m_keys.begin(); | 502 | for( OKeyConfigItem::List::Iterator it = m_keys.begin(); |
503 | it != m_keys.end(); ++it ) { | 503 | it != m_keys.end(); ++it ) { |
504 | if ( (*it).isEmpty() ) | 504 | if ( (*it).isEmpty() ) |
505 | continue; | 505 | continue; |
506 | OKeyPair pair = (*it).keyPair(); | 506 | OKeyPair pair = (*it).keyPair(); |
507 | OKeyPair deft = (*it).defaultKeyPair(); | ||
508 | /* don't write if it is the default setting */ | ||
509 | if ( (pair.keycode() == deft.keycode()) && | ||
510 | (pair.modifier()== deft.modifier() ) ) | ||
511 | return; | ||
512 | |||
507 | m_conf->writeEntry((*it).configKey()+"key", pair.keycode() ); | 513 | m_conf->writeEntry((*it).configKey()+"key", pair.keycode() ); |
508 | m_conf->writeEntry((*it).configKey()+"mod", pair.modifier() ); | 514 | m_conf->writeEntry((*it).configKey()+"mod", pair.modifier() ); |
509 | } | 515 | } |
510 | } | 516 | } |
511 | 517 | ||
512 | /** | 518 | /** |
513 | * This is function uses a QMap internally but you can have the same keycode | 519 | * This is function uses a QMap internally but you can have the same keycode |
514 | * with different modifier key. The behaviour is undefined if you add a OKeyConfigItem | 520 | * with different modifier key. The behaviour is undefined if you add a OKeyConfigItem |
515 | * with same keycode and modifier key. The GUI takes care that a user can't | 521 | * with same keycode and modifier key. The GUI takes care that a user can't |
516 | * cofigure two keys. | 522 | * cofigure two keys. |
517 | * | 523 | * |
518 | * Make sure you call e->ignore if you don't want to handle this event | 524 | * Make sure you call e->ignore if you don't want to handle this event |
519 | */ | 525 | */ |
520 | OKeyConfigItem OKeyConfigManager::handleKeyEvent( QKeyEvent* e ) { | 526 | OKeyConfigItem OKeyConfigManager::handleKeyEvent( QKeyEvent* e ) { |
521 | OKeyConfigItem::List _keyList = keyList( e->key() ); | 527 | /* |
528 | * Fix Up issues with Qt/E, my keybard, and virtual input | ||
529 | * methods | ||
530 | * First my Keyboard delivers 256,512,1024 for shift/ctrl/alt instead of the button state | ||
531 | * Also key() on virtual inputmethods are zero and only ascii. We need to fix upper and lower | ||
532 | * case ascii | ||
533 | */ | ||
534 | int key = e->key(); | ||
535 | int mod = e->state(); | ||
536 | |||
537 | /* | ||
538 | * virtual keyboard | ||
539 | * else change the button mod only | ||
540 | */ | ||
541 | qWarning( "handleKeyEvent...." ); | ||
542 | if ( key == 0 ) { | ||
543 | key = e->ascii(); | ||
544 | if ( key > 96 && key < 123) | ||
545 | key -= 32; | ||
546 | }else{ | ||
547 | int new_mod = 0; | ||
548 | if ( mod & 256 ) | ||
549 | new_mod |= Qt::ShiftButton; | ||
550 | else if ( mod & 512 ) | ||
551 | new_mod |= Qt::AltButton; | ||
552 | else if ( mod & 1024 ) | ||
553 | new_mod |= Qt::ControlButton; | ||
554 | |||
555 | mod = new_mod == 0? mod : new_mod; | ||
556 | } | ||
557 | |||
558 | OKeyConfigItem::List _keyList = keyList( key ); | ||
522 | if ( _keyList.isEmpty() ) | 559 | if ( _keyList.isEmpty() ) |
523 | return OKeyConfigItem(); | 560 | return OKeyConfigItem(); |
524 | 561 | ||
525 | OKeyConfigItem item; | 562 | OKeyConfigItem item; |
526 | for ( OKeyConfigItem::List::Iterator it = _keyList.begin(); it != _keyList.end(); | 563 | for ( OKeyConfigItem::List::Iterator it = _keyList.begin(); it != _keyList.end(); |
527 | ++it ) { | 564 | ++it ) { |
528 | if ( (*it).keyPair().modifier() == e->state() ) { | 565 | if ( (*it).keyPair().modifier() == mod ) { |
529 | item = *it; | 566 | item = *it; |
530 | break; | 567 | break; |
531 | } | 568 | } |
532 | 569 | ||
533 | } | 570 | } |
534 | 571 | ||
535 | return item; | 572 | return item; |
536 | } | 573 | } |
537 | 574 | ||
538 | /** | 575 | /** |
539 | * Return the associated id of the item or -1 if no item | 576 | * Return the associated id of the item or -1 if no item |
540 | * matched the key | 577 | * matched the key |