summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opieui/okeyconfigwidget.cpp20
-rw-r--r--libopie2/opieui/okeyconfigwidget.h2
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
@@ -493,165 +493,170 @@ void OKeyConfigManager::load() {
493 * We will save the current configuration 493 * We will save the current configuration
494 * to the OConfig. We will change the group. 494 * to the OConfig. We will change the group.
495 */ 495 */
496void OKeyConfigManager::save() { 496void 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(); 507 OKeyPair deft = (*it).defaultKeyPair();
508 /* don't write if it is the default setting */ 508 /* don't write if it is the default setting */
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 */
526OKeyConfigItem OKeyConfigManager::handleKeyEvent( QKeyEvent* e ) { 526OKeyConfigItem 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}
574 573
575/** 574/**
576 * Return the associated id of the item or -1 if no item 575 * Return the associated id of the item or -1 if no item
577 * matched the key 576 * matched the key
578 * 577 *
579 * @see handleKeyEvent 578 * @see handleKeyEvent
580 */ 579 */
581int OKeyConfigManager::handleKeyEventId( QKeyEvent* ev) { 580int 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 */
588void OKeyConfigManager::addKeyConfig( const OKeyConfigItem& item ) { 587void 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 */
597void OKeyConfigManager::removeKeyConfig( const OKeyConfigItem& item ) { 596void 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 */
605void OKeyConfigManager::clearKeyConfig() { 604void 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 */
612Opie::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 */
615void OKeyConfigManager::addToBlackList( const OKeyPair& key) { 620void 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 */
625void OKeyConfigManager::removeFromBlackList( const OKeyPair& key ) { 630void 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 */
634void OKeyConfigManager::clearBlackList() { 639void 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
642 */ 647 */
643OKeyPair::List OKeyConfigManager::blackList()const { 648OKeyPair::List OKeyConfigManager::blackList()const {
644 return m_blackKeys; 649 return m_blackKeys;
645} 650}
646 651
647 652
648/** 653/**
649 * Ask the Manager to handle KeyEvents for you. 654 * Ask the Manager to handle KeyEvents for you.
650 * All handled keys will emit a QSignal and return true 655 * All handled keys will emit a QSignal and return true
651 * that it handled the keyevent 656 * that it handled the keyevent
652 */ 657 */
653void OKeyConfigManager::handleWidget( QWidget* wid ) { 658void OKeyConfigManager::handleWidget( QWidget* wid ) {
654 wid->installEventFilter( this ); 659 wid->installEventFilter( this );
655} 660}
656 661
657/** 662/**
@@ -708,323 +713,332 @@ OKeyConfigItem::List OKeyConfigManager::keyList( int keycode) {
708 break; 713 break;
709 } 714 }
710 } 715 }
711 /* check if we added it */ 716 /* check if we added it */
712 if ( add ) 717 if ( add )
713 (*m_map)[pair.keycode()].append( *it ); 718 (*m_map)[pair.keycode()].append( *it );
714 } 719 }
715 } 720 }
716 return (*m_map)[keycode]; 721 return (*m_map)[keycode];
717} 722}
718 723
719 724
720 725
721///////////////////////// 726/////////////////////////
722//////// Widget Starts Here 727//////// Widget Starts Here
723namespace Opie { 728namespace Opie {
724namespace Ui { 729namespace Ui {
725namespace Private { 730namespace 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 }
793 798
794} 799}
795} 800}
796} 801}
797 802
798 803
799 804
800//////////////////////// 805////////////////////////
801 806
802 807
803 808
804 809
805 810
806/** 811/**
807 * 812 *
808 * This is a c'tor. You still need to pass the OKeyConfigManager 813 * This is a c'tor. You still need to pass the OKeyConfigManager
809 * and then issue a load. 814 * and then issue a load.
810 * The default mode is Immediate 815 * The default mode is Immediate
811 * 816 *
812 */ 817 */
813OKeyConfigWidget::OKeyConfigWidget( QWidget* parent, const char *name, WFlags fl ) 818OKeyConfigWidget::OKeyConfigWidget( QWidget* parent, const char *name, WFlags fl )
814 : QWidget( parent, name, fl ) { 819 : QWidget( parent, name, fl ) {
815 initUi(); 820 initUi();
816} 821}
817 822
818 823
819 824
820/** 825/**
821 * c'tor 826 * c'tor
822 */ 827 */
823OKeyConfigWidget::~OKeyConfigWidget() { 828OKeyConfigWidget::~OKeyConfigWidget() {
824} 829}
825 830
826 831
827/** 832/**
828 * @internal 833 * @internal
829 */ 834 */
830void OKeyConfigWidget::initUi() { 835void 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;
889 893
890 m_btn = new QPushButton( tr("Configure Key"), box ); 894 m_btn = new QPushButton( tr("Configure Key"), box );
891 gridLay->addWidget( m_btn, 1, 4 ); 895 gridLay->addWidget( m_btn, 1, 4 );
892 896
893 m_lbl= new QLabel( tr( "Default: " ), box ); 897 m_lbl= new QLabel( tr( "Default: " ), box );
894 gridLay->addWidget( m_lbl, 2, 0 ); 898 gridLay->addWidget( m_lbl, 2, 0 );
895 899
896 900
897 m_box = gr; 901 m_box = gr;
898} 902}
899 903
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 */
906void OKeyConfigWidget::setChangeMode( enum ChangeMode mode) { 910void 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 */
914OKeyConfigWidget::ChangeMode OKeyConfigWidget::changeMode()const { 918OKeyConfigWidget::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 */
922void OKeyConfigWidget::insert( const QString& str, OKeyConfigManager* man ) { 926void 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 */
931void OKeyConfigWidget::load() { 935void 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 */
940void OKeyConfigWidget::save() { 951void OKeyConfigWidget::save() {
941 952
942} 953}
943 954
944 955
945/** 956/**
946 * @internal 957 * @internal
947 */ 958 */
948void OKeyConfigWidget::slotListViewItem( QListViewItem* _item) { 959void 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
973void OKeyConfigWidget::slotNoKey() { 984void 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
997void OKeyConfigWidget::slotDefaultKey() { 1009void 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
1020void OKeyConfigWidget::slotCustomKey() { 1033void 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
@@ -135,96 +135,98 @@ private:
135 135
136 136
137 137
138/** 138/**
139 * \brief A manager to load and save Key Actions and get notified 139 * \brief A manager to load and save Key Actions and get notified
140 * This is the Manager for KeyActions. 140 * This is the Manager for KeyActions.
141 * You can say from which config and group to read data, to grab the 141 * You can say from which config and group to read data, to grab the
142 * keyboard to handle hardware keys, you can supply a blacklist of 142 * keyboard to handle hardware keys, you can supply a blacklist of
143 * keys which should not be used by allowed to be used. 143 * keys which should not be used by allowed to be used.
144 * You can even pass this manager to a Widget to do the configuration for you. 144 * You can even pass this manager to a Widget to do the configuration for you.
145 * You need to add OKeyConfigItem for your keys and then issue a load() to 145 * You need to add OKeyConfigItem for your keys and then issue a load() to
146 * read the Key information. 146 * read the Key information.
147 * You can either handle the QKeyEvent yourself and ask this class if it is 147 * You can either handle the QKeyEvent yourself and ask this class if it is
148 * handled by your action and let give you the action. Or you can install 148 * handled by your action and let give you the action. Or you can install
149 * the event filter and get a signal. 149 * the event filter and get a signal.
150 * You need to load ans save yourself! 150 * You need to load ans save yourself!
151 * 151 *
152 * @since 1.1.2 152 * @since 1.1.2
153 */ 153 */
154class OKeyConfigManager : public QObject { 154class OKeyConfigManager : public QObject {
155 Q_OBJECT 155 Q_OBJECT
156 typedef QMap<int, OKeyConfigItem::List> OKeyMapConfigPrivate; 156 typedef QMap<int, OKeyConfigItem::List> OKeyMapConfigPrivate;
157public: 157public:
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;
183signals: 185signals:
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
200private: 202private:
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/**
215 * With this Widget you can let the Keyboard Shortcuts 217 * With this Widget you can let the Keyboard Shortcuts
216 * be configured by the user. 218 * be configured by the user.
217 * There are two ways you can use this widget. Either in a tab were 219 * There are two ways you can use this widget. Either in a tab were
218 * all changes are immediately getting into effect or in a queue 220 * all changes are immediately getting into effect or in a queue
219 * were you ask for saving. Save won't write the data but only set 221 * were you ask for saving. Save won't write the data but only set
220 * it to the OKeyConfigManager 222 * it to the OKeyConfigManager
221 * 223 *
222 * @since 1.2 224 * @since 1.2
223 */ 225 */
224class OKeyConfigWidget : public QWidget { 226class OKeyConfigWidget : public QWidget {
225 Q_OBJECT 227 Q_OBJECT
226 228
227public: 229public:
228 /** 230 /**
229 * Immediate Apply the change directly to the underlying OKeyConfigManager 231 * Immediate Apply the change directly to the underlying OKeyConfigManager
230 * Queue Save all items and then apply when you save() 232 * Queue Save all items and then apply when you save()