summaryrefslogtreecommitdiff
authorzecke <zecke>2004-04-01 21:01:32 (UTC)
committer zecke <zecke>2004-04-01 21:01:32 (UTC)
commitd6c90e60dbc0a5bfd0bb2176a652ca7664a2a4b0 (patch) (unidiff)
treee387a69279d4417b4436634691f5cde2e503253f
parent1196811eb5fd6f4894b36bbebf81a8eca494f786 (diff)
downloadopie-d6c90e60dbc0a5bfd0bb2176a652ca7664a2a4b0.zip
opie-d6c90e60dbc0a5bfd0bb2176a652ca7664a2a4b0.tar.gz
opie-d6c90e60dbc0a5bfd0bb2176a652ca7664a2a4b0.tar.bz2
Unbelievable this widget is done and can be used now
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opieui/okeyconfigwidget.cpp73
-rw-r--r--libopie2/opieui/okeyconfigwidget.h10
2 files changed, 60 insertions, 23 deletions
diff --git a/libopie2/opieui/okeyconfigwidget.cpp b/libopie2/opieui/okeyconfigwidget.cpp
index 3e08416..8967d77 100644
--- a/libopie2/opieui/okeyconfigwidget.cpp
+++ b/libopie2/opieui/okeyconfigwidget.cpp
@@ -8,3 +8,3 @@
8#include <qbuttongroup.h> 8#include <qbuttongroup.h>
9 9#include <qmessagebox.h>
10#include <qaccel.h> 10#include <qaccel.h>
@@ -12,2 +12,4 @@
12#include <qlabel.h> 12#include <qlabel.h>
13
14/* non gui */
13#include <qtimer.h> 15#include <qtimer.h>
@@ -161,3 +163,3 @@ OKeyPair::List OKeyPair::hardwareKeys() {
161 */ 163 */
162bool OKeyPair::operator==( const OKeyPair& pair) { 164bool OKeyPair::operator==( const OKeyPair& pair)const {
163 if ( m_key != pair.m_key ) return false; 165 if ( m_key != pair.m_key ) return false;
@@ -171,3 +173,3 @@ bool OKeyPair::operator==( const OKeyPair& pair) {
171 */ 173 */
172bool OKeyPair::operator!=( const OKeyPair& pair) { 174bool OKeyPair::operator!=( const OKeyPair& pair)const {
173 return !(*this == pair); 175 return !(*this == pair);
@@ -373,3 +375,3 @@ bool OKeyConfigItem::isEmpty()const {
373 */ 375 */
374bool OKeyConfigItem::operator==( const OKeyConfigItem& conf ) { 376bool OKeyConfigItem::operator==( const OKeyConfigItem& conf )const {
375/* if ( isEmpty() == conf.isEmpty() ) return true; 377/* if ( isEmpty() == conf.isEmpty() ) return true;
@@ -391,3 +393,3 @@ bool OKeyConfigItem::operator==( const OKeyConfigItem& conf ) {
391 393
392bool OKeyConfigItem::operator!=( const OKeyConfigItem& conf ) { 394bool OKeyConfigItem::operator!=( const OKeyConfigItem& conf )const {
393 return !( *this == conf ); 395 return !( *this == conf );
@@ -485,4 +487,3 @@ void OKeyConfigManager::load() {
485 int key, mod; 487 int key, mod;
486 for( OKeyConfigItem::List::Iterator it = m_keys.begin(); 488 for( OKeyConfigItem::List::Iterator it = m_keys.begin(); it != m_keys.end(); ++it ) {
487 it != m_keys.end(); ++it ) {
488 key = m_conf->readNumEntry( (*it).configKey()+"key", (*it).defaultKeyPair().keycode() ); 489 key = m_conf->readNumEntry( (*it).configKey()+"key", (*it).defaultKeyPair().keycode() );
@@ -490,2 +491,3 @@ void OKeyConfigManager::load() {
490 OKeyPair okey( key, mod ); 491 OKeyPair okey( key, mod );
492
491 if ( !m_blackKeys.contains( okey ) && key != -1 && mod != -1 ) 493 if ( !m_blackKeys.contains( okey ) && key != -1 && mod != -1 )
@@ -508,4 +510,4 @@ void OKeyConfigManager::save() {
508 */ 510 */
509 for( OKeyConfigItem::List::Iterator it = m_keys.begin(); 511 for( OKeyConfigItem::List::Iterator it = m_keys.begin();it != m_keys.end(); ++it ) {
510 it != m_keys.end(); ++it ) { 512 /* skip empty items */
511 if ( (*it).isEmpty() ) 513 if ( (*it).isEmpty() )
@@ -516,3 +518,3 @@ void OKeyConfigManager::save() {
516 * don't write if it is the default setting 518 * don't write if it is the default setting
517 * FIXME allow to remove Keys 519 * FIXME allow to remove Keys from config
518 if ( (pair.keycode() == deft.keycode()) && 520 if ( (pair.keycode() == deft.keycode()) &&
@@ -578,3 +580,2 @@ void OKeyConfigManager::addKeyConfig( const OKeyConfigItem& item ) {
578 m_keys.append( item ); 580 m_keys.append( item );
579 qWarning( "m_keys count is now %d", m_keys.count() );
580 delete m_map; m_map = 0; 581 delete m_map; m_map = 0;
@@ -588,3 +589,2 @@ void OKeyConfigManager::removeKeyConfig( const OKeyConfigItem& item ) {
588 m_keys.remove( item ); 589 m_keys.remove( item );
589 qWarning( "m_keys count is now %d", m_keys.count() );
590 delete m_map; m_map = 0; 590 delete m_map; m_map = 0;
@@ -762,2 +762,5 @@ namespace Private {
762 762
763 /*
764 * the virtual and hardware key events have both issues...
765 */
763 void fixupKeys( int& key, int &mod, QKeyEvent* e ) { 766 void fixupKeys( int& key, int &mod, QKeyEvent* e ) {
@@ -1010,3 +1013,2 @@ void OKeyConfigWidget::slotListViewItem( QListViewItem* _item) {
1010void OKeyConfigWidget::slotNoKey() { 1013void OKeyConfigWidget::slotNoKey() {
1011 qWarning( "No Key" );
1012 m_none->setChecked( true ); 1014 m_none->setChecked( true );
@@ -1070,2 +1072,35 @@ void OKeyConfigWidget::slotConfigure() {
1070 1072
1073bool OKeyConfigWidget::sanityCheck( Opie::Ui::Private::OKeyListViewItem* item,
1074 const OKeyPair& newItem ) {
1075 OKeyPair::List bList = item->manager()->blackList();
1076 for ( OKeyPair::List::Iterator it = bList.begin(); it != bList.end(); ++it ) {
1077 /* black list matched */
1078 if ( *it == newItem ) {
1079 QMessageBox::warning( 0, tr("Key is on BlackList" ),
1080 tr("<qt>The Key you choose is on the black list "
1081 "and may not be used with this manager. Please "
1082 "use a different key.</qt>" ) );
1083 return false;
1084 }
1085 }
1086 /* no we need to check the other items which is dog slow */
1087 QListViewItemIterator it( item->parent() );
1088 while ( it.current() ) {
1089 /* if not our parent and not us */
1090 if (it.current()->parent() && it.current() != item) {
1091 /* damn already given away*/
1092 if ( newItem == static_cast<Opie::Ui::Private::OKeyListViewItem*>(it.current() )->item().keyPair() ) {
1093 QMessageBox::warning( 0, tr("Key is already assigned" ),
1094 tr("<qt>The Key you choose is already taken by "
1095 "a different Item of your config. Please try"
1096 "using a different key.</qt>" ) );
1097 return false;
1098 }
1099 }
1100 ++it;
1101 }
1102
1103 return true;
1104}
1105
1071void OKeyConfigWidget::updateItem( Opie::Ui::Private::OKeyListViewItem *item, 1106void OKeyConfigWidget::updateItem( Opie::Ui::Private::OKeyListViewItem *item,
@@ -1076,5 +1111,6 @@ void OKeyConfigWidget::updateItem( Opie::Ui::Private::OKeyListViewItem *item,
1076 */ 1111 */
1077 if ( !newItem.isEmpty() ) { 1112 if ( !newItem.isEmpty() && !sanityCheck(item, newItem ))
1113 return;
1114
1078 1115
1079 }
1080 1116
@@ -1130,3 +1166,2 @@ void OKeyChooserConfigDialog::keyPressEvent( QKeyEvent* ev ) {
1130 1166
1131 qWarning( "Key Press Event" );
1132 int mod, key; 1167 int mod, key;
@@ -1155,5 +1190,5 @@ void OKeyChooserConfigDialog::keyPressEvent( QKeyEvent* ev ) {
1155 } 1190 }
1156 if (mod ) { 1191 if (mod )
1157 m_mod |= mod; 1192 m_mod |= mod;
1158 }else 1193 else
1159 m_key = key; 1194 m_key = key;
@@ -1161,3 +1196,3 @@ void OKeyChooserConfigDialog::keyPressEvent( QKeyEvent* ev ) {
1161 if ( ( !mod || m_key ) && !m_timer->isActive() ) 1196 if ( ( !mod || m_key ) && !m_timer->isActive() )
1162 m_timer->start( 50, true ); 1197 m_timer->start( 150, true );
1163 1198
diff --git a/libopie2/opieui/okeyconfigwidget.h b/libopie2/opieui/okeyconfigwidget.h
index 9e26719..f75ed99 100644
--- a/libopie2/opieui/okeyconfigwidget.h
+++ b/libopie2/opieui/okeyconfigwidget.h
@@ -51,4 +51,4 @@ public:
51 51
52 bool operator==( const OKeyPair& ); 52 bool operator==( const OKeyPair& )const;
53 bool operator!=( const OKeyPair& ); 53 bool operator!=( const OKeyPair& )const;
54 54
@@ -97,4 +97,4 @@ public:
97 97
98 bool operator==( const OKeyConfigItem& ); 98 bool operator==( const OKeyConfigItem& )const;
99 bool operator!=( const OKeyConfigItem& ); 99 bool operator!=( const OKeyConfigItem& )const;
100 100
@@ -255,2 +255,4 @@ private slots:
255private: 255private:
256 static bool sanityCheck( Opie::Ui::Private::OKeyListViewItem* man,
257 const OKeyPair& newItem );
256 void updateItem( Opie::Ui::Private::OKeyListViewItem* man, 258 void updateItem( Opie::Ui::Private::OKeyListViewItem* man,