author | groucho <groucho> | 2003-03-19 11:36:34 (UTC) |
---|---|---|
committer | groucho <groucho> | 2003-03-19 11:36:34 (UTC) |
commit | 28be0fcc9bda71175c3ee17e79fce2ac24340ff2 (patch) (side-by-side diff) | |
tree | f09c80460e4f0219eb308d612a2e67df57f2c254 | |
parent | 18c6c51705de3b1897f671e54b25929e74d11f23 (diff) | |
download | opie-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
-rw-r--r-- | core/launcher/desktop.cpp | 25 | ||||
-rw-r--r-- | core/launcher/desktop.h | 2 | ||||
-rw-r--r-- | core/settings/button/buttonsettings.cpp | 3 | ||||
-rw-r--r-- | core/settings/button/buttonutils.cpp | 3 | ||||
-rw-r--r-- | core/settings/button/remapdlg.cpp | 26 | ||||
-rw-r--r-- | libopie/odevice.cpp | 15 | ||||
-rw-r--r-- | libopie/odevicebutton.cpp | 3 |
7 files changed, 55 insertions, 22 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 @@ -321,78 +321,87 @@ void DesktopApplication::launcherMessage( const QCString & msg, const QByteArray const ODeviceButton *db = ODevice::inst ( )-> buttonForKeycode ( keycode ); if ( db ) checkButtonAction ( db, keycode, press, autoRepeat ); } else if ( msg == "keyRegister(int,QCString,QCString)" ) { int k; QCString c, m; stream >> k >> c >> m; keyRegisterList.append ( QCopKeyRegister ( k, c, m )); } } void DesktopApplication::sendHeldAction ( ) { if ( m_last_button ) { m_last_button-> heldAction ( ). send ( ); m_last_button = 0; } } -void DesktopApplication::checkButtonAction ( const ODeviceButton *db, int /*keycode*/, bool press, bool autoRepeat ) +bool DesktopApplication::checkButtonAction ( const ODeviceButton *db, int /*keycode*/, bool press, bool autoRepeat ) { if ( db ) { if ( !press && !autoRepeat && m_button_timer-> isActive ( )) { m_button_timer-> stop ( ); - if ( !db-> pressedAction ( ). channel ( ). isEmpty ( )) { - db-> pressedAction ( ). send ( ); + + if (!db-> pressedAction ( ). channel ( ) .isEmpty()) + { + if ( db-> pressedAction ( ). channel ( )!="ignore") { + db-> pressedAction ( ). send ( ); + } + else return false; } } else if ( press && !autoRepeat ) { m_button_timer-> stop ( ); + if (!db-> pressedAction ( ). channel ( ) .isEmpty()) + { - if ( !db-> heldAction ( ). channel ( ). isEmpty ( )) { - m_last_button = db; - m_button_timer-> start ( ODevice::inst ( )-> buttonHoldTime ( ), true ); + if ( db-> heldAction ( ). channel ( )!="ignore") { + m_last_button = db; + m_button_timer-> start ( ODevice::inst ( )-> buttonHoldTime ( ), true ); + } + else return false; } } } + return true; } bool DesktopApplication::eventFilter ( QObject *o, QEvent *e ) { if ( e-> type ( ) == QEvent::KeyPress || e-> type ( ) == QEvent::KeyRelease ) { QKeyEvent *ke = (QKeyEvent *) e; const ODeviceButton *db = ODevice::inst ( )-> buttonForKeycode ( ke-> key ( )); if ( db ) { - checkButtonAction ( db, ke-> key ( ), e-> type ( ) == QEvent::KeyPress, ke-> isAutoRepeat ( )); - return true; + return checkButtonAction ( db, ke-> key ( ), e-> type ( ) == QEvent::KeyPress, ke-> isAutoRepeat ( )); } } return QPEApplication::eventFilter ( o, e ); } #ifdef Q_WS_QWS bool DesktopApplication::qwsEventFilter( QWSEvent *e ) { qpedesktop->checkMemory(); if ( e->type == QWSEvent::Key ) { QWSKeyEvent * ke = (QWSKeyEvent *) e; ushort keycode = ke-> simpleData. keycode; if ( !loggedin && keycode != Key_F34 ) return true; bool press = ke-> simpleData. is_press; bool autoRepeat = ke-> simpleData. is_auto_repeat; if ( !keyboardGrabbed ( )) { // app that registers key/message to be sent back to the app, when it doesn't have focus, // when user presses key, unless keyboard has been requested from app. 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 @@ -62,49 +62,49 @@ signals: void capsLockStateToggle(); void prepareForRestart(); protected: #ifdef Q_WS_QWS bool qwsEventFilter( QWSEvent * ); #endif void shutdown(); void restart(); public slots: virtual void systemMessage ( const QCString &msg, const QByteArray &data ); virtual void launcherMessage ( const QCString &msg, const QByteArray &data ); void rereadVolumes(); protected slots: void shutdown ( ShutdownImpl::Type ); void apmTimeout ( ); void sendHeldAction ( ); protected: virtual bool eventFilter ( QObject *o, QEvent *e ); - void checkButtonAction ( const Opie::ODeviceButton *db, int keycode, bool press, bool autoRepeat ); + bool checkButtonAction ( const Opie::ODeviceButton *db, int keycode, bool press, bool autoRepeat ); private: static DesktopApplication *me ( ); private: void reloadPowerWarnSettings(); DesktopPowerAlerter *pa; PowerStatus *m_ps, *m_ps_last; QTimer *cardSendTimer; QCopChannel *channel; OpieScreenSaver *m_screensaver; QTimer * m_apm_timer; int m_powerVeryLow; int m_powerCritical; int m_currentPowerLevel; const Opie::ODeviceButton *m_last_button; QTimer *m_button_timer; bool m_keyclick_sound : 1; bool m_screentap_sound : 1; bool m_alarm_sound : 1; }; 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 @@ -187,59 +187,58 @@ void ButtonSettings::keyPressEvent ( QKeyEvent *e ) } void ButtonSettings::keyReleaseEvent ( QKeyEvent *e ) { buttoninfo *bi = buttonInfoForKeycode ( e-> key ( )); if ( bi && !e-> isAutoRepeat ( ) && m_timer-> isActive ( )) { m_timer-> stop ( ); edit ( bi, false ); } else QDialog::keyReleaseEvent ( e ); } void ButtonSettings::keyTimeout ( ) { if ( m_last_button ) { edit ( m_last_button, true ); m_last_button = false; } } void ButtonSettings::edit ( buttoninfo *bi, bool hold ) { - qDebug ( "remap %s for %s", hold ? "hold" : "press", bi-> m_button-> userText ( ). latin1 ( )); if ( m_lock ) return; m_lock = true; RemapDlg *d = new RemapDlg ( bi-> m_button, hold, this ); d-> showMaximized ( ); if ( d-> exec ( ) == QDialog::Accepted ) { - qDebug ( " -> %s %s", d-> message ( ). channel ( ). data ( ), d-> message ( ). message ( ). data ( )); + if ( hold ) { bi-> m_hmsg = d-> message ( ); bi-> m_hdirty = true; } else { bi-> m_pmsg = d-> message ( ); bi-> m_pdirty = true; } updateLabels ( ); } delete d; m_lock = false; } void ButtonSettings::accept ( ) { for ( QListIterator <buttoninfo> it ( m_infos ); *it; ++it ) { buttoninfo *bi = *it; if ( bi-> m_pdirty ) 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 @@ -44,49 +44,50 @@ ButtonUtils *ButtonUtils::ButtonUtils::inst ( ) } return p; } void ButtonUtils::cleanup ( ) { delete inst ( ); } ButtonUtils::ButtonUtils ( ) { m_apps = new AppLnkSet( MimeType::appsFolderName ( )); } ButtonUtils::~ButtonUtils ( ) { delete m_apps; } qCopInfo ButtonUtils::messageToInfo ( const OQCopMessage &c ) { QCString ch = c. channel ( ); QCString f = c. message ( ); - if ( ch. isNull ( )) + + if ( ch == "ignore" ) return qCopInfo ( qApp-> translate ( "ButtonSettings", "<nobr>Ignored</nobr>" )); for ( const predef_qcop *p = predef; p-> m_text; p++ ) { if (( ch == p-> m_channel ) && ( f == p-> m_function )) return qCopInfo ( qApp-> translate ( "ButtonSettings", p-> m_text ), Resource::loadPixmap ( p-> m_pixmap )); } if ( ch. left ( 16 ) == "QPE/Application/" ) { QString app = ch. mid ( 16 ); const AppLnk *applnk = m_apps-> findExec ( app ); if ( applnk ) app = applnk-> name ( ); if (( f == "raise()" ) || ( f == "nextView()" )) return qCopInfo ( qApp-> translate ( "ButtonSettings", "<nobr>Show <b>%1</b></nobr>" ). arg ( app ), applnk ? applnk-> pixmap ( ) : QPixmap ( )); else return qCopInfo ( qApp-> translate ( "ButtonSettings", "<nobr>Call <b>%1</b>: <i>%2</i></nobr>" ). arg ( app ). arg ( f ), applnk ? applnk-> pixmap ( ) : QPixmap ( )); } else { return qCopInfo ( qApp-> translate ( "ButtonSettings", "<nobr>Call <b>%1</b> <i>%2</i></nobr>" ). arg (( ch. left ( 4 ) == "QPE/" ) ? ch. mid ( 4 ) : ch ). arg ( f )); } } 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 @@ -38,90 +38,108 @@ public: } private: QString m_key; bool m_def; }; RemapDlg::RemapDlg ( const Opie::ODeviceButton *b, bool hold, QWidget *parent, const char *name ) : RemapDlgBase ( parent, name, true, WStyle_ContextHelp ) { setCaption ( tr( "%1 %2", "(hold|press) buttoname" ). arg( hold ? tr( "Held" ) : tr( "Pressed" )). arg ( b-> userText ( ))); m_current = 0; static const char * const def_channels [] = { "QPE/Application/", "QPE/Launcher", "QPE/System", "QPE/TaskBar", "QPE/", 0 }; w_channel-> insertStrList ((const char **) def_channels ); m_msg = hold ? b-> heldAction ( ) : b-> pressedAction ( ); m_msg_preset = hold ? b-> factoryPresetHeldAction ( ) : b-> factoryPresetPressedAction ( ); m_map_none = new NoSortItem ( w_list, 0, tr( "No mapping" )); m_map_preset = new NoSortItem ( w_list, 1, tr( "Default" ), m_msg_preset. channel ( ), m_msg_preset. message ( )); ((NoSortItem *) m_map_preset )-> setDefault ( true ); - m_map_custom = new NoSortItem ( w_list, 2, tr( "Custom" ), m_msg. channel ( ), m_msg. message ( )); + + if (m_msg. channel ( ) == "ignore") + { + m_map_custom = new NoSortItem ( w_list, 2, tr( "Custom" ), m_msg_preset. channel ( ), m_msg_preset. message ( )); + + m_current = m_map_none; + } + else + { + m_map_custom = new NoSortItem ( w_list, 2, tr( "Custom" ), m_msg. channel ( ), m_msg. message ( )); + m_current = m_map_custom; + } QListViewItem *it = new NoSortItem ( w_list, 3, tr( "Actions" )); ButtonUtils::inst ( )-> insertActions ( it ); it-> setOpen ( true ); m_map_show = new NoSortItem ( w_list, 4, tr( "Show" )); - m_current = m_map_custom; w_list-> setCurrentItem ( m_current ); QTimer::singleShot ( 0, this, SLOT( delayedInit ( ))); } RemapDlg::~RemapDlg ( ) { } void RemapDlg::delayedInit ( ) { bool b = w_list-> viewport ( )-> isUpdatesEnabled ( ); w_list-> viewport ( )-> setUpdatesEnabled ( false ); ButtonUtils::inst ( )-> insertAppLnks ( m_map_show ); w_list-> viewport ( )-> setUpdatesEnabled ( b ); m_map_show-> repaint ( ); } void RemapDlg::itemChanged ( QListViewItem *it ) { bool enabled = false; OQCopMessage m; m_current = it; if ( it == m_map_none ) - m_msg = m = OQCopMessage ( 0, 0 ); + { + m_msg = m = OQCopMessage ( "ignore", 0 ); + qDebug ("***ignoring"); + } else if ( it == m_map_preset ) + { m_msg = m = m_msg_preset; - else if ( it && !it-> childCount ( )) { + qDebug ("***Preset"); + } + else if ( it && !it-> childCount ( )) + { + qDebug ("***Custom: %s %s ",it-> text ( 1 ). latin1 ( ), it-> text ( 2 ). latin1 ( )); enabled = ( it == m_map_custom ); m_msg = m = OQCopMessage ( it-> text ( 1 ). latin1 ( ), it-> text ( 2 ). latin1 ( )); } w_channel-> setEnabled ( enabled ); w_message-> setEnabled ( enabled ); w_channel-> setEditText ( m. channel ( )); w_message-> setEditText ( m. message ( )); } void RemapDlg::textChanged ( const QString &str ) { if ( !m_current ) return; QComboBox *which = (QComboBox *) sender ( ); if ( which == w_channel ) m_current-> setText ( 1, str ); else if ( which == w_message ) m_current-> setText ( 2, str ); } diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 9e97c56..d5e3c5c 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp @@ -259,49 +259,48 @@ ODevice::ODevice ( ) connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); } void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) { if ( msg == "deviceButtonMappingChanged()" ) { reloadButtonMapping ( ); } } void ODevice::init ( ) { // Simulation uses iPAQ 3660 device buttons for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { i_button *ib = ipaq_buttons + i; ODeviceButton b; if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { b. setKeycode ( ib-> code ); b. setUserText ( qApp-> translate ( "Button", ib-> utext )); b. setPixmap ( Resource::loadPixmap ( ib-> pix )); b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); - d-> m_buttons. append ( b ); } } reloadButtonMapping ( ); } ODevice::~ODevice ( ) { delete d; } bool ODevice::setSoftSuspend ( bool /*soft*/ ) { return false; } //#include <linux/apm_bios.h> #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) bool ODevice::suspend ( ) { if ( !d-> m_qwsserver ) // only qwsserver is allowed to suspend @@ -495,79 +494,85 @@ const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) } void ODevice::reloadButtonMapping ( ) { Config cfg ( "ButtonSettings" ); for ( uint i = 0; i < d-> m_buttons. count ( ); i++ ) { ODeviceButton &b = d-> m_buttons [i]; QString group = "Button" + QString::number ( i ); QCString pch, hch; QCString pm, hm; QByteArray pdata, hdata; if ( cfg. hasGroup ( group )) { cfg. setGroup ( group ); pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); } - + b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); + b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); } } void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) { + QString mb_chan; + if ( button >= (int) d-> m_buttons. count ( )) return; + ODeviceButton &b = d-> m_buttons [button]; - b. setPressedAction ( action ); + b. setPressedAction ( action ); + + mb_chan=b. pressedAction ( ). channel ( ); Config buttonFile ( "ButtonSettings" ); buttonFile. setGroup ( "Button" + QString::number ( button )); - buttonFile. writeEntry ( "PressedActionChannel", (const char*) b. pressedAction ( ). channel ( )); + buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); // buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); } void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) { if ( button >= (int) d-> m_buttons. count ( )) return; ODeviceButton &b = d-> m_buttons [button]; - b. setHeldAction ( action ); + b. setHeldAction ( action ); Config buttonFile ( "ButtonSettings" ); buttonFile. setGroup ( "Button" + QString::number ( button )); buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); // buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); } /************************************************** * * iPAQ * **************************************************/ void iPAQ::init ( ) { d-> m_vendorstr = "HP"; d-> m_vendor = Vendor_HP; diff --git a/libopie/odevicebutton.cpp b/libopie/odevicebutton.cpp index 2270343..4b22358 100644 --- a/libopie/odevicebutton.cpp +++ b/libopie/odevicebutton.cpp @@ -49,49 +49,49 @@ OQCopMessage::OQCopMessage ( const OQCopMessage © ) OQCopMessage &OQCopMessage::operator = ( const OQCopMessage &assign ) { init ( assign. channel ( ), assign. message ( ), assign. data ( )); return *this; } OQCopMessage::OQCopMessage ( const QCString &ch, const QCString &m, const QByteArray &arg ) : d ( 0 ) { init ( ch, m, arg ); } void OQCopMessage::init ( const QCString &ch, const QCString &m, const QByteArray &arg ) { if ( !d ) d = new OQCopMessageData ( ); d-> m_channel = ch; d-> m_message = m; d-> m_data = arg; } bool OQCopMessage::send ( ) { - if ( d-> m_channel. isEmpty ( ) || d-> m_message. isEmpty ( )) + if ( d-> m_channel. isEmpty ( ) || d-> m_message. isEmpty ( ) ) return false; QCopEnvelope e ( d-> m_channel, d-> m_message ); if ( d-> m_data. size ( )) e. writeRawBytes ( d-> m_data. data ( ), d-> m_data. size ( )); return true; } QCString OQCopMessage::channel ( ) const { return d-> m_channel; } QCString OQCopMessage::message ( ) const { return d-> m_message; } QByteArray OQCopMessage::data ( ) const { return d-> m_data; } @@ -197,38 +197,39 @@ OQCopMessage ODeviceButton::heldAction() const return factoryPresetHeldAction(); return m_HeldAction; } void ODeviceButton::setKeycode(ushort keycode) { m_Keycode = keycode; } void ODeviceButton::setUserText(const QString& text) { m_UserText = text; } void ODeviceButton::setPixmap(const QPixmap& picture) { m_Pixmap = picture; } void ODeviceButton::setFactoryPresetPressedAction(const OQCopMessage& action) { m_FactoryPresetPressedAction = action; } + void ODeviceButton::setPressedAction(const OQCopMessage& action) { m_PressedAction = action; } void ODeviceButton::setFactoryPresetHeldAction(const OQCopMessage& action) { m_FactoryPresetHeldAction = action; } void ODeviceButton::setHeldAction(const OQCopMessage& action) { m_HeldAction = action; } |