summaryrefslogtreecommitdiff
authorzecke <zecke>2004-03-29 01:19:31 (UTC)
committer zecke <zecke>2004-03-29 01:19:31 (UTC)
commite8dd4582051e07a049ae8b3cd04b4463ecc33790 (patch) (unidiff)
treeab7d4d71eb460f0c1afff2d326c0447f5b986814
parent28648c47d06c339ee893f8cef740bae9d54863bf (diff)
downloadopie-e8dd4582051e07a049ae8b3cd04b4463ecc33790.zip
opie-e8dd4582051e07a049ae8b3cd04b4463ecc33790.tar.gz
opie-e8dd4582051e07a049ae8b3cd04b4463ecc33790.tar.bz2
-Bugfixes on compare operator and isEmpty
-Implement saving from the widget to the manager -Fix Ctrl vs Alt mixup Yeah now the user can select between none and default A OKeyChooserDialog will soon be implemented
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opieui/okeyconfigwidget.cpp93
-rw-r--r--libopie2/opieui/okeyconfigwidget.h41
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
@@ -363,2 +363,3 @@ bool OKeyConfigItem::isEmpty()const {
363 if ( !m_text.isEmpty() ) return false; 363 if ( !m_text.isEmpty() ) return false;
364 if ( m_id != -1 ) return false;
364 365
@@ -371,7 +372,9 @@ bool OKeyConfigItem::isEmpty()const {
371bool OKeyConfigItem::operator==( const OKeyConfigItem& conf ) { 372bool 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;
@@ -380,2 +383,4 @@ bool OKeyConfigItem::operator==( const OKeyConfigItem& conf ) {
380 383
384
385
381 return true; 386 return true;
@@ -507,3 +512,5 @@ void OKeyConfigManager::save() {
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()) &&
@@ -511,2 +518,3 @@ void OKeyConfigManager::save() {
511 return; 518 return;
519 */
512 520
@@ -549,5 +557,5 @@ OKeyConfigItem OKeyConfigManager::handleKeyEvent( QKeyEvent* e ) {
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
@@ -588,2 +596,3 @@ 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;
@@ -597,2 +606,3 @@ 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;
@@ -739,3 +749,5 @@ namespace Private {
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
@@ -744,2 +756,3 @@ namespace Private {
744 OKeyConfigItem m_item; 756 OKeyConfigItem m_item;
757 OKeyConfigItem m_origItem;
745 OKeyConfigManager* m_manager; 758 OKeyConfigManager* m_manager;
@@ -750,2 +763,3 @@ namespace Private {
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 );
@@ -756,2 +770,5 @@ namespace Private {
756 } 770 }
771 OKeyConfigItem OKeyListViewItem::origItem() const{
772 return m_origItem;
773 }
757 OKeyConfigManager* OKeyListViewItem::manager() { 774 OKeyConfigManager* OKeyListViewItem::manager() {
@@ -763,4 +780,11 @@ namespace Private {
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 }
@@ -850,2 +874,3 @@ void OKeyConfigWidget::initUi() {
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*)),
@@ -899,4 +924,6 @@ void OKeyConfigWidget::initUi() {
899 924
925 connect(m_btn, SIGNAL(clicked()),
926 this, SLOT(slotConfigure()));
900 927
901 m_box = gr; 928 m_box = box;
902} 929}
@@ -951,2 +978,16 @@ void OKeyConfigWidget::load() {
951void OKeyConfigWidget::save() { 978void 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
@@ -969,2 +1010,3 @@ void OKeyConfigWidget::slotListViewItem( QListViewItem* _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() ) {
@@ -990,3 +1032,3 @@ void OKeyConfigWidget::slotNoKey() {
990 1032
991 if ( !m_view->currentItem() || m_view->currentItem()->parent() ) 1033 if ( !m_view->currentItem() || !m_view->currentItem()->parent() )
992 return; 1034 return;
@@ -1002,2 +1044,3 @@ void OKeyConfigWidget::slotNoKey() {
1002 item->item().setKeyPair( OKeyPair::emptyKey() ); 1044 item->item().setKeyPair( OKeyPair::emptyKey() );
1045 item->updateText();
1003 1046
@@ -1009,9 +1052,8 @@ void OKeyConfigWidget::slotNoKey() {
1009void OKeyConfigWidget::slotDefaultKey() { 1052void 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;
@@ -1027,2 +1069,3 @@ void OKeyConfigWidget::slotDefaultKey() {
1027 item->item().setKeyPair( item->item().defaultKeyPair() ); 1069 item->item().setKeyPair( item->item().defaultKeyPair() );
1070 item->updateText();
1028 1071
@@ -1033,3 +1076,2 @@ void OKeyConfigWidget::slotDefaultKey() {
1033void OKeyConfigWidget::slotCustomKey() { 1076void OKeyConfigWidget::slotCustomKey() {
1034 qWarning( "SlotCustom Key" );
1035 m_cus ->setChecked( true ); 1077 m_cus ->setChecked( true );
@@ -1039,3 +1081,3 @@ void OKeyConfigWidget::slotCustomKey() {
1039 1081
1040 if ( !m_view->currentItem() || m_view->currentItem()->parent() ) 1082 if ( !m_view->currentItem() || !m_view->currentItem()->parent() )
1041 return; 1083 return;
@@ -1044 +1086,24 @@ void OKeyConfigWidget::slotCustomKey() {
1044 1086
1087void OKeyConfigWidget::slotConfigure() {
1088
1089}
1090
1091
1092OKeyChooserConfigDialog::OKeyChooserConfigDialog( QWidget* par, const char* nam,
1093 bool mod, WFlags fl )
1094 : QDialog( par, nam, mod, fl ) {
1095}
1096
1097OKeyChooserConfigDialog::~OKeyChooserConfigDialog() {
1098}
1099
1100Opie::Ui::OKeyPair OKeyChooserConfigDialog::keyPair()const{
1101}
1102
1103void OKeyChooserConfigDialog::keyPressEvent( QKeyEvent* ev ) {
1104 ev->ignore();
1105}
1106
1107void 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
@@ -250,3 +250,3 @@ private slots:
250 void slotCustomKey(); 250 void slotCustomKey();
251 251 void slotConfigure();
252 252
@@ -265,2 +265,41 @@ private:
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 */
284class OKeyChooserConfigDialog : public QDialog {
285 Q_OBJECT
286public:
287 OKeyChooserConfigDialog( QWidget* parent = 0, const char* name = 0, bool modal = false, WFlags fl = 0 );
288 ~OKeyChooserConfigDialog();
289
290 OKeyPair keyPair()const;
291
292protected:
293 void keyPressEvent( QKeyEvent* );
294 void keyReleaseEvent( QKeyEvent* );
295
296signals:
297 void keyCaptured();
298
299private:
300 OKeyPair m_keyPair;
301 class Private;
302 Private *d;
303};
304
266} 305}