-rw-r--r-- | libopie2/opieui/okeyconfigwidget.cpp | 93 | ||||
-rw-r--r-- | libopie2/opieui/okeyconfigwidget.h | 41 |
2 files changed, 119 insertions, 15 deletions
diff --git a/libopie2/opieui/okeyconfigwidget.cpp b/libopie2/opieui/okeyconfigwidget.cpp index 273f15b..41be1be 100644 --- a/libopie2/opieui/okeyconfigwidget.cpp +++ b/libopie2/opieui/okeyconfigwidget.cpp | |||
@@ -356,33 +356,38 @@ void OKeyConfigItem::setId( int id ) { | |||
356 | * If the item is not configured isEmpty() will return true | 356 | * If the item is not configured isEmpty() will return true |
357 | * It is empty if no text is present and no default | 357 | * It is empty if no text is present and no default |
358 | * and no configured key | 358 | * and no configured key |
359 | */ | 359 | */ |
360 | bool OKeyConfigItem::isEmpty()const { | 360 | bool OKeyConfigItem::isEmpty()const { |
361 | if ( !m_def.isEmpty() ) return false; | 361 | if ( !m_def.isEmpty() ) return false; |
362 | if ( !m_key.isEmpty() ) return false; | 362 | if ( !m_key.isEmpty() ) return false; |
363 | if ( !m_text.isEmpty() ) return false; | 363 | if ( !m_text.isEmpty() ) return false; |
364 | if ( m_id != -1 ) return false; | ||
364 | 365 | ||
365 | return true; | 366 | return true; |
366 | } | 367 | } |
367 | 368 | ||
368 | /** | 369 | /** |
369 | * Check if the KeyPairs are the same | 370 | * Check if the KeyPairs are the same |
370 | */ | 371 | */ |
371 | bool OKeyConfigItem::operator==( const OKeyConfigItem& conf ) { | 372 | bool OKeyConfigItem::operator==( const OKeyConfigItem& conf ) { |
372 | if ( isEmpty() == conf.isEmpty() ) return true; | 373 | /* if ( isEmpty() == conf.isEmpty() ) return true; |
373 | else if ( isEmpty() != conf.isEmpty() ) return false; | 374 | else if ( isEmpty() != conf.isEmpty() ) return false; |
374 | else if ( !isEmpty()!= conf.isEmpty() ) return false; | 375 | else if ( !isEmpty()!= conf.isEmpty() ) return false; |
376 | */ | ||
375 | 377 | ||
376 | if ( m_id != conf.m_id ) return false; | 378 | if ( m_id != conf.m_id ) return false; |
379 | if ( m_obj != conf.m_obj ) return false; | ||
377 | if ( m_text != conf.m_text ) return false; | 380 | if ( m_text != conf.m_text ) return false; |
378 | if ( m_key != conf.m_key ) return false; | 381 | if ( m_key != conf.m_key ) return false; |
379 | if ( m_def != conf.m_def ) return false; | 382 | if ( m_def != conf.m_def ) return false; |
380 | 383 | ||
384 | |||
385 | |||
381 | return true; | 386 | return true; |
382 | 387 | ||
383 | } | 388 | } |
384 | 389 | ||
385 | bool OKeyConfigItem::operator!=( const OKeyConfigItem& conf ) { | 390 | bool OKeyConfigItem::operator!=( const OKeyConfigItem& conf ) { |
386 | return !( *this == conf ); | 391 | return !( *this == conf ); |
387 | } | 392 | } |
388 | 393 | ||
@@ -500,20 +505,23 @@ void OKeyConfigManager::save() { | |||
500 | * Write each item | 505 | * Write each item |
501 | */ | 506 | */ |
502 | for( OKeyConfigItem::List::Iterator it = m_keys.begin(); | 507 | for( OKeyConfigItem::List::Iterator it = m_keys.begin(); |
503 | it != m_keys.end(); ++it ) { | 508 | it != m_keys.end(); ++it ) { |
504 | if ( (*it).isEmpty() ) | 509 | if ( (*it).isEmpty() ) |
505 | continue; | 510 | continue; |
506 | OKeyPair pair = (*it).keyPair(); | 511 | OKeyPair pair = (*it).keyPair(); |
507 | OKeyPair deft = (*it).defaultKeyPair(); | 512 | OKeyPair deft = (*it).defaultKeyPair(); |
508 | /* don't write if it is the default setting */ | 513 | /* |
514 | * don't write if it is the default setting | ||
515 | * FIXME allow to remove Keys | ||
509 | if ( (pair.keycode() == deft.keycode()) && | 516 | if ( (pair.keycode() == deft.keycode()) && |
510 | (pair.modifier()== deft.modifier() ) ) | 517 | (pair.modifier()== deft.modifier() ) ) |
511 | return; | 518 | return; |
519 | */ | ||
512 | 520 | ||
513 | m_conf->writeEntry((*it).configKey()+"key", pair.keycode() ); | 521 | m_conf->writeEntry((*it).configKey()+"key", pair.keycode() ); |
514 | m_conf->writeEntry((*it).configKey()+"mod", pair.modifier() ); | 522 | m_conf->writeEntry((*it).configKey()+"mod", pair.modifier() ); |
515 | } | 523 | } |
516 | } | 524 | } |
517 | 525 | ||
518 | /** | 526 | /** |
519 | * This is function uses a QMap internally but you can have the same keycode | 527 | * This is function uses a QMap internally but you can have the same keycode |
@@ -542,19 +550,19 @@ OKeyConfigItem OKeyConfigManager::handleKeyEvent( QKeyEvent* e ) { | |||
542 | key = e->ascii(); | 550 | key = e->ascii(); |
543 | if ( key > 96 && key < 123) | 551 | if ( key > 96 && key < 123) |
544 | key -= 32; | 552 | key -= 32; |
545 | }else{ | 553 | }else{ |
546 | int new_mod = 0; | 554 | int new_mod = 0; |
547 | if ( mod & 256 ) | 555 | if ( mod & 256 ) |
548 | new_mod |= Qt::ShiftButton; | 556 | new_mod |= Qt::ShiftButton; |
549 | else if ( mod & 512 ) | 557 | else if ( mod & 512 ) |
550 | new_mod |= Qt::AltButton; | ||
551 | else if ( mod & 1024 ) | ||
552 | new_mod |= Qt::ControlButton; | 558 | new_mod |= Qt::ControlButton; |
559 | else if ( mod & 1024 ) | ||
560 | new_mod |= Qt::AltButton; | ||
553 | 561 | ||
554 | mod = new_mod == 0? mod : new_mod; | 562 | mod = new_mod == 0? mod : new_mod; |
555 | } | 563 | } |
556 | 564 | ||
557 | OKeyConfigItem::List _keyList = keyList( key ); | 565 | OKeyConfigItem::List _keyList = keyList( key ); |
558 | if ( _keyList.isEmpty() ) | 566 | if ( _keyList.isEmpty() ) |
559 | return OKeyConfigItem(); | 567 | return OKeyConfigItem(); |
560 | 568 | ||
@@ -581,25 +589,27 @@ int OKeyConfigManager::handleKeyEventId( QKeyEvent* ev) { | |||
581 | return handleKeyEvent( ev ).id(); | 589 | return handleKeyEvent( ev ).id(); |
582 | } | 590 | } |
583 | 591 | ||
584 | /** | 592 | /** |
585 | * Add Key Config to the List of items | 593 | * Add Key Config to the List of items |
586 | */ | 594 | */ |
587 | void OKeyConfigManager::addKeyConfig( const OKeyConfigItem& item ) { | 595 | void OKeyConfigManager::addKeyConfig( const OKeyConfigItem& item ) { |
588 | m_keys.append( item ); | 596 | m_keys.append( item ); |
597 | qWarning( "m_keys count is now %d", m_keys.count() ); | ||
589 | delete m_map; m_map = 0; | 598 | delete m_map; m_map = 0; |
590 | } | 599 | } |
591 | 600 | ||
592 | /** | 601 | /** |
593 | * Remove the Key from the Config. Internal lists will be destroyed | 602 | * Remove the Key from the Config. Internal lists will be destroyed |
594 | * and rebuild on demand later | 603 | * and rebuild on demand later |
595 | */ | 604 | */ |
596 | void OKeyConfigManager::removeKeyConfig( const OKeyConfigItem& item ) { | 605 | void OKeyConfigManager::removeKeyConfig( const OKeyConfigItem& item ) { |
597 | m_keys.remove( item ); | 606 | m_keys.remove( item ); |
607 | qWarning( "m_keys count is now %d", m_keys.count() ); | ||
598 | delete m_map; m_map = 0; | 608 | delete m_map; m_map = 0; |
599 | } | 609 | } |
600 | 610 | ||
601 | /** | 611 | /** |
602 | * Clears the complete list | 612 | * Clears the complete list |
603 | */ | 613 | */ |
604 | void OKeyConfigManager::clearKeyConfig() { | 614 | void OKeyConfigManager::clearKeyConfig() { |
605 | m_keys.clear(); | 615 | m_keys.clear(); |
@@ -732,42 +742,56 @@ namespace Private { | |||
732 | class OKeyListViewItem : public Opie::Ui::OListViewItem { | 742 | class OKeyListViewItem : public Opie::Ui::OListViewItem { |
733 | public: | 743 | public: |
734 | OKeyListViewItem( const OKeyConfigItem& item, OKeyConfigManager*, Opie::Ui::OListViewItem* parent); | 744 | OKeyListViewItem( const OKeyConfigItem& item, OKeyConfigManager*, Opie::Ui::OListViewItem* parent); |
735 | ~OKeyListViewItem(); | 745 | ~OKeyListViewItem(); |
736 | 746 | ||
737 | void setDefault(); | 747 | void setDefault(); |
738 | 748 | ||
739 | OKeyConfigItem& item(); | 749 | OKeyConfigItem& item(); |
750 | OKeyConfigItem origItem()const; | ||
740 | void setItem( const OKeyConfigItem& item ); | 751 | void setItem( const OKeyConfigItem& item ); |
752 | void updateText(); | ||
741 | 753 | ||
742 | OKeyConfigManager *manager(); | 754 | OKeyConfigManager *manager(); |
743 | private: | 755 | private: |
744 | OKeyConfigItem m_item; | 756 | OKeyConfigItem m_item; |
757 | OKeyConfigItem m_origItem; | ||
745 | OKeyConfigManager* m_manager; | 758 | OKeyConfigManager* m_manager; |
746 | 759 | ||
747 | }; | 760 | }; |
748 | 761 | ||
749 | OKeyListViewItem::OKeyListViewItem( const OKeyConfigItem& item, OKeyConfigManager* man, OListViewItem* parent) | 762 | OKeyListViewItem::OKeyListViewItem( const OKeyConfigItem& item, OKeyConfigManager* man, OListViewItem* parent) |
750 | : Opie::Ui::OListViewItem( parent ), m_manager( man ) { | 763 | : Opie::Ui::OListViewItem( parent ), m_manager( man ) { |
764 | m_origItem = item; | ||
751 | setItem( item ); | 765 | setItem( item ); |
752 | } | 766 | } |
753 | OKeyListViewItem::~OKeyListViewItem() {} | 767 | OKeyListViewItem::~OKeyListViewItem() {} |
754 | OKeyConfigItem &OKeyListViewItem::item(){ | 768 | OKeyConfigItem &OKeyListViewItem::item(){ |
755 | return m_item; | 769 | return m_item; |
756 | } | 770 | } |
771 | OKeyConfigItem OKeyListViewItem::origItem() const{ | ||
772 | return m_origItem; | ||
773 | } | ||
757 | OKeyConfigManager* OKeyListViewItem::manager() { | 774 | OKeyConfigManager* OKeyListViewItem::manager() { |
758 | return m_manager; | 775 | return m_manager; |
759 | } | 776 | } |
760 | void OKeyListViewItem::setItem( const OKeyConfigItem& item ) { | 777 | void OKeyListViewItem::setItem( const OKeyConfigItem& item ) { |
761 | m_item = item; | 778 | m_item = item; |
762 | setPixmap( 0, m_item.pixmap() ); | 779 | setPixmap( 0, m_item.pixmap() ); |
763 | setText ( 1, m_item.text() ); | 780 | setText ( 1, m_item.text() ); |
764 | setText ( 2, keyToString( m_item.keyPair() ) ); | 781 | m_item.keyPair().isEmpty() ? setText( 2, QObject::tr( "None" ) ) : |
765 | setText ( 3, keyToString( m_item.defaultKeyPair() ) ); | 782 | setText( 2, keyToString( m_item.keyPair() ) ); |
783 | |||
784 | m_item.defaultKeyPair().isEmpty() ? setText( 3, QObject::tr( "None" ) ) : | ||
785 | setText ( 3, keyToString( m_item.defaultKeyPair() ) ); | ||
786 | } | ||
787 | void OKeyListViewItem::updateText() { | ||
788 | m_item.keyPair().isEmpty() ? setText( 2, QObject::tr( "None" ) ) : | ||
789 | setText( 2, keyToString( m_item.keyPair() ) ); | ||
766 | } | 790 | } |
767 | 791 | ||
768 | QString keyToString( const OKeyPair& pair ) { | 792 | QString keyToString( const OKeyPair& pair ) { |
769 | int mod = 0; | 793 | int mod = 0; |
770 | if ( pair.modifier() & Qt::ShiftButton ) | 794 | if ( pair.modifier() & Qt::ShiftButton ) |
771 | mod |= Qt::SHIFT; | 795 | mod |= Qt::SHIFT; |
772 | if ( pair.modifier() & Qt::ControlButton ) | 796 | if ( pair.modifier() & Qt::ControlButton ) |
773 | mod |= Qt::CTRL; | 797 | mod |= Qt::CTRL; |
@@ -843,16 +867,17 @@ void OKeyConfigWidget::initUi() { | |||
843 | */ | 867 | */ |
844 | m_view = new Opie::Ui::OListView( this ); | 868 | m_view = new Opie::Ui::OListView( this ); |
845 | m_view->setFocus(); | 869 | m_view->setFocus(); |
846 | m_view->setAllColumnsShowFocus( true ); | 870 | m_view->setAllColumnsShowFocus( true ); |
847 | m_view->addColumn( tr("Pixmap") ); | 871 | m_view->addColumn( tr("Pixmap") ); |
848 | m_view->addColumn( tr("Name","Name of the Action in the ListView Header" ) ); | 872 | m_view->addColumn( tr("Name","Name of the Action in the ListView Header" ) ); |
849 | m_view->addColumn( tr("Key" ) ); | 873 | m_view->addColumn( tr("Key" ) ); |
850 | m_view->addColumn( tr("Default Key" ) ); | 874 | m_view->addColumn( tr("Default Key" ) ); |
875 | m_view->setRootIsDecorated( true ); | ||
851 | connect(m_view, SIGNAL(currentChanged(QListViewItem*)), | 876 | connect(m_view, SIGNAL(currentChanged(QListViewItem*)), |
852 | this, SLOT(slotListViewItem(QListViewItem*)) ); | 877 | this, SLOT(slotListViewItem(QListViewItem*)) ); |
853 | 878 | ||
854 | gridLay->addMultiCellWidget( m_view, 1, 1, 0, 1 ); | 879 | gridLay->addMultiCellWidget( m_view, 1, 1, 0, 1 ); |
855 | 880 | ||
856 | /* | 881 | /* |
857 | * GROUP with button info | 882 | * GROUP with button info |
858 | */ | 883 | */ |
@@ -892,18 +917,20 @@ void OKeyConfigWidget::initUi() { | |||
892 | m_cus = rad; | 917 | m_cus = rad; |
893 | 918 | ||
894 | m_btn = new QPushButton( tr("Configure Key"), box ); | 919 | m_btn = new QPushButton( tr("Configure Key"), box ); |
895 | gridLay->addWidget( m_btn, 1, 4 ); | 920 | gridLay->addWidget( m_btn, 1, 4 ); |
896 | 921 | ||
897 | m_lbl= new QLabel( tr( "Default: " ), box ); | 922 | m_lbl= new QLabel( tr( "Default: " ), box ); |
898 | gridLay->addWidget( m_lbl, 2, 0 ); | 923 | gridLay->addWidget( m_lbl, 2, 0 ); |
899 | 924 | ||
925 | connect(m_btn, SIGNAL(clicked()), | ||
926 | this, SLOT(slotConfigure())); | ||
900 | 927 | ||
901 | m_box = gr; | 928 | m_box = box; |
902 | } | 929 | } |
903 | 930 | ||
904 | /** | 931 | /** |
905 | * Set the ChangeMode. | 932 | * Set the ChangeMode. |
906 | * You need to call this function prior to load | 933 | * You need to call this function prior to load |
907 | * If you call this function past load the behaviour is undefined | 934 | * If you call this function past load the behaviour is undefined |
908 | * But caling load again is safe | 935 | * But caling load again is safe |
909 | */ | 936 | */ |
@@ -944,16 +971,30 @@ void OKeyConfigWidget::load() { | |||
944 | } | 971 | } |
945 | 972 | ||
946 | /** | 973 | /** |
947 | * Saves if in Queue Mode. It'll update the supplied | 974 | * Saves if in Queue Mode. It'll update the supplied |
948 | * OKeyConfigManager objects. | 975 | * OKeyConfigManager objects. |
949 | * If in Queue mode it'll just return | 976 | * If in Queue mode it'll just return |
950 | */ | 977 | */ |
951 | void OKeyConfigWidget::save() { | 978 | void OKeyConfigWidget::save() { |
979 | /* | ||
980 | * Iterate over all config items | ||
981 | */ | ||
982 | QListViewItemIterator it( m_view ); | ||
983 | while ( it.current() ) { | ||
984 | if (it.current()->parent() ) { | ||
985 | Opie::Ui::Private::OKeyListViewItem *item = static_cast<Opie::Ui::Private::OKeyListViewItem*>( it.current() ); | ||
986 | OKeyConfigManager *man = item->manager(); | ||
987 | man->removeKeyConfig( item->origItem() ); | ||
988 | man->addKeyConfig( item->item() ); | ||
989 | } | ||
990 | ++it; | ||
991 | } | ||
992 | |||
952 | 993 | ||
953 | } | 994 | } |
954 | 995 | ||
955 | 996 | ||
956 | /** | 997 | /** |
957 | * @internal | 998 | * @internal |
958 | */ | 999 | */ |
959 | void OKeyConfigWidget::slotListViewItem( QListViewItem* _item) { | 1000 | void OKeyConfigWidget::slotListViewItem( QListViewItem* _item) { |
@@ -962,16 +1003,17 @@ void OKeyConfigWidget::slotListViewItem( QListViewItem* _item) { | |||
962 | m_none->setChecked( true ); | 1003 | m_none->setChecked( true ); |
963 | m_btn ->setEnabled( false ); | 1004 | m_btn ->setEnabled( false ); |
964 | m_def ->setChecked( false ); | 1005 | m_def ->setChecked( false ); |
965 | m_cus ->setChecked( false ); | 1006 | m_cus ->setChecked( false ); |
966 | }else{ | 1007 | }else{ |
967 | m_box->setEnabled( true ); | 1008 | m_box->setEnabled( true ); |
968 | Opie::Ui::Private::OKeyListViewItem *item = static_cast<Opie::Ui::Private::OKeyListViewItem*>( _item ); | 1009 | Opie::Ui::Private::OKeyListViewItem *item = static_cast<Opie::Ui::Private::OKeyListViewItem*>( _item ); |
969 | OKeyConfigItem keyItem= item->item(); | 1010 | OKeyConfigItem keyItem= item->item(); |
1011 | m_lbl->setText( tr("Default: " )+ item->text( 3 ) ); | ||
970 | if ( keyItem.keyPair().isEmpty() ) { | 1012 | if ( keyItem.keyPair().isEmpty() ) { |
971 | m_none->setChecked( true ); | 1013 | m_none->setChecked( true ); |
972 | m_btn ->setEnabled( false ); | 1014 | m_btn ->setEnabled( false ); |
973 | m_def ->setChecked( false ); | 1015 | m_def ->setChecked( false ); |
974 | m_cus ->setChecked( false ); | 1016 | m_cus ->setChecked( false ); |
975 | }else { | 1017 | }else { |
976 | m_none->setChecked( false ); | 1018 | m_none->setChecked( false ); |
977 | m_cus ->setChecked( true ); | 1019 | m_cus ->setChecked( true ); |
@@ -983,62 +1025,85 @@ void OKeyConfigWidget::slotListViewItem( QListViewItem* _item) { | |||
983 | 1025 | ||
984 | void OKeyConfigWidget::slotNoKey() { | 1026 | void OKeyConfigWidget::slotNoKey() { |
985 | qWarning( "No Key" ); | 1027 | qWarning( "No Key" ); |
986 | m_none->setChecked( true ); | 1028 | m_none->setChecked( true ); |
987 | m_cus ->setChecked( false ); | 1029 | m_cus ->setChecked( false ); |
988 | m_btn ->setEnabled( false ); | 1030 | m_btn ->setEnabled( false ); |
989 | m_def ->setChecked( false ); | 1031 | m_def ->setChecked( false ); |
990 | 1032 | ||
991 | if ( !m_view->currentItem() || m_view->currentItem()->parent() ) | 1033 | if ( !m_view->currentItem() || !m_view->currentItem()->parent() ) |
992 | return; | 1034 | return; |
993 | 1035 | ||
994 | 1036 | ||
995 | 1037 | ||
996 | /* | 1038 | /* |
997 | * If immediate we need to remove and readd the key | 1039 | * If immediate we need to remove and readd the key |
998 | */ | 1040 | */ |
999 | Opie::Ui::Private::OKeyListViewItem *item = static_cast<Opie::Ui::Private::OKeyListViewItem*>(m_view->currentItem()); | 1041 | Opie::Ui::Private::OKeyListViewItem *item = static_cast<Opie::Ui::Private::OKeyListViewItem*>(m_view->currentItem()); |
1000 | if ( m_mode == Imediate ) | 1042 | if ( m_mode == Imediate ) |
1001 | item->manager()->removeKeyConfig( item->item() ); | 1043 | item->manager()->removeKeyConfig( item->item() ); |
1002 | item->item().setKeyPair( OKeyPair::emptyKey() ); | 1044 | item->item().setKeyPair( OKeyPair::emptyKey() ); |
1045 | item->updateText(); | ||
1003 | 1046 | ||
1004 | if ( m_mode == Imediate ) | 1047 | if ( m_mode == Imediate ) |
1005 | item->manager()->addKeyConfig( item->item() ); | 1048 | item->manager()->addKeyConfig( item->item() ); |
1006 | 1049 | ||
1007 | } | 1050 | } |
1008 | 1051 | ||
1009 | void OKeyConfigWidget::slotDefaultKey() { | 1052 | void OKeyConfigWidget::slotDefaultKey() { |
1010 | qWarning( "Slot Default Key" ); | 1053 | m_none->setChecked( false ); |
1011 | m_none->setChecked( true ); | ||
1012 | m_cus ->setChecked( false ); | 1054 | m_cus ->setChecked( false ); |
1013 | m_btn ->setEnabled( false ); | 1055 | m_btn ->setEnabled( false ); |
1014 | m_def ->setChecked( false ); | 1056 | m_def ->setChecked( true ); |
1015 | 1057 | ||
1016 | if ( !m_view->currentItem() || m_view->currentItem()->parent() ) | 1058 | if ( !m_view->currentItem() || !m_view->currentItem()->parent() ) |
1017 | return; | 1059 | return; |
1018 | 1060 | ||
1019 | Opie::Ui::Private::OKeyListViewItem *item = static_cast<Opie::Ui::Private::OKeyListViewItem*>(m_view->currentItem()); | 1061 | Opie::Ui::Private::OKeyListViewItem *item = static_cast<Opie::Ui::Private::OKeyListViewItem*>(m_view->currentItem()); |
1020 | 1062 | ||
1021 | /* | 1063 | /* |
1022 | * If immediate we need to remove and readd the key | 1064 | * If immediate we need to remove and readd the key |
1023 | */ | 1065 | */ |
1024 | if ( m_mode == Imediate ) | 1066 | if ( m_mode == Imediate ) |
1025 | item->manager()->removeKeyConfig( item->item() ); | 1067 | item->manager()->removeKeyConfig( item->item() ); |
1026 | 1068 | ||
1027 | item->item().setKeyPair( item->item().defaultKeyPair() ); | 1069 | item->item().setKeyPair( item->item().defaultKeyPair() ); |
1070 | item->updateText(); | ||
1028 | 1071 | ||
1029 | if ( m_mode == Imediate ) | 1072 | if ( m_mode == Imediate ) |
1030 | item->manager()->addKeyConfig( item->item() ); | 1073 | item->manager()->addKeyConfig( item->item() ); |
1031 | } | 1074 | } |
1032 | 1075 | ||
1033 | void OKeyConfigWidget::slotCustomKey() { | 1076 | void OKeyConfigWidget::slotCustomKey() { |
1034 | qWarning( "SlotCustom Key" ); | ||
1035 | m_cus ->setChecked( true ); | 1077 | m_cus ->setChecked( true ); |
1036 | m_btn ->setEnabled( true ); | 1078 | m_btn ->setEnabled( true ); |
1037 | m_def ->setChecked( false ); | 1079 | m_def ->setChecked( false ); |
1038 | m_none->setChecked( false ); | 1080 | m_none->setChecked( false ); |
1039 | 1081 | ||
1040 | if ( !m_view->currentItem() || m_view->currentItem()->parent() ) | 1082 | if ( !m_view->currentItem() || !m_view->currentItem()->parent() ) |
1041 | return; | 1083 | return; |
1042 | 1084 | ||
1043 | } | 1085 | } |
1044 | 1086 | ||
1087 | void OKeyConfigWidget::slotConfigure() { | ||
1088 | |||
1089 | } | ||
1090 | |||
1091 | |||
1092 | OKeyChooserConfigDialog::OKeyChooserConfigDialog( QWidget* par, const char* nam, | ||
1093 | bool mod, WFlags fl ) | ||
1094 | : QDialog( par, nam, mod, fl ) { | ||
1095 | } | ||
1096 | |||
1097 | OKeyChooserConfigDialog::~OKeyChooserConfigDialog() { | ||
1098 | } | ||
1099 | |||
1100 | Opie::Ui::OKeyPair OKeyChooserConfigDialog::keyPair()const{ | ||
1101 | } | ||
1102 | |||
1103 | void OKeyChooserConfigDialog::keyPressEvent( QKeyEvent* ev ) { | ||
1104 | ev->ignore(); | ||
1105 | } | ||
1106 | |||
1107 | void OKeyChooserConfigDialog::keyReleaseEvent( QKeyEvent* ev ) { | ||
1108 | ev->ignore(); | ||
1109 | } | ||
diff --git a/libopie2/opieui/okeyconfigwidget.h b/libopie2/opieui/okeyconfigwidget.h index a7a5f48..8d2a1ef 100644 --- a/libopie2/opieui/okeyconfigwidget.h +++ b/libopie2/opieui/okeyconfigwidget.h | |||
@@ -243,28 +243,67 @@ public: | |||
243 | void load(); | 243 | void load(); |
244 | void save(); | 244 | void save(); |
245 | 245 | ||
246 | private slots: | 246 | private slots: |
247 | void slotListViewItem( QListViewItem* ); | 247 | void slotListViewItem( QListViewItem* ); |
248 | void slotNoKey(); | 248 | void slotNoKey(); |
249 | void slotDefaultKey(); | 249 | void slotDefaultKey(); |
250 | void slotCustomKey(); | 250 | void slotCustomKey(); |
251 | 251 | void slotConfigure(); | |
252 | 252 | ||
253 | private: | 253 | private: |
254 | void initUi(); | 254 | void initUi(); |
255 | Opie::Ui::OListView *m_view; | 255 | Opie::Ui::OListView *m_view; |
256 | Opie::Ui::Private::OKeyConfigWidgetPrivateList m_list; | 256 | Opie::Ui::Private::OKeyConfigWidgetPrivateList m_list; |
257 | QLabel *m_lbl; | 257 | QLabel *m_lbl; |
258 | QPushButton *m_btn; | 258 | QPushButton *m_btn; |
259 | QRadioButton *m_def, *m_cus, *m_none; | 259 | QRadioButton *m_def, *m_cus, *m_none; |
260 | QWidget* m_box; | 260 | QWidget* m_box; |
261 | ChangeMode m_mode; | 261 | ChangeMode m_mode; |
262 | class Private; | 262 | class Private; |
263 | Private *d; | 263 | Private *d; |
264 | }; | 264 | }; |
265 | 265 | ||
266 | |||
267 | /** | ||
268 | * This is a small dialog that allows you to | ||
269 | * capture a key sequence. | ||
270 | * If you want it to close after a key was captured you | ||
271 | * can use this code snippet. | ||
272 | * | ||
273 | * \code | ||
274 | * OKeyChooserConfigDialog diag(0,0,true); | ||
275 | * connect(&diag,SIGNAL(keyCaptured()), | ||
276 | * this,SLOT(accept())); | ||
277 | * if( QPEApplication::execDialog(&diag) == QDialog::Accept ){ | ||
278 | * take_the_key_and_do_something | ||
279 | * } | ||
280 | * | ||
281 | * \endcode | ||
282 | * | ||
283 | */ | ||
284 | class OKeyChooserConfigDialog : public QDialog { | ||
285 | Q_OBJECT | ||
286 | public: | ||
287 | OKeyChooserConfigDialog( QWidget* parent = 0, const char* name = 0, bool modal = false, WFlags fl = 0 ); | ||
288 | ~OKeyChooserConfigDialog(); | ||
289 | |||
290 | OKeyPair keyPair()const; | ||
291 | |||
292 | protected: | ||
293 | void keyPressEvent( QKeyEvent* ); | ||
294 | void keyReleaseEvent( QKeyEvent* ); | ||
295 | |||
296 | signals: | ||
297 | void keyCaptured(); | ||
298 | |||
299 | private: | ||
300 | OKeyPair m_keyPair; | ||
301 | class Private; | ||
302 | Private *d; | ||
303 | }; | ||
304 | |||
266 | } | 305 | } |
267 | } | 306 | } |
268 | 307 | ||
269 | 308 | ||
270 | #endif | 309 | #endif |