-rw-r--r-- | libopie2/opieui/okeyconfigwidget.cpp | 20 | ||||
-rw-r--r-- | libopie2/opieui/okeyconfigwidget.h | 2 |
2 files changed, 19 insertions, 3 deletions
diff --git a/libopie2/opieui/okeyconfigwidget.cpp b/libopie2/opieui/okeyconfigwidget.cpp index 2ea0bd5..273f15b 100644 --- a/libopie2/opieui/okeyconfigwidget.cpp +++ b/libopie2/opieui/okeyconfigwidget.cpp | |||
@@ -533,17 +533,16 @@ OKeyConfigItem OKeyConfigManager::handleKeyEvent( QKeyEvent* e ) { | |||
533 | */ | 533 | */ |
534 | int key = e->key(); | 534 | int key = e->key(); |
535 | int mod = e->state(); | 535 | int mod = e->state(); |
536 | 536 | ||
537 | /* | 537 | /* |
538 | * virtual keyboard | 538 | * virtual keyboard |
539 | * else change the button mod only | 539 | * else change the button mod only |
540 | */ | 540 | */ |
541 | qWarning( "handleKeyEvent...." ); | ||
542 | if ( key == 0 ) { | 541 | if ( key == 0 ) { |
543 | key = e->ascii(); | 542 | key = e->ascii(); |
544 | if ( key > 96 && key < 123) | 543 | if ( key > 96 && key < 123) |
545 | key -= 32; | 544 | key -= 32; |
546 | }else{ | 545 | }else{ |
547 | int new_mod = 0; | 546 | int new_mod = 0; |
548 | if ( mod & 256 ) | 547 | if ( mod & 256 ) |
549 | new_mod |= Qt::ShiftButton; | 548 | new_mod |= Qt::ShiftButton; |
@@ -602,16 +601,22 @@ void OKeyConfigManager::removeKeyConfig( const OKeyConfigItem& item ) { | |||
602 | /** | 601 | /** |
603 | * Clears the complete list | 602 | * Clears the complete list |
604 | */ | 603 | */ |
605 | void OKeyConfigManager::clearKeyConfig() { | 604 | void OKeyConfigManager::clearKeyConfig() { |
606 | m_keys.clear(); | 605 | m_keys.clear(); |
607 | delete m_map; m_map = 0; | 606 | delete m_map; m_map = 0; |
608 | } | 607 | } |
609 | 608 | ||
609 | /** | ||
610 | * | ||
611 | */ | ||
612 | Opie::Ui::OKeyConfigItem::List OKeyConfigManager::keyConfigList()const{ | ||
613 | return m_keys; | ||
614 | } | ||
610 | 615 | ||
611 | /** | 616 | /** |
612 | * Add this OKeyPair to the blackList. | 617 | * Add this OKeyPair to the blackList. |
613 | * Internal lists will be destroyed | 618 | * Internal lists will be destroyed |
614 | */ | 619 | */ |
615 | void OKeyConfigManager::addToBlackList( const OKeyPair& key) { | 620 | void OKeyConfigManager::addToBlackList( const OKeyPair& key) { |
616 | m_blackKeys.append( key ); | 621 | m_blackKeys.append( key ); |
617 | delete m_map; m_map = 0; | 622 | delete m_map; m_map = 0; |
@@ -748,21 +753,21 @@ namespace Private { | |||
748 | OKeyListViewItem::~OKeyListViewItem() {} | 753 | OKeyListViewItem::~OKeyListViewItem() {} |
749 | OKeyConfigItem &OKeyListViewItem::item(){ | 754 | OKeyConfigItem &OKeyListViewItem::item(){ |
750 | return m_item; | 755 | return m_item; |
751 | } | 756 | } |
752 | OKeyConfigManager* OKeyListViewItem::manager() { | 757 | OKeyConfigManager* OKeyListViewItem::manager() { |
753 | return m_manager; | 758 | return m_manager; |
754 | } | 759 | } |
755 | void OKeyListViewItem::setItem( const OKeyConfigItem& item ) { | 760 | void OKeyListViewItem::setItem( const OKeyConfigItem& item ) { |
761 | m_item = item; | ||
756 | setPixmap( 0, m_item.pixmap() ); | 762 | setPixmap( 0, m_item.pixmap() ); |
757 | setText ( 1, m_item.text() ); | 763 | setText ( 1, m_item.text() ); |
758 | setText ( 2, keyToString( m_item.keyPair() ) ); | 764 | setText ( 2, keyToString( m_item.keyPair() ) ); |
759 | setText ( 3, keyToString( m_item.defaultKeyPair() ) ); | 765 | setText ( 3, keyToString( m_item.defaultKeyPair() ) ); |
760 | m_item = item; | ||
761 | } | 766 | } |
762 | 767 | ||
763 | QString keyToString( const OKeyPair& pair ) { | 768 | QString keyToString( const OKeyPair& pair ) { |
764 | int mod = 0; | 769 | int mod = 0; |
765 | if ( pair.modifier() & Qt::ShiftButton ) | 770 | if ( pair.modifier() & Qt::ShiftButton ) |
766 | mod |= Qt::SHIFT; | 771 | mod |= Qt::SHIFT; |
767 | if ( pair.modifier() & Qt::ControlButton ) | 772 | if ( pair.modifier() & Qt::ControlButton ) |
768 | mod |= Qt::CTRL; | 773 | mod |= Qt::CTRL; |
@@ -848,17 +853,16 @@ void OKeyConfigWidget::initUi() { | |||
848 | 853 | ||
849 | gridLay->addMultiCellWidget( m_view, 1, 1, 0, 1 ); | 854 | gridLay->addMultiCellWidget( m_view, 1, 1, 0, 1 ); |
850 | 855 | ||
851 | /* | 856 | /* |
852 | * GROUP with button info | 857 | * GROUP with button info |
853 | */ | 858 | */ |
854 | 859 | ||
855 | QGroupBox *box = new QGroupBox( this ); | 860 | QGroupBox *box = new QGroupBox( this ); |
856 | box ->setEnabled( false ); | ||
857 | box ->setTitle( tr("Shortcut for Selected Action") ); | 861 | box ->setTitle( tr("Shortcut for Selected Action") ); |
858 | box ->setFrameStyle( QFrame::Box | QFrame::Sunken ); | 862 | box ->setFrameStyle( QFrame::Box | QFrame::Sunken ); |
859 | layout->addWidget( box, 1 ); | 863 | layout->addWidget( box, 1 ); |
860 | 864 | ||
861 | gridLay = new QGridLayout( box, 3, 4 ); | 865 | gridLay = new QGridLayout( box, 3, 4 ); |
862 | gridLay->addRowSpacing( 0, fontMetrics().lineSpacing() ); | 866 | gridLay->addRowSpacing( 0, fontMetrics().lineSpacing() ); |
863 | gridLay->setMargin( 4 ); | 867 | gridLay->setMargin( 4 ); |
864 | 868 | ||
@@ -924,17 +928,24 @@ void OKeyConfigWidget::insert( const QString& str, OKeyConfigManager* man ) { | |||
924 | m_list.append(root); | 928 | m_list.append(root); |
925 | } | 929 | } |
926 | 930 | ||
927 | 931 | ||
928 | /** | 932 | /** |
929 | * loads the items and allows editing them | 933 | * loads the items and allows editing them |
930 | */ | 934 | */ |
931 | void OKeyConfigWidget::load() { | 935 | void OKeyConfigWidget::load() { |
936 | Opie::Ui::Private::OKeyConfigWidgetPrivateList::Iterator it; | ||
937 | for ( it = m_list.begin(); it != m_list.end(); ++it ) { | ||
938 | OListViewItem *item = new OListViewItem( m_view, (*it).name ); | ||
939 | OKeyConfigItem::List list = (*it).manager->keyConfigList(); | ||
940 | for (OKeyConfigItem::List::Iterator keyIt = list.begin(); keyIt != list.end();++keyIt ) | ||
941 | (void )new Opie::Ui::Private::OKeyListViewItem(*keyIt, (*it).manager, item ); | ||
932 | 942 | ||
943 | } | ||
933 | } | 944 | } |
934 | 945 | ||
935 | /** | 946 | /** |
936 | * Saves if in Queue Mode. It'll update the supplied | 947 | * Saves if in Queue Mode. It'll update the supplied |
937 | * OKeyConfigManager objects. | 948 | * OKeyConfigManager objects. |
938 | * If in Queue mode it'll just return | 949 | * If in Queue mode it'll just return |
939 | */ | 950 | */ |
940 | void OKeyConfigWidget::save() { | 951 | void OKeyConfigWidget::save() { |
@@ -966,16 +977,17 @@ void OKeyConfigWidget::slotListViewItem( QListViewItem* _item) { | |||
966 | m_cus ->setChecked( true ); | 977 | m_cus ->setChecked( true ); |
967 | m_btn ->setEnabled( true ); | 978 | m_btn ->setEnabled( true ); |
968 | m_def ->setChecked( false ); | 979 | m_def ->setChecked( false ); |
969 | } | 980 | } |
970 | } | 981 | } |
971 | } | 982 | } |
972 | 983 | ||
973 | void OKeyConfigWidget::slotNoKey() { | 984 | void OKeyConfigWidget::slotNoKey() { |
985 | qWarning( "No Key" ); | ||
974 | m_none->setChecked( true ); | 986 | m_none->setChecked( true ); |
975 | m_cus ->setChecked( false ); | 987 | m_cus ->setChecked( false ); |
976 | m_btn ->setEnabled( false ); | 988 | m_btn ->setEnabled( false ); |
977 | m_def ->setChecked( false ); | 989 | m_def ->setChecked( false ); |
978 | 990 | ||
979 | if ( !m_view->currentItem() || m_view->currentItem()->parent() ) | 991 | if ( !m_view->currentItem() || m_view->currentItem()->parent() ) |
980 | return; | 992 | return; |
981 | 993 | ||
@@ -990,16 +1002,17 @@ void OKeyConfigWidget::slotNoKey() { | |||
990 | item->item().setKeyPair( OKeyPair::emptyKey() ); | 1002 | item->item().setKeyPair( OKeyPair::emptyKey() ); |
991 | 1003 | ||
992 | if ( m_mode == Imediate ) | 1004 | if ( m_mode == Imediate ) |
993 | item->manager()->addKeyConfig( item->item() ); | 1005 | item->manager()->addKeyConfig( item->item() ); |
994 | 1006 | ||
995 | } | 1007 | } |
996 | 1008 | ||
997 | void OKeyConfigWidget::slotDefaultKey() { | 1009 | void OKeyConfigWidget::slotDefaultKey() { |
1010 | qWarning( "Slot Default Key" ); | ||
998 | m_none->setChecked( true ); | 1011 | m_none->setChecked( true ); |
999 | m_cus ->setChecked( false ); | 1012 | m_cus ->setChecked( false ); |
1000 | m_btn ->setEnabled( false ); | 1013 | m_btn ->setEnabled( false ); |
1001 | m_def ->setChecked( false ); | 1014 | m_def ->setChecked( false ); |
1002 | 1015 | ||
1003 | if ( !m_view->currentItem() || m_view->currentItem()->parent() ) | 1016 | if ( !m_view->currentItem() || m_view->currentItem()->parent() ) |
1004 | return; | 1017 | return; |
1005 | 1018 | ||
@@ -1013,16 +1026,17 @@ void OKeyConfigWidget::slotDefaultKey() { | |||
1013 | 1026 | ||
1014 | item->item().setKeyPair( item->item().defaultKeyPair() ); | 1027 | item->item().setKeyPair( item->item().defaultKeyPair() ); |
1015 | 1028 | ||
1016 | if ( m_mode == Imediate ) | 1029 | if ( m_mode == Imediate ) |
1017 | item->manager()->addKeyConfig( item->item() ); | 1030 | item->manager()->addKeyConfig( item->item() ); |
1018 | } | 1031 | } |
1019 | 1032 | ||
1020 | void OKeyConfigWidget::slotCustomKey() { | 1033 | void OKeyConfigWidget::slotCustomKey() { |
1034 | qWarning( "SlotCustom Key" ); | ||
1021 | m_cus ->setChecked( true ); | 1035 | m_cus ->setChecked( true ); |
1022 | m_btn ->setEnabled( true ); | 1036 | m_btn ->setEnabled( true ); |
1023 | m_def ->setChecked( false ); | 1037 | m_def ->setChecked( false ); |
1024 | m_none->setChecked( false ); | 1038 | m_none->setChecked( false ); |
1025 | 1039 | ||
1026 | if ( !m_view->currentItem() || m_view->currentItem()->parent() ) | 1040 | if ( !m_view->currentItem() || m_view->currentItem()->parent() ) |
1027 | return; | 1041 | return; |
1028 | 1042 | ||
diff --git a/libopie2/opieui/okeyconfigwidget.h b/libopie2/opieui/okeyconfigwidget.h index b3309af..a7a5f48 100644 --- a/libopie2/opieui/okeyconfigwidget.h +++ b/libopie2/opieui/okeyconfigwidget.h | |||
@@ -175,16 +175,18 @@ public: | |||
175 | void addToBlackList( const OKeyPair& ); | 175 | void addToBlackList( const OKeyPair& ); |
176 | void removeFromBlackList( const OKeyPair& ); | 176 | void removeFromBlackList( const OKeyPair& ); |
177 | void clearBlackList(); | 177 | void clearBlackList(); |
178 | OKeyPair::List blackList()const; | 178 | OKeyPair::List blackList()const; |
179 | 179 | ||
180 | void handleWidget( QWidget* ); | 180 | void handleWidget( QWidget* ); |
181 | 181 | ||
182 | bool eventFilter( QObject*, QEvent* ); | 182 | bool eventFilter( QObject*, QEvent* ); |
183 | |||
184 | OKeyConfigItem::List keyConfigList()const; | ||
183 | signals: | 185 | signals: |
184 | /** | 186 | /** |
185 | * The Signals are triggered on KeyPress and KeyRelease! | 187 | * The Signals are triggered on KeyPress and KeyRelease! |
186 | * You can check the isDown of the QKeyEvent | 188 | * You can check the isDown of the QKeyEvent |
187 | * @see QKeyEvent | 189 | * @see QKeyEvent |
188 | */ | 190 | */ |
189 | void actionActivated( QWidget*, QKeyEvent*, const Opie::Ui::OKeyConfigItem& ); | 191 | void actionActivated( QWidget*, QKeyEvent*, const Opie::Ui::OKeyConfigItem& ); |
190 | 192 | ||