summaryrefslogtreecommitdiff
authorzecke <zecke>2004-03-28 20:39:22 (UTC)
committer zecke <zecke>2004-03-28 20:39:22 (UTC)
commitb4c5da4a6cf51753e8d2da505197326e05323d73 (patch) (unidiff)
tree6b9814683e717f8445496dc0d4c8d23eda223dc3
parent4cbd5ad37e51b7bc9c749f8eda2e46a806d904b0 (diff)
downloadopie-b4c5da4a6cf51753e8d2da505197326e05323d73.zip
opie-b4c5da4a6cf51753e8d2da505197326e05323d73.tar.gz
opie-b4c5da4a6cf51753e8d2da505197326e05323d73.tar.bz2
From yesterday. Some sort of GUI loading
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
@@ -529,25 +529,24 @@ OKeyConfigItem OKeyConfigManager::handleKeyEvent( QKeyEvent* e ) {
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;
@@ -598,24 +597,30 @@ 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 */
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/**
@@ -744,29 +749,29 @@ namespace Private {
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() );
@@ -844,25 +849,24 @@ void OKeyConfigWidget::initUi() {
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
@@ -920,25 +924,32 @@ OKeyConfigWidget::ChangeMode OKeyConfigWidget::changeMode()const {
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
@@ -962,69 +973,72 @@ void OKeyConfigWidget::slotListViewItem( QListViewItem* _item) {
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
@@ -171,24 +171,26 @@ public:
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 *