Diffstat (limited to 'libopie2/opieui/okeyconfigwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opieui/okeyconfigwidget.cpp | 73 |
1 files changed, 54 insertions, 19 deletions
diff --git a/libopie2/opieui/okeyconfigwidget.cpp b/libopie2/opieui/okeyconfigwidget.cpp index 3e08416..8967d77 100644 --- a/libopie2/opieui/okeyconfigwidget.cpp +++ b/libopie2/opieui/okeyconfigwidget.cpp | |||
@@ -1,24 +1,26 @@ | |||
1 | #include "okeyconfigwidget.h" | 1 | #include "okeyconfigwidget.h" |
2 | #include "okeyconfigwidget_p.h" | 2 | #include "okeyconfigwidget_p.h" |
3 | 3 | ||
4 | 4 | ||
5 | #include <qgroupbox.h> | 5 | #include <qgroupbox.h> |
6 | #include <qradiobutton.h> | 6 | #include <qradiobutton.h> |
7 | #include <qpushbutton.h> | 7 | #include <qpushbutton.h> |
8 | #include <qbuttongroup.h> | 8 | #include <qbuttongroup.h> |
9 | 9 | #include <qmessagebox.h> | |
10 | #include <qaccel.h> | 10 | #include <qaccel.h> |
11 | #include <qlayout.h> | 11 | #include <qlayout.h> |
12 | #include <qlabel.h> | 12 | #include <qlabel.h> |
13 | |||
14 | /* non gui */ | ||
13 | #include <qtimer.h> | 15 | #include <qtimer.h> |
14 | 16 | ||
15 | 17 | ||
16 | using namespace Opie::Ui; | 18 | using namespace Opie::Ui; |
17 | 19 | ||
18 | 20 | ||
19 | 21 | ||
20 | /** | 22 | /** |
21 | * The default Constructor of a OKeyPair. | 23 | * The default Constructor of a OKeyPair. |
22 | * A Key and a Modifier ( Alt/Shift/Ctrl ) | 24 | * A Key and a Modifier ( Alt/Shift/Ctrl ) |
23 | * needs to be supplied. | 25 | * needs to be supplied. |
24 | * Use Qt::Key for the information. | 26 | * Use Qt::Key for the information. |
@@ -150,35 +152,35 @@ OKeyPair::List OKeyPair::hardwareKeys() { | |||
150 | for ( QValueList<Opie::Core::ODeviceButton>::ConstIterator it = but.begin(); | 152 | for ( QValueList<Opie::Core::ODeviceButton>::ConstIterator it = but.begin(); |
151 | it != but.end(); ++it ) | 153 | it != but.end(); ++it ) |
152 | lst.append( OKeyPair( (*it).keycode(), 0 ) ); | 154 | lst.append( OKeyPair( (*it).keycode(), 0 ) ); |
153 | 155 | ||
154 | 156 | ||
155 | return lst; | 157 | return lst; |
156 | } | 158 | } |
157 | 159 | ||
158 | /** | 160 | /** |
159 | * Equals operator. Check if two OKeyPairs have the same key and modifier | 161 | * Equals operator. Check if two OKeyPairs have the same key and modifier |
160 | * @see operator!= | 162 | * @see operator!= |
161 | */ | 163 | */ |
162 | bool OKeyPair::operator==( const OKeyPair& pair) { | 164 | bool OKeyPair::operator==( const OKeyPair& pair)const { |
163 | if ( m_key != pair.m_key ) return false; | 165 | if ( m_key != pair.m_key ) return false; |
164 | if ( m_mod != pair.m_mod ) return false; | 166 | if ( m_mod != pair.m_mod ) return false; |
165 | 167 | ||
166 | return true; | 168 | return true; |
167 | } | 169 | } |
168 | 170 | ||
169 | /** | 171 | /** |
170 | * Not equal operator. calls the equal operator internally | 172 | * Not equal operator. calls the equal operator internally |
171 | */ | 173 | */ |
172 | bool OKeyPair::operator!=( const OKeyPair& pair) { | 174 | bool OKeyPair::operator!=( const OKeyPair& pair)const { |
173 | return !(*this == pair); | 175 | return !(*this == pair); |
174 | } | 176 | } |
175 | 177 | ||
176 | 178 | ||
177 | /** | 179 | /** |
178 | * The normal Constructor to create a OKeyConfigItem | 180 | * The normal Constructor to create a OKeyConfigItem |
179 | * | 181 | * |
180 | * You can set the the key paramater of this item but if | 182 | * You can set the the key paramater of this item but if |
181 | * you use this item with the OKeyConfigManager your setting | 183 | * you use this item with the OKeyConfigManager your setting |
182 | * will be overwritten. | 184 | * will be overwritten. |
183 | * You can also specify a QObject and slot which sould get called | 185 | * You can also specify a QObject and slot which sould get called |
184 | * once this item is activated. This slot only works if you | 186 | * once this item is activated. This slot only works if you |
@@ -362,43 +364,43 @@ void OKeyConfigItem::setId( int id ) { | |||
362 | bool OKeyConfigItem::isEmpty()const { | 364 | bool OKeyConfigItem::isEmpty()const { |
363 | if ( !m_def.isEmpty() ) return false; | 365 | if ( !m_def.isEmpty() ) return false; |
364 | if ( !m_key.isEmpty() ) return false; | 366 | if ( !m_key.isEmpty() ) return false; |
365 | if ( !m_text.isEmpty() ) return false; | 367 | if ( !m_text.isEmpty() ) return false; |
366 | if ( m_id != -1 ) return false; | 368 | if ( m_id != -1 ) return false; |
367 | 369 | ||
368 | return true; | 370 | return true; |
369 | } | 371 | } |
370 | 372 | ||
371 | /** | 373 | /** |
372 | * Check if the KeyPairs are the same | 374 | * Check if the KeyPairs are the same |
373 | */ | 375 | */ |
374 | bool OKeyConfigItem::operator==( const OKeyConfigItem& conf ) { | 376 | bool OKeyConfigItem::operator==( const OKeyConfigItem& conf )const { |
375 | /* if ( isEmpty() == conf.isEmpty() ) return true; | 377 | /* if ( isEmpty() == conf.isEmpty() ) return true; |
376 | else if ( isEmpty() != conf.isEmpty() ) return false; | 378 | else if ( isEmpty() != conf.isEmpty() ) return false; |
377 | else if ( !isEmpty()!= conf.isEmpty() ) return false; | 379 | else if ( !isEmpty()!= conf.isEmpty() ) return false; |
378 | */ | 380 | */ |
379 | 381 | ||
380 | if ( m_id != conf.m_id ) return false; | 382 | if ( m_id != conf.m_id ) return false; |
381 | if ( m_obj != conf.m_obj ) return false; | 383 | if ( m_obj != conf.m_obj ) return false; |
382 | if ( m_text != conf.m_text ) return false; | 384 | if ( m_text != conf.m_text ) return false; |
383 | if ( m_key != conf.m_key ) return false; | 385 | if ( m_key != conf.m_key ) return false; |
384 | if ( m_def != conf.m_def ) return false; | 386 | if ( m_def != conf.m_def ) return false; |
385 | 387 | ||
386 | 388 | ||
387 | 389 | ||
388 | return true; | 390 | return true; |
389 | 391 | ||
390 | } | 392 | } |
391 | 393 | ||
392 | bool OKeyConfigItem::operator!=( const OKeyConfigItem& conf ) { | 394 | bool OKeyConfigItem::operator!=( const OKeyConfigItem& conf )const { |
393 | return !( *this == conf ); | 395 | return !( *this == conf ); |
394 | } | 396 | } |
395 | 397 | ||
396 | /** | 398 | /** |
397 | * \brief c'tor | 399 | * \brief c'tor |
398 | * The Constructor for a OKeyConfigManager | 400 | * The Constructor for a OKeyConfigManager |
399 | * | 401 | * |
400 | * You can use this manager in multiple ways. Either make it handle | 402 | * You can use this manager in multiple ways. Either make it handle |
401 | * QKeyEvents | 403 | * QKeyEvents |
402 | * | 404 | * |
403 | * \code | 405 | * \code |
404 | * Opie::Core::Config conf = oApp->config(); | 406 | * Opie::Core::Config conf = oApp->config(); |
@@ -474,56 +476,56 @@ OKeyConfigManager::~OKeyConfigManager() { | |||
474 | * make it be the empty key paur | 476 | * make it be the empty key paur |
475 | * We will change the group of the OConfig Item! | 477 | * We will change the group of the OConfig Item! |
476 | * | 478 | * |
477 | * @see OKeyPair::emptyKey | 479 | * @see OKeyPair::emptyKey |
478 | */ | 480 | */ |
479 | void OKeyConfigManager::load() { | 481 | void OKeyConfigManager::load() { |
480 | m_conf->setGroup( m_group ); | 482 | m_conf->setGroup( m_group ); |
481 | 483 | ||
482 | /* | 484 | /* |
483 | * Read each item | 485 | * Read each item |
484 | */ | 486 | */ |
485 | int key, mod; | 487 | int key, mod; |
486 | for( OKeyConfigItem::List::Iterator it = m_keys.begin(); | 488 | for( OKeyConfigItem::List::Iterator it = m_keys.begin(); it != m_keys.end(); ++it ) { |
487 | it != m_keys.end(); ++it ) { | ||
488 | key = m_conf->readNumEntry( (*it).configKey()+"key", (*it).defaultKeyPair().keycode() ); | 489 | key = m_conf->readNumEntry( (*it).configKey()+"key", (*it).defaultKeyPair().keycode() ); |
489 | mod = m_conf->readNumEntry( (*it).configKey()+"mod", (*it).defaultKeyPair().modifier() ); | 490 | mod = m_conf->readNumEntry( (*it).configKey()+"mod", (*it).defaultKeyPair().modifier() ); |
490 | OKeyPair okey( key, mod ); | 491 | OKeyPair okey( key, mod ); |
492 | |||
491 | if ( !m_blackKeys.contains( okey ) && key != -1 && mod != -1 ) | 493 | if ( !m_blackKeys.contains( okey ) && key != -1 && mod != -1 ) |
492 | (*it).setKeyPair( OKeyPair(key, mod) ); | 494 | (*it).setKeyPair( OKeyPair(key, mod) ); |
493 | else | 495 | else |
494 | (*it).setKeyPair( OKeyPair::emptyKey() ); | 496 | (*it).setKeyPair( OKeyPair::emptyKey() ); |
495 | } | 497 | } |
496 | delete m_map; m_map = 0; | 498 | delete m_map; m_map = 0; |
497 | } | 499 | } |
498 | 500 | ||
499 | /** | 501 | /** |
500 | * We will save the current configuration | 502 | * We will save the current configuration |
501 | * to the OConfig. We will change the group. | 503 | * to the OConfig. We will change the group. |
502 | */ | 504 | */ |
503 | void OKeyConfigManager::save() { | 505 | void OKeyConfigManager::save() { |
504 | m_conf->setGroup( m_group ); | 506 | m_conf->setGroup( m_group ); |
505 | 507 | ||
506 | /* | 508 | /* |
507 | * Write each item | 509 | * Write each item |
508 | */ | 510 | */ |
509 | for( OKeyConfigItem::List::Iterator it = m_keys.begin(); | 511 | for( OKeyConfigItem::List::Iterator it = m_keys.begin();it != m_keys.end(); ++it ) { |
510 | it != m_keys.end(); ++it ) { | 512 | /* skip empty items */ |
511 | if ( (*it).isEmpty() ) | 513 | if ( (*it).isEmpty() ) |
512 | continue; | 514 | continue; |
513 | OKeyPair pair = (*it).keyPair(); | 515 | OKeyPair pair = (*it).keyPair(); |
514 | OKeyPair deft = (*it).defaultKeyPair(); | 516 | OKeyPair deft = (*it).defaultKeyPair(); |
515 | /* | 517 | /* |
516 | * don't write if it is the default setting | 518 | * don't write if it is the default setting |
517 | * FIXME allow to remove Keys | 519 | * FIXME allow to remove Keys from config |
518 | if ( (pair.keycode() == deft.keycode()) && | 520 | if ( (pair.keycode() == deft.keycode()) && |
519 | (pair.modifier()== deft.modifier() ) ) | 521 | (pair.modifier()== deft.modifier() ) ) |
520 | return; | 522 | return; |
521 | */ | 523 | */ |
522 | 524 | ||
523 | m_conf->writeEntry((*it).configKey()+"key", pair.keycode() ); | 525 | m_conf->writeEntry((*it).configKey()+"key", pair.keycode() ); |
524 | m_conf->writeEntry((*it).configKey()+"mod", pair.modifier() ); | 526 | m_conf->writeEntry((*it).configKey()+"mod", pair.modifier() ); |
525 | } | 527 | } |
526 | } | 528 | } |
527 | 529 | ||
528 | /** | 530 | /** |
529 | * This is function uses a QMap internally but you can have the same keycode | 531 | * This is function uses a QMap internally but you can have the same keycode |
@@ -567,35 +569,33 @@ OKeyConfigItem OKeyConfigManager::handleKeyEvent( QKeyEvent* e ) { | |||
567 | * | 569 | * |
568 | * @see handleKeyEvent | 570 | * @see handleKeyEvent |
569 | */ | 571 | */ |
570 | int OKeyConfigManager::handleKeyEventId( QKeyEvent* ev) { | 572 | int OKeyConfigManager::handleKeyEventId( QKeyEvent* ev) { |
571 | return handleKeyEvent( ev ).id(); | 573 | return handleKeyEvent( ev ).id(); |
572 | } | 574 | } |
573 | 575 | ||
574 | /** | 576 | /** |
575 | * Add Key Config to the List of items | 577 | * Add Key Config to the List of items |
576 | */ | 578 | */ |
577 | void OKeyConfigManager::addKeyConfig( const OKeyConfigItem& item ) { | 579 | void OKeyConfigManager::addKeyConfig( const OKeyConfigItem& item ) { |
578 | m_keys.append( item ); | 580 | m_keys.append( item ); |
579 | qWarning( "m_keys count is now %d", m_keys.count() ); | ||
580 | delete m_map; m_map = 0; | 581 | delete m_map; m_map = 0; |
581 | } | 582 | } |
582 | 583 | ||
583 | /** | 584 | /** |
584 | * Remove the Key from the Config. Internal lists will be destroyed | 585 | * Remove the Key from the Config. Internal lists will be destroyed |
585 | * and rebuild on demand later | 586 | * and rebuild on demand later |
586 | */ | 587 | */ |
587 | void OKeyConfigManager::removeKeyConfig( const OKeyConfigItem& item ) { | 588 | void OKeyConfigManager::removeKeyConfig( const OKeyConfigItem& item ) { |
588 | m_keys.remove( item ); | 589 | m_keys.remove( item ); |
589 | qWarning( "m_keys count is now %d", m_keys.count() ); | ||
590 | delete m_map; m_map = 0; | 590 | delete m_map; m_map = 0; |
591 | } | 591 | } |
592 | 592 | ||
593 | /** | 593 | /** |
594 | * Clears the complete list | 594 | * Clears the complete list |
595 | */ | 595 | */ |
596 | void OKeyConfigManager::clearKeyConfig() { | 596 | void OKeyConfigManager::clearKeyConfig() { |
597 | m_keys.clear(); | 597 | m_keys.clear(); |
598 | delete m_map; m_map = 0; | 598 | delete m_map; m_map = 0; |
599 | } | 599 | } |
600 | 600 | ||
601 | /** | 601 | /** |
@@ -751,24 +751,27 @@ namespace Private { | |||
751 | QString keyToString( const OKeyPair& pair ) { | 751 | QString keyToString( const OKeyPair& pair ) { |
752 | int mod = 0; | 752 | int mod = 0; |
753 | if ( pair.modifier() & Qt::ShiftButton ) | 753 | if ( pair.modifier() & Qt::ShiftButton ) |
754 | mod |= Qt::SHIFT; | 754 | mod |= Qt::SHIFT; |
755 | if ( pair.modifier() & Qt::ControlButton ) | 755 | if ( pair.modifier() & Qt::ControlButton ) |
756 | mod |= Qt::CTRL; | 756 | mod |= Qt::CTRL; |
757 | if ( pair.modifier() & Qt::AltButton ) | 757 | if ( pair.modifier() & Qt::AltButton ) |
758 | mod |= Qt::ALT; | 758 | mod |= Qt::ALT; |
759 | 759 | ||
760 | return QAccel::keyToString( mod + pair.keycode() ); | 760 | return QAccel::keyToString( mod + pair.keycode() ); |
761 | } | 761 | } |
762 | 762 | ||
763 | /* | ||
764 | * the virtual and hardware key events have both issues... | ||
765 | */ | ||
763 | void fixupKeys( int& key, int &mod, QKeyEvent* e ) { | 766 | void fixupKeys( int& key, int &mod, QKeyEvent* e ) { |
764 | key = e->key(); | 767 | key = e->key(); |
765 | mod = e->state(); | 768 | mod = e->state(); |
766 | /* | 769 | /* |
767 | * virtual keyboard | 770 | * virtual keyboard |
768 | * else change the button mod only | 771 | * else change the button mod only |
769 | */ | 772 | */ |
770 | if ( key == 0 ) { | 773 | if ( key == 0 ) { |
771 | key = e->ascii(); | 774 | key = e->ascii(); |
772 | if ( key > 96 && key < 123) | 775 | if ( key > 96 && key < 123) |
773 | key -= 32; | 776 | key -= 32; |
774 | }else{ | 777 | }else{ |
@@ -999,25 +1002,24 @@ void OKeyConfigWidget::slotListViewItem( QListViewItem* _item) { | |||
999 | m_def ->setChecked( false ); | 1002 | m_def ->setChecked( false ); |
1000 | m_cus ->setChecked( false ); | 1003 | m_cus ->setChecked( false ); |
1001 | }else { | 1004 | }else { |
1002 | m_none->setChecked( false ); | 1005 | m_none->setChecked( false ); |
1003 | m_cus ->setChecked( true ); | 1006 | m_cus ->setChecked( true ); |
1004 | m_btn ->setEnabled( true ); | 1007 | m_btn ->setEnabled( true ); |
1005 | m_def ->setChecked( false ); | 1008 | m_def ->setChecked( false ); |
1006 | } | 1009 | } |
1007 | } | 1010 | } |
1008 | } | 1011 | } |
1009 | 1012 | ||
1010 | void OKeyConfigWidget::slotNoKey() { | 1013 | void OKeyConfigWidget::slotNoKey() { |
1011 | qWarning( "No Key" ); | ||
1012 | m_none->setChecked( true ); | 1014 | m_none->setChecked( true ); |
1013 | m_cus ->setChecked( false ); | 1015 | m_cus ->setChecked( false ); |
1014 | m_btn ->setEnabled( false ); | 1016 | m_btn ->setEnabled( false ); |
1015 | m_def ->setChecked( false ); | 1017 | m_def ->setChecked( false ); |
1016 | 1018 | ||
1017 | if ( !m_view->currentItem() || !m_view->currentItem()->parent() ) | 1019 | if ( !m_view->currentItem() || !m_view->currentItem()->parent() ) |
1018 | return; | 1020 | return; |
1019 | 1021 | ||
1020 | 1022 | ||
1021 | 1023 | ||
1022 | /* | 1024 | /* |
1023 | * If immediate we need to remove and readd the key | 1025 | * If immediate we need to remove and readd the key |
@@ -1059,33 +1061,67 @@ void OKeyConfigWidget::slotConfigure() { | |||
1059 | OKeyChooserConfigDialog dlg( this, "Dialog Name", true ); | 1061 | OKeyChooserConfigDialog dlg( this, "Dialog Name", true ); |
1060 | dlg.setCaption(tr("Configure Key")); | 1062 | dlg.setCaption(tr("Configure Key")); |
1061 | connect(&dlg, SIGNAL(keyCaptured()), &dlg, SLOT(accept()) ); | 1063 | connect(&dlg, SIGNAL(keyCaptured()), &dlg, SLOT(accept()) ); |
1062 | 1064 | ||
1063 | if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) { | 1065 | if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) { |
1064 | Opie::Ui::Private::OKeyListViewItem *item = static_cast<Opie::Ui::Private::OKeyListViewItem*>(m_view->currentItem()); | 1066 | Opie::Ui::Private::OKeyListViewItem *item = static_cast<Opie::Ui::Private::OKeyListViewItem*>(m_view->currentItem()); |
1065 | updateItem( item, dlg.keyPair() ); | 1067 | updateItem( item, dlg.keyPair() ); |
1066 | } | 1068 | } |
1067 | 1069 | ||
1068 | 1070 | ||
1069 | } | 1071 | } |
1070 | 1072 | ||
1073 | bool OKeyConfigWidget::sanityCheck( Opie::Ui::Private::OKeyListViewItem* item, | ||
1074 | const OKeyPair& newItem ) { | ||
1075 | OKeyPair::List bList = item->manager()->blackList(); | ||
1076 | for ( OKeyPair::List::Iterator it = bList.begin(); it != bList.end(); ++it ) { | ||
1077 | /* black list matched */ | ||
1078 | if ( *it == newItem ) { | ||
1079 | QMessageBox::warning( 0, tr("Key is on BlackList" ), | ||
1080 | tr("<qt>The Key you choose is on the black list " | ||
1081 | "and may not be used with this manager. Please " | ||
1082 | "use a different key.</qt>" ) ); | ||
1083 | return false; | ||
1084 | } | ||
1085 | } | ||
1086 | /* no we need to check the other items which is dog slow */ | ||
1087 | QListViewItemIterator it( item->parent() ); | ||
1088 | while ( it.current() ) { | ||
1089 | /* if not our parent and not us */ | ||
1090 | if (it.current()->parent() && it.current() != item) { | ||
1091 | /* damn already given away*/ | ||
1092 | if ( newItem == static_cast<Opie::Ui::Private::OKeyListViewItem*>(it.current() )->item().keyPair() ) { | ||
1093 | QMessageBox::warning( 0, tr("Key is already assigned" ), | ||
1094 | tr("<qt>The Key you choose is already taken by " | ||
1095 | "a different Item of your config. Please try" | ||
1096 | "using a different key.</qt>" ) ); | ||
1097 | return false; | ||
1098 | } | ||
1099 | } | ||
1100 | ++it; | ||
1101 | } | ||
1102 | |||
1103 | return true; | ||
1104 | } | ||
1105 | |||
1071 | void OKeyConfigWidget::updateItem( Opie::Ui::Private::OKeyListViewItem *item, | 1106 | void OKeyConfigWidget::updateItem( Opie::Ui::Private::OKeyListViewItem *item, |
1072 | const OKeyPair& newItem) { | 1107 | const OKeyPair& newItem) { |
1073 | /* sanity check | 1108 | /* sanity check |
1074 | * check against the blacklist of the manager | 1109 | * check against the blacklist of the manager |
1075 | * check if another item uses this key which is o(n) at least | 1110 | * check if another item uses this key which is o(n) at least |
1076 | */ | 1111 | */ |
1077 | if ( !newItem.isEmpty() ) { | 1112 | if ( !newItem.isEmpty() && !sanityCheck(item, newItem )) |
1113 | return; | ||
1114 | |||
1078 | 1115 | ||
1079 | } | ||
1080 | 1116 | ||
1081 | /* | 1117 | /* |
1082 | * If immediate we need to remove and readd the key | 1118 | * If immediate we need to remove and readd the key |
1083 | */ | 1119 | */ |
1084 | if ( m_mode == Imediate ) | 1120 | if ( m_mode == Imediate ) |
1085 | item->manager()->removeKeyConfig( item->item() ); | 1121 | item->manager()->removeKeyConfig( item->item() ); |
1086 | 1122 | ||
1087 | item->item().setKeyPair( newItem ); | 1123 | item->item().setKeyPair( newItem ); |
1088 | item->updateText(); | 1124 | item->updateText(); |
1089 | 1125 | ||
1090 | if ( m_mode == Imediate ) | 1126 | if ( m_mode == Imediate ) |
1091 | item->manager()->addKeyConfig( item->item() ); | 1127 | item->manager()->addKeyConfig( item->item() ); |
@@ -1119,56 +1155,55 @@ OKeyChooserConfigDialog::~OKeyChooserConfigDialog() { | |||
1119 | } | 1155 | } |
1120 | 1156 | ||
1121 | Opie::Ui::OKeyPair OKeyChooserConfigDialog::keyPair()const{ | 1157 | Opie::Ui::OKeyPair OKeyChooserConfigDialog::keyPair()const{ |
1122 | return m_keyPair; | 1158 | return m_keyPair; |
1123 | } | 1159 | } |
1124 | 1160 | ||
1125 | void OKeyChooserConfigDialog::keyPressEvent( QKeyEvent* ev ) { | 1161 | void OKeyChooserConfigDialog::keyPressEvent( QKeyEvent* ev ) { |
1126 | QDialog::keyPressEvent( ev ); | 1162 | QDialog::keyPressEvent( ev ); |
1127 | 1163 | ||
1128 | if ( ev->isAutoRepeat() ) | 1164 | if ( ev->isAutoRepeat() ) |
1129 | return; | 1165 | return; |
1130 | 1166 | ||
1131 | qWarning( "Key Press Event" ); | ||
1132 | int mod, key; | 1167 | int mod, key; |
1133 | Opie::Ui::Private::fixupKeys( key,mod, ev ); | 1168 | Opie::Ui::Private::fixupKeys( key,mod, ev ); |
1134 | 1169 | ||
1135 | /* either we used software keyboard | 1170 | /* either we used software keyboard |
1136 | * or we've true support | 1171 | * or we've true support |
1137 | */ | 1172 | */ |
1138 | if ( !m_virtKey && !ev->key()) { | 1173 | if ( !m_virtKey && !ev->key()) { |
1139 | m_virtKey = true; | 1174 | m_virtKey = true; |
1140 | m_keyPair = OKeyPair( key, mod ); | 1175 | m_keyPair = OKeyPair( key, mod ); |
1141 | }else{ | 1176 | }else{ |
1142 | mod = 0; | 1177 | mod = 0; |
1143 | switch( key ) { | 1178 | switch( key ) { |
1144 | case Qt::Key_Control: | 1179 | case Qt::Key_Control: |
1145 | mod = Qt::ControlButton; | 1180 | mod = Qt::ControlButton; |
1146 | break; | 1181 | break; |
1147 | case Qt::Key_Shift: | 1182 | case Qt::Key_Shift: |
1148 | mod = Qt::ShiftButton; | 1183 | mod = Qt::ShiftButton; |
1149 | break; | 1184 | break; |
1150 | case Qt::Key_Alt: | 1185 | case Qt::Key_Alt: |
1151 | mod = Qt::AltButton; | 1186 | mod = Qt::AltButton; |
1152 | break; | 1187 | break; |
1153 | default: | 1188 | default: |
1154 | break; | 1189 | break; |
1155 | } | 1190 | } |
1156 | if (mod ) { | 1191 | if (mod ) |
1157 | m_mod |= mod; | 1192 | m_mod |= mod; |
1158 | }else | 1193 | else |
1159 | m_key = key; | 1194 | m_key = key; |
1160 | 1195 | ||
1161 | if ( ( !mod || m_key ) && !m_timer->isActive() ) | 1196 | if ( ( !mod || m_key ) && !m_timer->isActive() ) |
1162 | m_timer->start( 50, true ); | 1197 | m_timer->start( 150, true ); |
1163 | 1198 | ||
1164 | m_keyPair = OKeyPair( m_key, m_mod ); | 1199 | m_keyPair = OKeyPair( m_key, m_mod ); |
1165 | } | 1200 | } |
1166 | 1201 | ||
1167 | m_lbl->setText( Opie::Ui::Private::keyToString( m_keyPair ) ); | 1202 | m_lbl->setText( Opie::Ui::Private::keyToString( m_keyPair ) ); |
1168 | 1203 | ||
1169 | } | 1204 | } |
1170 | 1205 | ||
1171 | void OKeyChooserConfigDialog::keyReleaseEvent( QKeyEvent* ev ) { | 1206 | void OKeyChooserConfigDialog::keyReleaseEvent( QKeyEvent* ev ) { |
1172 | m_timer->stop(); | 1207 | m_timer->stop(); |
1173 | QDialog::keyPressEvent( ev ); | 1208 | QDialog::keyPressEvent( ev ); |
1174 | 1209 | ||