-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 | |||
@@ -509,65 +509,64 @@ void OKeyConfigManager::save() { | |||
509 | if ( (pair.keycode() == deft.keycode()) && | 509 | if ( (pair.keycode() == deft.keycode()) && |
510 | (pair.modifier()== deft.modifier() ) ) | 510 | (pair.modifier()== deft.modifier() ) ) |
511 | return; | 511 | return; |
512 | 512 | ||
513 | m_conf->writeEntry((*it).configKey()+"key", pair.keycode() ); | 513 | m_conf->writeEntry((*it).configKey()+"key", pair.keycode() ); |
514 | m_conf->writeEntry((*it).configKey()+"mod", pair.modifier() ); | 514 | m_conf->writeEntry((*it).configKey()+"mod", pair.modifier() ); |
515 | } | 515 | } |
516 | } | 516 | } |
517 | 517 | ||
518 | /** | 518 | /** |
519 | * 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 |
520 | * 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 |
521 | * 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 |
522 | * cofigure two keys. | 522 | * cofigure two keys. |
523 | * | 523 | * |
524 | * 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 |
525 | */ | 525 | */ |
526 | OKeyConfigItem OKeyConfigManager::handleKeyEvent( QKeyEvent* e ) { | 526 | OKeyConfigItem OKeyConfigManager::handleKeyEvent( QKeyEvent* e ) { |
527 | /* | 527 | /* |
528 | * Fix Up issues with Qt/E, my keybard, and virtual input | 528 | * Fix Up issues with Qt/E, my keybard, and virtual input |
529 | * methods | 529 | * methods |
530 | * First my Keyboard delivers 256,512,1024 for shift/ctrl/alt instead of the button state | 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 | 531 | * Also key() on virtual inputmethods are zero and only ascii. We need to fix upper and lower |
532 | * case ascii | 532 | * case ascii |
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; |
550 | else if ( mod & 512 ) | 549 | else if ( mod & 512 ) |
551 | new_mod |= Qt::AltButton; | 550 | new_mod |= Qt::AltButton; |
552 | else if ( mod & 1024 ) | 551 | else if ( mod & 1024 ) |
553 | new_mod |= Qt::ControlButton; | 552 | new_mod |= Qt::ControlButton; |
554 | 553 | ||
555 | mod = new_mod == 0? mod : new_mod; | 554 | mod = new_mod == 0? mod : new_mod; |
556 | } | 555 | } |
557 | 556 | ||
558 | OKeyConfigItem::List _keyList = keyList( key ); | 557 | OKeyConfigItem::List _keyList = keyList( key ); |
559 | if ( _keyList.isEmpty() ) | 558 | if ( _keyList.isEmpty() ) |
560 | return OKeyConfigItem(); | 559 | return OKeyConfigItem(); |
561 | 560 | ||
562 | OKeyConfigItem item; | 561 | OKeyConfigItem item; |
563 | for ( OKeyConfigItem::List::Iterator it = _keyList.begin(); it != _keyList.end(); | 562 | for ( OKeyConfigItem::List::Iterator it = _keyList.begin(); it != _keyList.end(); |
564 | ++it ) { | 563 | ++it ) { |
565 | if ( (*it).keyPair().modifier() == mod ) { | 564 | if ( (*it).keyPair().modifier() == mod ) { |
566 | item = *it; | 565 | item = *it; |
567 | break; | 566 | break; |
568 | } | 567 | } |
569 | 568 | ||
570 | } | 569 | } |
571 | 570 | ||
572 | return item; | 571 | return item; |
573 | } | 572 | } |
@@ -578,64 +577,70 @@ OKeyConfigItem OKeyConfigManager::handleKeyEvent( QKeyEvent* e ) { | |||
578 | * | 577 | * |
579 | * @see handleKeyEvent | 578 | * @see handleKeyEvent |
580 | */ | 579 | */ |
581 | int OKeyConfigManager::handleKeyEventId( QKeyEvent* ev) { | 580 | int OKeyConfigManager::handleKeyEventId( QKeyEvent* ev) { |
582 | return handleKeyEvent( ev ).id(); | 581 | return handleKeyEvent( ev ).id(); |
583 | } | 582 | } |
584 | 583 | ||
585 | /** | 584 | /** |
586 | * Add Key Config to the List of items | 585 | * Add Key Config to the List of items |
587 | */ | 586 | */ |
588 | void OKeyConfigManager::addKeyConfig( const OKeyConfigItem& item ) { | 587 | void OKeyConfigManager::addKeyConfig( const OKeyConfigItem& item ) { |
589 | m_keys.append( item ); | 588 | m_keys.append( item ); |
590 | delete m_map; m_map = 0; | 589 | delete m_map; m_map = 0; |
591 | } | 590 | } |
592 | 591 | ||
593 | /** | 592 | /** |
594 | * Remove the Key from the Config. Internal lists will be destroyed | 593 | * Remove the Key from the Config. Internal lists will be destroyed |
595 | * and rebuild on demand later | 594 | * and rebuild on demand later |
596 | */ | 595 | */ |
597 | void OKeyConfigManager::removeKeyConfig( const OKeyConfigItem& item ) { | 596 | void OKeyConfigManager::removeKeyConfig( const OKeyConfigItem& item ) { |
598 | m_keys.remove( item ); | 597 | m_keys.remove( item ); |
599 | delete m_map; m_map = 0; | 598 | delete m_map; m_map = 0; |
600 | } | 599 | } |
601 | 600 | ||
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; |
618 | } | 623 | } |
619 | 624 | ||
620 | 625 | ||
621 | /** | 626 | /** |
622 | * Remove this OKeyPair from the black List | 627 | * Remove this OKeyPair from the black List |
623 | * Internal lists will be destroyed | 628 | * Internal lists will be destroyed |
624 | */ | 629 | */ |
625 | void OKeyConfigManager::removeFromBlackList( const OKeyPair& key ) { | 630 | void OKeyConfigManager::removeFromBlackList( const OKeyPair& key ) { |
626 | m_blackKeys.remove( key ); | 631 | m_blackKeys.remove( key ); |
627 | delete m_map; m_map = 0; | 632 | delete m_map; m_map = 0; |
628 | } | 633 | } |
629 | 634 | ||
630 | 635 | ||
631 | /** | 636 | /** |
632 | * Clear the blackList | 637 | * Clear the blackList |
633 | */ | 638 | */ |
634 | void OKeyConfigManager::clearBlackList() { | 639 | void OKeyConfigManager::clearBlackList() { |
635 | m_blackKeys.clear(); | 640 | m_blackKeys.clear(); |
636 | delete m_map; m_map = 0; | 641 | delete m_map; m_map = 0; |
637 | } | 642 | } |
638 | 643 | ||
639 | 644 | ||
640 | /** | 645 | /** |
641 | * Return a copy of the blackList | 646 | * Return a copy of the blackList |
@@ -724,69 +729,69 @@ namespace Opie { | |||
724 | namespace Ui { | 729 | namespace Ui { |
725 | namespace Private { | 730 | namespace Private { |
726 | static QString keyToString( const OKeyPair& ); | 731 | static QString keyToString( const OKeyPair& ); |
727 | class OKeyListViewItem : public Opie::Ui::OListViewItem { | 732 | class OKeyListViewItem : public Opie::Ui::OListViewItem { |
728 | public: | 733 | public: |
729 | OKeyListViewItem( const OKeyConfigItem& item, OKeyConfigManager*, Opie::Ui::OListViewItem* parent); | 734 | OKeyListViewItem( const OKeyConfigItem& item, OKeyConfigManager*, Opie::Ui::OListViewItem* parent); |
730 | ~OKeyListViewItem(); | 735 | ~OKeyListViewItem(); |
731 | 736 | ||
732 | void setDefault(); | 737 | void setDefault(); |
733 | 738 | ||
734 | OKeyConfigItem& item(); | 739 | OKeyConfigItem& item(); |
735 | void setItem( const OKeyConfigItem& item ); | 740 | void setItem( const OKeyConfigItem& item ); |
736 | 741 | ||
737 | OKeyConfigManager *manager(); | 742 | OKeyConfigManager *manager(); |
738 | private: | 743 | private: |
739 | OKeyConfigItem m_item; | 744 | OKeyConfigItem m_item; |
740 | OKeyConfigManager* m_manager; | 745 | OKeyConfigManager* m_manager; |
741 | 746 | ||
742 | }; | 747 | }; |
743 | 748 | ||
744 | OKeyListViewItem::OKeyListViewItem( const OKeyConfigItem& item, OKeyConfigManager* man, OListViewItem* parent) | 749 | OKeyListViewItem::OKeyListViewItem( const OKeyConfigItem& item, OKeyConfigManager* man, OListViewItem* parent) |
745 | : Opie::Ui::OListViewItem( parent ), m_manager( man ) { | 750 | : Opie::Ui::OListViewItem( parent ), m_manager( man ) { |
746 | setItem( item ); | 751 | setItem( item ); |
747 | } | 752 | } |
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; |
769 | if ( pair.modifier() & Qt::AltButton ) | 774 | if ( pair.modifier() & Qt::AltButton ) |
770 | mod |= Qt::ALT; | 775 | mod |= Qt::ALT; |
771 | 776 | ||
772 | return QAccel::keyToString( mod + pair.keycode() ); | 777 | return QAccel::keyToString( mod + pair.keycode() ); |
773 | } | 778 | } |
774 | 779 | ||
775 | struct OKeyConfigWidgetPrivate{ | 780 | struct OKeyConfigWidgetPrivate{ |
776 | OKeyConfigWidgetPrivate(const QString& = QString::null, | 781 | OKeyConfigWidgetPrivate(const QString& = QString::null, |
777 | OKeyConfigManager* = 0); | 782 | OKeyConfigManager* = 0); |
778 | bool operator==( const OKeyConfigWidgetPrivate& ); | 783 | bool operator==( const OKeyConfigWidgetPrivate& ); |
779 | QString name; | 784 | QString name; |
780 | OKeyConfigManager *manager; | 785 | OKeyConfigManager *manager; |
781 | }; | 786 | }; |
782 | 787 | ||
783 | OKeyConfigWidgetPrivate::OKeyConfigWidgetPrivate( const QString& _name, | 788 | OKeyConfigWidgetPrivate::OKeyConfigWidgetPrivate( const QString& _name, |
784 | OKeyConfigManager* man ) | 789 | OKeyConfigManager* man ) |
785 | : name( _name ), manager( man ){} | 790 | : name( _name ), manager( man ){} |
786 | 791 | ||
787 | bool OKeyConfigWidgetPrivate::operator==( const OKeyConfigWidgetPrivate& item) { | 792 | bool OKeyConfigWidgetPrivate::operator==( const OKeyConfigWidgetPrivate& item) { |
788 | if ( manager != item.manager) return false; | 793 | if ( manager != item.manager) return false; |
789 | if ( name != item.name ) return false; | 794 | if ( name != item.name ) return false; |
790 | 795 | ||
791 | return true; | 796 | return true; |
792 | } | 797 | } |
@@ -824,65 +829,64 @@ OKeyConfigWidget::~OKeyConfigWidget() { | |||
824 | } | 829 | } |
825 | 830 | ||
826 | 831 | ||
827 | /** | 832 | /** |
828 | * @internal | 833 | * @internal |
829 | */ | 834 | */ |
830 | void OKeyConfigWidget::initUi() { | 835 | void OKeyConfigWidget::initUi() { |
831 | QBoxLayout *layout = new QVBoxLayout( this ); | 836 | QBoxLayout *layout = new QVBoxLayout( this ); |
832 | QGridLayout *gridLay = new QGridLayout( 2, 2 ); | 837 | QGridLayout *gridLay = new QGridLayout( 2, 2 ); |
833 | layout->addLayout( gridLay, 10 ); | 838 | layout->addLayout( gridLay, 10 ); |
834 | gridLay->setRowStretch( 1, 10 ); // let only the ListView strecth | 839 | gridLay->setRowStretch( 1, 10 ); // let only the ListView strecth |
835 | 840 | ||
836 | /* | 841 | /* |
837 | * LISTVIEW with the Keys | 842 | * LISTVIEW with the Keys |
838 | */ | 843 | */ |
839 | m_view = new Opie::Ui::OListView( this ); | 844 | m_view = new Opie::Ui::OListView( this ); |
840 | m_view->setFocus(); | 845 | m_view->setFocus(); |
841 | m_view->setAllColumnsShowFocus( true ); | 846 | m_view->setAllColumnsShowFocus( true ); |
842 | m_view->addColumn( tr("Pixmap") ); | 847 | m_view->addColumn( tr("Pixmap") ); |
843 | m_view->addColumn( tr("Name","Name of the Action in the ListView Header" ) ); | 848 | m_view->addColumn( tr("Name","Name of the Action in the ListView Header" ) ); |
844 | m_view->addColumn( tr("Key" ) ); | 849 | m_view->addColumn( tr("Key" ) ); |
845 | m_view->addColumn( tr("Default Key" ) ); | 850 | m_view->addColumn( tr("Default Key" ) ); |
846 | connect(m_view, SIGNAL(currentChanged(QListViewItem*)), | 851 | connect(m_view, SIGNAL(currentChanged(QListViewItem*)), |
847 | this, SLOT(slotListViewItem(QListViewItem*)) ); | 852 | this, SLOT(slotListViewItem(QListViewItem*)) ); |
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 | ||
865 | QButtonGroup *gr = new QButtonGroup( box ); | 869 | QButtonGroup *gr = new QButtonGroup( box ); |
866 | gr->hide(); | 870 | gr->hide(); |
867 | gr->setExclusive( true ); | 871 | gr->setExclusive( true ); |
868 | 872 | ||
869 | QRadioButton *rad = new QRadioButton( tr( "&None" ), box ); | 873 | QRadioButton *rad = new QRadioButton( tr( "&None" ), box ); |
870 | connect( rad, SIGNAL(clicked()), | 874 | connect( rad, SIGNAL(clicked()), |
871 | this, SLOT(slotNoKey()) ); | 875 | this, SLOT(slotNoKey()) ); |
872 | gr->insert( rad, 10 ); | 876 | gr->insert( rad, 10 ); |
873 | gridLay->addWidget( rad, 1, 0 ); | 877 | gridLay->addWidget( rad, 1, 0 ); |
874 | m_none = rad; | 878 | m_none = rad; |
875 | 879 | ||
876 | rad = new QRadioButton( tr("&Default" ), box ); | 880 | rad = new QRadioButton( tr("&Default" ), box ); |
877 | connect( rad, SIGNAL(clicked()), | 881 | connect( rad, SIGNAL(clicked()), |
878 | this, SLOT(slotDefaultKey()) ); | 882 | this, SLOT(slotDefaultKey()) ); |
879 | gr->insert( rad, 11 ); | 883 | gr->insert( rad, 11 ); |
880 | gridLay->addWidget( rad, 1, 1 ); | 884 | gridLay->addWidget( rad, 1, 1 ); |
881 | m_def = rad; | 885 | m_def = rad; |
882 | 886 | ||
883 | rad = new QRadioButton( tr("C&ustom"), box ); | 887 | rad = new QRadioButton( tr("C&ustom"), box ); |
884 | connect( rad, SIGNAL(clicked()), | 888 | connect( rad, SIGNAL(clicked()), |
885 | this, SLOT(slotCustomKey()) ); | 889 | this, SLOT(slotCustomKey()) ); |
886 | gr->insert( rad, 12 ); | 890 | gr->insert( rad, 12 ); |
887 | gridLay->addWidget( rad, 1, 2 ); | 891 | gridLay->addWidget( rad, 1, 2 ); |
888 | m_cus = rad; | 892 | m_cus = rad; |
@@ -900,131 +904,141 @@ void OKeyConfigWidget::initUi() { | |||
900 | /** | 904 | /** |
901 | * Set the ChangeMode. | 905 | * Set the ChangeMode. |
902 | * You need to call this function prior to load | 906 | * You need to call this function prior to load |
903 | * If you call this function past load the behaviour is undefined | 907 | * If you call this function past load the behaviour is undefined |
904 | * But caling load again is safe | 908 | * But caling load again is safe |
905 | */ | 909 | */ |
906 | void OKeyConfigWidget::setChangeMode( enum ChangeMode mode) { | 910 | void OKeyConfigWidget::setChangeMode( enum ChangeMode mode) { |
907 | m_mode = mode; | 911 | m_mode = mode; |
908 | } | 912 | } |
909 | 913 | ||
910 | 914 | ||
911 | /** | 915 | /** |
912 | * return the current mode | 916 | * return the current mode |
913 | */ | 917 | */ |
914 | OKeyConfigWidget::ChangeMode OKeyConfigWidget::changeMode()const { | 918 | OKeyConfigWidget::ChangeMode OKeyConfigWidget::changeMode()const { |
915 | return m_mode; | 919 | return m_mode; |
916 | } | 920 | } |
917 | 921 | ||
918 | 922 | ||
919 | /** | 923 | /** |
920 | * insert these items before calling load | 924 | * insert these items before calling load |
921 | */ | 925 | */ |
922 | void OKeyConfigWidget::insert( const QString& str, OKeyConfigManager* man ) { | 926 | void OKeyConfigWidget::insert( const QString& str, OKeyConfigManager* man ) { |
923 | Opie::Ui::Private::OKeyConfigWidgetPrivate root( str, man ); | 927 | Opie::Ui::Private::OKeyConfigWidgetPrivate root( str, 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() { |
941 | 952 | ||
942 | } | 953 | } |
943 | 954 | ||
944 | 955 | ||
945 | /** | 956 | /** |
946 | * @internal | 957 | * @internal |
947 | */ | 958 | */ |
948 | void OKeyConfigWidget::slotListViewItem( QListViewItem* _item) { | 959 | void OKeyConfigWidget::slotListViewItem( QListViewItem* _item) { |
949 | if ( !_item || !_item->parent() ) { | 960 | if ( !_item || !_item->parent() ) { |
950 | m_box->setEnabled( false ); | 961 | m_box->setEnabled( false ); |
951 | m_none->setChecked( true ); | 962 | m_none->setChecked( true ); |
952 | m_btn ->setEnabled( false ); | 963 | m_btn ->setEnabled( false ); |
953 | m_def ->setChecked( false ); | 964 | m_def ->setChecked( false ); |
954 | m_cus ->setChecked( false ); | 965 | m_cus ->setChecked( false ); |
955 | }else{ | 966 | }else{ |
956 | m_box->setEnabled( true ); | 967 | m_box->setEnabled( true ); |
957 | Opie::Ui::Private::OKeyListViewItem *item = static_cast<Opie::Ui::Private::OKeyListViewItem*>( _item ); | 968 | Opie::Ui::Private::OKeyListViewItem *item = static_cast<Opie::Ui::Private::OKeyListViewItem*>( _item ); |
958 | OKeyConfigItem keyItem= item->item(); | 969 | OKeyConfigItem keyItem= item->item(); |
959 | if ( keyItem.keyPair().isEmpty() ) { | 970 | if ( keyItem.keyPair().isEmpty() ) { |
960 | m_none->setChecked( true ); | 971 | m_none->setChecked( true ); |
961 | m_btn ->setEnabled( false ); | 972 | m_btn ->setEnabled( false ); |
962 | m_def ->setChecked( false ); | 973 | m_def ->setChecked( false ); |
963 | m_cus ->setChecked( false ); | 974 | m_cus ->setChecked( false ); |
964 | }else { | 975 | }else { |
965 | m_none->setChecked( false ); | 976 | m_none->setChecked( false ); |
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 | ||
982 | 994 | ||
983 | 995 | ||
984 | /* | 996 | /* |
985 | * If immediate we need to remove and readd the key | 997 | * If immediate we need to remove and readd the key |
986 | */ | 998 | */ |
987 | Opie::Ui::Private::OKeyListViewItem *item = static_cast<Opie::Ui::Private::OKeyListViewItem*>(m_view->currentItem()); | 999 | Opie::Ui::Private::OKeyListViewItem *item = static_cast<Opie::Ui::Private::OKeyListViewItem*>(m_view->currentItem()); |
988 | if ( m_mode == Imediate ) | 1000 | if ( m_mode == Imediate ) |
989 | item->manager()->removeKeyConfig( item->item() ); | 1001 | item->manager()->removeKeyConfig( item->item() ); |
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 | ||
1006 | Opie::Ui::Private::OKeyListViewItem *item = static_cast<Opie::Ui::Private::OKeyListViewItem*>(m_view->currentItem()); | 1019 | Opie::Ui::Private::OKeyListViewItem *item = static_cast<Opie::Ui::Private::OKeyListViewItem*>(m_view->currentItem()); |
1007 | 1020 | ||
1008 | /* | 1021 | /* |
1009 | * If immediate we need to remove and readd the key | 1022 | * If immediate we need to remove and readd the key |
1010 | */ | 1023 | */ |
1011 | if ( m_mode == Imediate ) | 1024 | if ( m_mode == Imediate ) |
1012 | item->manager()->removeKeyConfig( item->item() ); | 1025 | item->manager()->removeKeyConfig( item->item() ); |
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 | ||
1029 | } | 1043 | } |
1030 | 1044 | ||
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 | |||
@@ -151,64 +151,66 @@ private: | |||
151 | * | 151 | * |
152 | * @since 1.1.2 | 152 | * @since 1.1.2 |
153 | */ | 153 | */ |
154 | class OKeyConfigManager : public QObject { | 154 | class OKeyConfigManager : public QObject { |
155 | Q_OBJECT | 155 | Q_OBJECT |
156 | typedef QMap<int, OKeyConfigItem::List> OKeyMapConfigPrivate; | 156 | typedef QMap<int, OKeyConfigItem::List> OKeyMapConfigPrivate; |
157 | public: | 157 | public: |
158 | OKeyConfigManager(Opie::Core::OConfig *conf = 0, | 158 | OKeyConfigManager(Opie::Core::OConfig *conf = 0, |
159 | const QString& group = QString::null, | 159 | const QString& group = QString::null, |
160 | const OKeyPair::List &block = OKeyPair::List(), | 160 | const OKeyPair::List &block = OKeyPair::List(), |
161 | bool grabkeyboard = false, QObject * par = 0, | 161 | bool grabkeyboard = false, QObject * par = 0, |
162 | const char* name = 0 ); | 162 | const char* name = 0 ); |
163 | ~OKeyConfigManager(); | 163 | ~OKeyConfigManager(); |
164 | 164 | ||
165 | void load(); | 165 | void load(); |
166 | void save(); | 166 | void save(); |
167 | 167 | ||
168 | OKeyConfigItem handleKeyEvent( QKeyEvent* ); | 168 | OKeyConfigItem handleKeyEvent( QKeyEvent* ); |
169 | int handleKeyEventId( QKeyEvent* ); | 169 | int handleKeyEventId( QKeyEvent* ); |
170 | 170 | ||
171 | void addKeyConfig( const OKeyConfigItem& ); | 171 | void addKeyConfig( const OKeyConfigItem& ); |
172 | void removeKeyConfig( const OKeyConfigItem& ); | 172 | void removeKeyConfig( const OKeyConfigItem& ); |
173 | void clearKeyConfig(); | 173 | void clearKeyConfig(); |
174 | 174 | ||
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 | ||
191 | /** | 193 | /** |
192 | * This Signal correspondents to the OKeyConfigItem slot | 194 | * This Signal correspondents to the OKeyConfigItem slot |
193 | * and object | 195 | * and object |
194 | * | 196 | * |
195 | * @see OKeyConfigItem::slot | 197 | * @see OKeyConfigItem::slot |
196 | * @see OKeyConfigItem::object | 198 | * @see OKeyConfigItem::object |
197 | */ | 199 | */ |
198 | void actionActivated( QWidget* par, QKeyEvent* key); | 200 | void actionActivated( QWidget* par, QKeyEvent* key); |
199 | 201 | ||
200 | private: | 202 | private: |
201 | OKeyConfigItem::List keyList( int ); | 203 | OKeyConfigItem::List keyList( int ); |
202 | OKeyConfigItem::List m_keys; | 204 | OKeyConfigItem::List m_keys; |
203 | QValueList<QWidget*> m_widgets; | 205 | QValueList<QWidget*> m_widgets; |
204 | Opie::Core::OConfig *m_conf; | 206 | Opie::Core::OConfig *m_conf; |
205 | QString m_group; | 207 | QString m_group; |
206 | OKeyPair::List m_blackKeys; | 208 | OKeyPair::List m_blackKeys; |
207 | bool m_grab : 1; | 209 | bool m_grab : 1; |
208 | OKeyMapConfigPrivate *m_map; | 210 | OKeyMapConfigPrivate *m_map; |
209 | class Private; | 211 | class Private; |
210 | Private *d; | 212 | Private *d; |
211 | }; | 213 | }; |
212 | 214 | ||
213 | 215 | ||
214 | /** | 216 | /** |