summaryrefslogtreecommitdiff
authorgroucho <groucho>2003-03-19 11:36:34 (UTC)
committer groucho <groucho>2003-03-19 11:36:34 (UTC)
commit28be0fcc9bda71175c3ee17e79fce2ac24340ff2 (patch) (unidiff)
treef09c80460e4f0219eb308d612a2e67df57f2c254
parent18c6c51705de3b1897f671e54b25929e74d11f23 (diff)
downloadopie-28be0fcc9bda71175c3ee17e79fce2ac24340ff2.zip
opie-28be0fcc9bda71175c3ee17e79fce2ac24340ff2.tar.gz
opie-28be0fcc9bda71175c3ee17e79fce2ac24340ff2.tar.bz2
Fixed bug #744 where non mapped buttons in buttonsettings were not saved by introducing the "
ignore" statement. Also removed unsed debug code
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/launcher/desktop.cpp19
-rw-r--r--core/launcher/desktop.h2
-rw-r--r--core/settings/button/buttonsettings.cpp3
-rw-r--r--core/settings/button/buttonutils.cpp3
-rw-r--r--core/settings/button/remapdlg.cpp24
-rw-r--r--libopie/odevice.cpp9
-rw-r--r--libopie/odevicebutton.cpp1
7 files changed, 47 insertions, 14 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp
index 59f2aea..fbcce7c 100644
--- a/core/launcher/desktop.cpp
+++ b/core/launcher/desktop.cpp
@@ -342,25 +342,35 @@ void DesktopApplication::sendHeldAction ( )
342 342
343 343
344 344
345void DesktopApplication::checkButtonAction ( const ODeviceButton *db, int /*keycode*/, bool press, bool autoRepeat ) 345bool DesktopApplication::checkButtonAction ( const ODeviceButton *db, int /*keycode*/, bool press, bool autoRepeat )
346 { 346 {
347 if ( db ) { 347 if ( db ) {
348 if ( !press && !autoRepeat && m_button_timer-> isActive ( )) { 348 if ( !press && !autoRepeat && m_button_timer-> isActive ( )) {
349 m_button_timer-> stop ( ); 349 m_button_timer-> stop ( );
350 if ( !db-> pressedAction ( ). channel ( ). isEmpty ( )) { 350
351 if (!db-> pressedAction ( ). channel ( ) .isEmpty())
352 {
353 if ( db-> pressedAction ( ). channel ( )!="ignore") {
351 db-> pressedAction ( ). send ( ); 354 db-> pressedAction ( ). send ( );
352 } 355 }
356 else return false;
357 }
353 } 358 }
354 else if ( press && !autoRepeat ) { 359 else if ( press && !autoRepeat ) {
355 m_button_timer-> stop ( ); 360 m_button_timer-> stop ( );
361 if (!db-> pressedAction ( ). channel ( ) .isEmpty())
362 {
356 363
357 if ( !db-> heldAction ( ). channel ( ). isEmpty ( )) { 364 if ( db-> heldAction ( ). channel ( )!="ignore") {
358 m_last_button = db; 365 m_last_button = db;
359 m_button_timer-> start ( ODevice::inst ( )-> buttonHoldTime ( ), true ); 366 m_button_timer-> start ( ODevice::inst ( )-> buttonHoldTime ( ), true );
360 } 367 }
368 else return false;
361 } 369 }
362 } 370 }
363} 371}
372 return true;
373}
364 374
365bool DesktopApplication::eventFilter ( QObject *o, QEvent *e ) 375bool DesktopApplication::eventFilter ( QObject *o, QEvent *e )
366{ 376{
@@ -370,8 +380,7 @@ bool DesktopApplication::eventFilter ( QObject *o, QEvent *e )
370 const ODeviceButton *db = ODevice::inst ( )-> buttonForKeycode ( ke-> key ( )); 380 const ODeviceButton *db = ODevice::inst ( )-> buttonForKeycode ( ke-> key ( ));
371 381
372 if ( db ) { 382 if ( db ) {
373 checkButtonAction ( db, ke-> key ( ), e-> type ( ) == QEvent::KeyPress, ke-> isAutoRepeat ( )); 383 return checkButtonAction ( db, ke-> key ( ), e-> type ( ) == QEvent::KeyPress, ke-> isAutoRepeat ( ));
374 return true;
375 } 384 }
376 } 385 }
377 return QPEApplication::eventFilter ( o, e ); 386 return QPEApplication::eventFilter ( o, e );
diff --git a/core/launcher/desktop.h b/core/launcher/desktop.h
index db0173e..4024c38 100644
--- a/core/launcher/desktop.h
+++ b/core/launcher/desktop.h
@@ -83,7 +83,7 @@ protected slots:
83 83
84protected: 84protected:
85 virtual bool eventFilter ( QObject *o, QEvent *e ); 85 virtual bool eventFilter ( QObject *o, QEvent *e );
86 void checkButtonAction ( const Opie::ODeviceButton *db, int keycode, bool press, bool autoRepeat ); 86 bool checkButtonAction ( const Opie::ODeviceButton *db, int keycode, bool press, bool autoRepeat );
87 87
88private: 88private:
89 static DesktopApplication *me ( ); 89 static DesktopApplication *me ( );
diff --git a/core/settings/button/buttonsettings.cpp b/core/settings/button/buttonsettings.cpp
index eabb779..942d5e4 100644
--- a/core/settings/button/buttonsettings.cpp
+++ b/core/settings/button/buttonsettings.cpp
@@ -208,7 +208,6 @@ void ButtonSettings::keyTimeout ( )
208 208
209void ButtonSettings::edit ( buttoninfo *bi, bool hold ) 209void ButtonSettings::edit ( buttoninfo *bi, bool hold )
210{ 210{
211 qDebug ( "remap %s for %s", hold ? "hold" : "press", bi-> m_button-> userText ( ). latin1 ( ));
212 211
213 if ( m_lock ) 212 if ( m_lock )
214 return; 213 return;
@@ -218,7 +217,7 @@ void ButtonSettings::edit ( buttoninfo *bi, bool hold )
218 217
219 d-> showMaximized ( ); 218 d-> showMaximized ( );
220 if ( d-> exec ( ) == QDialog::Accepted ) { 219 if ( d-> exec ( ) == QDialog::Accepted ) {
221 qDebug ( " -> %s %s", d-> message ( ). channel ( ). data ( ), d-> message ( ). message ( ). data ( )); 220
222 221
223 if ( hold ) { 222 if ( hold ) {
224 bi-> m_hmsg = d-> message ( ); 223 bi-> m_hmsg = d-> message ( );
diff --git a/core/settings/button/buttonutils.cpp b/core/settings/button/buttonutils.cpp
index 91d2af3..27a2f38 100644
--- a/core/settings/button/buttonutils.cpp
+++ b/core/settings/button/buttonutils.cpp
@@ -65,7 +65,8 @@ qCopInfo ButtonUtils::messageToInfo ( const OQCopMessage &c )
65 QCString ch = c. channel ( ); 65 QCString ch = c. channel ( );
66 QCString f = c. message ( ); 66 QCString f = c. message ( );
67 67
68 if ( ch. isNull ( )) 68
69 if ( ch == "ignore" )
69 return qCopInfo ( qApp-> translate ( "ButtonSettings", "<nobr>Ignored</nobr>" )); 70 return qCopInfo ( qApp-> translate ( "ButtonSettings", "<nobr>Ignored</nobr>" ));
70 71
71 for ( const predef_qcop *p = predef; p-> m_text; p++ ) { 72 for ( const predef_qcop *p = predef; p-> m_text; p++ ) {
diff --git a/core/settings/button/remapdlg.cpp b/core/settings/button/remapdlg.cpp
index a251bd4..b6ee60b 100644
--- a/core/settings/button/remapdlg.cpp
+++ b/core/settings/button/remapdlg.cpp
@@ -59,7 +59,18 @@ RemapDlg::RemapDlg ( const Opie::ODeviceButton *b, bool hold, QWidget *parent, c
59 m_map_none = new NoSortItem ( w_list, 0, tr( "No mapping" )); 59 m_map_none = new NoSortItem ( w_list, 0, tr( "No mapping" ));
60 m_map_preset = new NoSortItem ( w_list, 1, tr( "Default" ), m_msg_preset. channel ( ), m_msg_preset. message ( )); 60 m_map_preset = new NoSortItem ( w_list, 1, tr( "Default" ), m_msg_preset. channel ( ), m_msg_preset. message ( ));
61 ((NoSortItem *) m_map_preset )-> setDefault ( true ); 61 ((NoSortItem *) m_map_preset )-> setDefault ( true );
62
63 if (m_msg. channel ( ) == "ignore")
64 {
65 m_map_custom = new NoSortItem ( w_list, 2, tr( "Custom" ), m_msg_preset. channel ( ), m_msg_preset. message ( ));
66
67 m_current = m_map_none;
68 }
69 else
70 {
62 m_map_custom = new NoSortItem ( w_list, 2, tr( "Custom" ), m_msg. channel ( ), m_msg. message ( )); 71 m_map_custom = new NoSortItem ( w_list, 2, tr( "Custom" ), m_msg. channel ( ), m_msg. message ( ));
72 m_current = m_map_custom;
73 }
63 74
64 QListViewItem *it = new NoSortItem ( w_list, 3, tr( "Actions" )); 75 QListViewItem *it = new NoSortItem ( w_list, 3, tr( "Actions" ));
65 ButtonUtils::inst ( )-> insertActions ( it ); 76 ButtonUtils::inst ( )-> insertActions ( it );
@@ -67,7 +78,6 @@ RemapDlg::RemapDlg ( const Opie::ODeviceButton *b, bool hold, QWidget *parent, c
67 78
68 m_map_show = new NoSortItem ( w_list, 4, tr( "Show" )); 79 m_map_show = new NoSortItem ( w_list, 4, tr( "Show" ));
69 80
70 m_current = m_map_custom;
71 w_list-> setCurrentItem ( m_current ); 81 w_list-> setCurrentItem ( m_current );
72 82
73 QTimer::singleShot ( 0, this, SLOT( delayedInit ( ))); 83 QTimer::singleShot ( 0, this, SLOT( delayedInit ( )));
@@ -97,10 +107,18 @@ void RemapDlg::itemChanged ( QListViewItem *it )
97 m_current = it; 107 m_current = it;
98 108
99 if ( it == m_map_none ) 109 if ( it == m_map_none )
100 m_msg = m = OQCopMessage ( 0, 0 ); 110 {
111 m_msg = m = OQCopMessage ( "ignore", 0 );
112 qDebug ("***ignoring");
113 }
101 else if ( it == m_map_preset ) 114 else if ( it == m_map_preset )
115 {
102 m_msg = m = m_msg_preset; 116 m_msg = m = m_msg_preset;
103 else if ( it && !it-> childCount ( )) { 117 qDebug ("***Preset");
118 }
119 else if ( it && !it-> childCount ( ))
120 {
121 qDebug ("***Custom: %s %s ",it-> text ( 1 ). latin1 ( ), it-> text ( 2 ). latin1 ( ));
104 enabled = ( it == m_map_custom ); 122 enabled = ( it == m_map_custom );
105 m_msg = m = OQCopMessage ( it-> text ( 1 ). latin1 ( ), it-> text ( 2 ). latin1 ( )); 123 m_msg = m = OQCopMessage ( it-> text ( 1 ). latin1 ( ), it-> text ( 2 ). latin1 ( ));
106 } 124 }
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 9e97c56..d5e3c5c 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -280,7 +280,6 @@ void ODevice::init ( )
280 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 280 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
281 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); 281 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
282 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); 282 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
283
284 d-> m_buttons. append ( b ); 283 d-> m_buttons. append ( b );
285 } 284 }
286 } 285 }
@@ -518,21 +517,27 @@ void ODevice::reloadButtonMapping ( )
518 } 517 }
519 518
520 b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); 519 b. setPressedAction ( OQCopMessage ( pch, pm, pdata ));
520
521 b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); 521 b. setHeldAction ( OQCopMessage ( hch, hm, hdata ));
522 } 522 }
523} 523}
524 524
525void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) 525void ODevice::remapPressedAction ( int button, const OQCopMessage &action )
526{ 526{
527 QString mb_chan;
528
527 if ( button >= (int) d-> m_buttons. count ( )) 529 if ( button >= (int) d-> m_buttons. count ( ))
528 return; 530 return;
529 531
532
530 ODeviceButton &b = d-> m_buttons [button]; 533 ODeviceButton &b = d-> m_buttons [button];
531 b. setPressedAction ( action ); 534 b. setPressedAction ( action );
532 535
536 mb_chan=b. pressedAction ( ). channel ( );
537
533 Config buttonFile ( "ButtonSettings" ); 538 Config buttonFile ( "ButtonSettings" );
534 buttonFile. setGroup ( "Button" + QString::number ( button )); 539 buttonFile. setGroup ( "Button" + QString::number ( button ));
535 buttonFile. writeEntry ( "PressedActionChannel", (const char*) b. pressedAction ( ). channel ( )); 540 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan);
536 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); 541 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( ));
537 542
538 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); 543 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( )));
diff --git a/libopie/odevicebutton.cpp b/libopie/odevicebutton.cpp
index 2270343..4b22358 100644
--- a/libopie/odevicebutton.cpp
+++ b/libopie/odevicebutton.cpp
@@ -218,6 +218,7 @@ void ODeviceButton::setFactoryPresetPressedAction(const OQCopMessage& action)
218 m_FactoryPresetPressedAction = action; 218 m_FactoryPresetPressedAction = action;
219} 219}
220 220
221
221void ODeviceButton::setPressedAction(const OQCopMessage& action) 222void ODeviceButton::setPressedAction(const OQCopMessage& action)
222{ 223{
223 m_PressedAction = action; 224 m_PressedAction = action;