-rw-r--r-- | core/launcher/desktop.cpp | 19 | ||||
-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 | 24 | ||||
-rw-r--r-- | libopie/odevice.cpp | 9 | ||||
-rw-r--r-- | libopie/odevicebutton.cpp | 1 |
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 @@ -249,222 +249,231 @@ void DesktopApplication::systemMessage( const QCString & msg, const QByteArray & QDataStream stream ( data, IO_ReadOnly ); if ( msg == "setScreenSaverInterval(int)" ) { int time; stream >> time; m_screensaver-> setInterval( time ); } else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { int t1, t2, t3; stream >> t1 >> t2 >> t3; m_screensaver-> setIntervals( t1, t2, t3 ); } else if ( msg == "setBacklight(int)" ) { int bright; stream >> bright; m_screensaver-> setBacklight( bright ); } else if ( msg == "setScreenSaverMode(int)" ) { int mode; stream >> mode; m_screensaver-> setMode ( mode ); } else if ( msg == "reloadPowerWarnSettings()" ) { reloadPowerWarnSettings(); } else if ( msg == "setDisplayState(int)" ) { int state; stream >> state; m_screensaver-> setDisplayState ( state != 0 ); } else if ( msg == "suspend()" ) { emit power(); } else if ( msg == "sendBusinessCard()" ) { QString card = ::getenv ( "HOME" ); card += "/Applications/addressbook/businesscard.vcf"; if ( QFile::exists( card ) ) { QCopEnvelope e ( "QPE/Obex", "send(QString,QString,QString)" ); QString mimetype = "text/x-vCard"; e << tr( "business card" ) << card << mimetype; } } } void DesktopApplication::reloadPowerWarnSettings ( ) { Config cfg ( "apm" ); cfg. setGroup ( "Warnings" ); int iv = cfg. readNumEntry ( "checkinterval", 10000 ); m_apm_timer-> stop ( ); if ( iv ) m_apm_timer-> start ( iv ); m_powerVeryLow = cfg. readNumEntry ( "powerverylow", 10 ); m_powerCritical = cfg. readNumEntry ( "powervcritical", 5 ); } enum MemState { Unknown, VeryLow, Low, Normal } memstate = Unknown; void DesktopApplication::launcherMessage( const QCString & msg, const QByteArray & data ) { QDataStream stream ( data, IO_ReadOnly ); if ( msg == "deviceButton(int,int,int)" ) { int keycode, press, autoRepeat; stream >> keycode >> press >> autoRepeat; 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 ( )) { + + 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 ( )) { + 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. // will not send multiple repeats if user holds key // i.e. one shot if ( keycode != 0 && press && !autoRepeat ) { for ( KeyRegisterList::Iterator it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) { if (( *it ). getKeyCode ( ) == keycode ) { QCopEnvelope (( *it ). getChannel ( ), ( *it ). getMessage ( )); return true; } } } } if ( keycode == HardKey_Suspend ) { if ( press ) emit power ( ); return true; } else if ( keycode == HardKey_Backlight ) { if ( press ) emit backlight ( ); return true; } else if ( keycode == Key_F32 ) { if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); return true; } else if ( keycode == Key_F31 && !ke-> simpleData. modifiers ) { // Symbol Key -> show Unicode IM if ( press ) emit symbol ( ); return true; } else if ( keycode == Key_NumLock ) { if ( press ) emit numLockStateToggle ( ); } else if ( keycode == Key_CapsLock ) { if ( press ) emit capsLockStateToggle(); } if (( press && !autoRepeat ) || ( !press && autoRepeat )) { if ( m_keyclick_sound ) ODevice::inst ( )-> keySound ( ); } } else if ( e-> type == QWSEvent::Mouse ) { QWSMouseEvent * me = ( QWSMouseEvent * ) e; static bool up = true; if ( me-> simpleData. state & LeftButton ) { if ( up ) { up = false; if ( m_screentap_sound ) ODevice::inst ( ) -> touchSound ( ); } } else { up = true; } } return QPEApplication::qwsEventFilter ( e ); } #endif #if defined(QPE_HAVE_MEMALERTER) QPE_MEMALERTER_IMPL #endif 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 @@ -1,155 +1,155 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #ifndef __DESKTOP_H__ #define __DESKTOP_H__ #include "shutdownimpl.h" #include <qpe/qpeapplication.h> #include <opie/odevicebutton.h> #include <qwidget.h> #include <qdatetime.h> class Background; class Launcher; class TaskBar; class PowerStatus; class QCopBridge; class TransferServer; class DesktopPowerAlerter; class PackageSlave; class OpieScreenSaver; class DesktopApplication : public QPEApplication { Q_OBJECT public: DesktopApplication( int& argc, char **argv, Type t ); ~DesktopApplication(); static void switchLCD ( bool on ); // only for togglePower in Desktop static void soundAlarm(); // only because QCop soundAlarm() is defined in QPE/TaskBar signals: void menu(); void home(); void launch(); void backlight(); void power(); void symbol(); void numLockStateToggle(); 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; }; class Desktop : public QWidget { Q_OBJECT public: Desktop(); ~Desktop(); static bool screenLocked(); void show(); void checkMemory(); public slots: void execAutoStart(); void togglePower(); void toggleLight(); void toggleNumLockState(); void toggleCapsLockState(); void toggleSymbolInput(); void terminateServers(); protected: void executeOrModify( const QString& appLnkFile ); void styleChange( QStyle & ); void timerEvent( QTimerEvent *e ); QWidget *bg; Launcher *launcher; TaskBar *tb; private: void startTransferServer(); bool recoverMemory(); QCopBridge *qcopBridge; TransferServer *transferServer; PackageSlave *packageSlave; QDateTime suspendTime; }; #endif // __DESKTOP_H__ 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 @@ -115,143 +115,142 @@ ButtonSettings::ButtonSettings ( ) l-> setAlignment ( AlignLeft | AlignVCenter | SingleLine ); lay-> addWidget ( l, i, 3, AlignLeft | AlignBottom ); bi-> m_plabel = l; l = new QLabel ( this ); l-> setFixedSize ( 16, 16 ); lay-> addWidget ( l, i + 1, 2, AlignLeft | AlignTop ); bi-> m_hicon = l; l = new QLabel ( this ); l-> setAlignment ( AlignLeft | AlignVCenter | SingleLine ); lay-> addWidget ( l, i + 1, 3, AlignLeft | AlignTop ); bi-> m_hlabel = l; i += 2; m_infos. append ( bi ); } toplay-> addStretch ( 10 ); m_last_button = 0; m_lock = false; m_timer = new QTimer ( this ); connect ( m_timer, SIGNAL( timeout ( )), this, SLOT( keyTimeout ( ))); updateLabels ( ); QPEApplication::grabKeyboard ( ); } ButtonSettings::~ButtonSettings ( ) { QPEApplication::ungrabKeyboard ( ); } void ButtonSettings::updateLabels ( ) { for ( QListIterator <buttoninfo> it ( m_infos ); *it; ++it ) { qCopInfo cip = ButtonUtils::inst ( )-> messageToInfo ((*it)-> m_pmsg ); (*it)-> m_picon-> setPixmap ( cip. m_icon ); (*it)-> m_plabel-> setText ( cip. m_name ); qCopInfo cih = ButtonUtils::inst ( )-> messageToInfo ((*it)-> m_hmsg ); (*it)-> m_hicon-> setPixmap ( cih. m_icon ); (*it)-> m_hlabel-> setText ( cih. m_name ); } } buttoninfo *ButtonSettings::buttonInfoForKeycode ( ushort key ) { for ( QListIterator <buttoninfo> it ( m_infos ); *it; ++it ) { if ((*it)-> m_button-> keycode ( ) == key ) return *it; } return 0; } void ButtonSettings::keyPressEvent ( QKeyEvent *e ) { buttoninfo *bi = buttonInfoForKeycode ( e-> key ( )); if ( bi && !e-> isAutoRepeat ( )) { m_timer-> stop ( ); m_last_button = bi; m_timer-> start ( ODevice::inst ( )-> buttonHoldTime ( ), true ); } else QDialog::keyPressEvent ( 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 ) ODevice::inst ( )-> remapPressedAction ( bi-> m_index, bi-> m_pmsg ); if ( bi-> m_hdirty ) ODevice::inst ( )-> remapHeldAction ( bi-> m_index, bi-> m_hmsg ); } QDialog::accept ( ); } void ButtonSettings::done ( int r ) { QDialog::done ( r ); close ( ); } 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 @@ -1,127 +1,128 @@ #include <stdlib.h> #include <qapplication.h> #include <qlistview.h> #include <qpe/applnk.h> #include <qpe/mimetype.h> #include <qpe/resource.h> #include "buttonutils.h" using namespace Opie; struct predef_qcop { const char *m_text; const char *m_pixmap; const char *m_channel; const char *m_function; }; static const predef_qcop predef [] = { { QT_TRANSLATE_NOOP( "ButtonSettings", "Beam VCard" ), "beam", "QPE/Application/addressbook", "beamBusinessCard()" }, { QT_TRANSLATE_NOOP( "ButtonSettings", "Send eMail" ), "buttonsettings/mail", "QPE/Application/mail", "newMail()" }, { QT_TRANSLATE_NOOP( "ButtonSettings", "Toggle Menu" ), "buttonsettings/menu", "QPE/TaskBar", "toggleMenu()" }, { QT_TRANSLATE_NOOP( "ButtonSettings", "Toggle O-Menu" ), "buttonsettings/omenu", "QPE/TaskBar", "toggleStartMenu()" }, { QT_TRANSLATE_NOOP( "ButtonSettings", "Show Desktop" ), "home", "QPE/Launcher", "home()" }, { QT_TRANSLATE_NOOP( "ButtonSettings", "Toggle Recording" ), "buttonsettings/record", "QPE/VMemo", "toggleRecord()" }, { 0, 0, 0, 0 } }; ButtonUtils *ButtonUtils::ButtonUtils::inst ( ) { static ButtonUtils *p = 0; if ( !p ) { p = new ButtonUtils ( ); ::atexit ( cleanup ); } 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 )); } } void ButtonUtils::insertActions ( QListViewItem *here ) { for ( const predef_qcop *p = predef; p-> m_text; p++ ) { QListViewItem *item = new QListViewItem ( here, qApp-> translate ( "ButtonSettings", p-> m_text ), p-> m_channel, p-> m_function ); item-> setPixmap ( 0, Resource::loadPixmap ( p-> m_pixmap )); } } void ButtonUtils::insertAppLnks ( QListViewItem *here ) { QStringList types = m_apps-> types ( ); QListViewItem *typeitem [types. count ( )]; int i = 0; for ( QStringList::Iterator it = types. begin ( ); it != types. end ( ); ++it ) { QListViewItem *item = new QListViewItem ( here, m_apps-> typeName ( *it )); item-> setPixmap ( 0, m_apps-> typePixmap ( *it )); typeitem [i++] = item; } for ( QListIterator <AppLnk> appit ( m_apps-> children ( )); *appit; ++appit ) { AppLnk *l = *appit; int i = 0; for ( QStringList::Iterator it = types. begin ( ); it != types. end ( ); ++it ) { if ( l-> type ( ) == *it ) { QListViewItem *sub = new QListViewItem ( typeitem [i], l-> name ( ), QString ( "QPE/Application/" ) + l-> exec ( ), "raise()" ); sub-> setPixmap ( 0, l-> pixmap ( )); } i++; } } } 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 @@ -1,132 +1,150 @@ #include <qlistview.h> #include <qlabel.h> #include <qcombobox.h> #include <qtimer.h> #include "remapdlg.h" #include "buttonutils.h" using namespace Opie; class NoSortItem : public QListViewItem { public: NoSortItem ( QListView *lv, uint pos, const QString &str, const QCString &s1 = 0, const QCString &s2 = 0 ) : QListViewItem ( lv, str, s1, s2 ) { m_key = QString ( QChar ( 'a' + pos )); m_def = false; } void setDefault ( bool b ) { m_def = b; } virtual QString key ( int /*column*/, bool /*ascending*/ ) const { return m_key; } virtual void paintCell ( QPainter * p, const QColorGroup & cg, int column, int width, int align ) { if ( m_def ) { QFont f ( listView ( )-> font ( )); f. setBold ( true ); p-> setFont ( f ); } QListViewItem::paintCell ( p, cg, column, width, align ); } 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 ); + + 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 ); } OQCopMessage RemapDlg::message ( ) { return m_msg; } diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 9e97c56..d5e3c5c 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp @@ -187,193 +187,192 @@ struct z_button { { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), "devicebuttons/z_contact", "addressbook", "raise()", "addressbook", "beamBusinessCard()" }, { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), "devicebuttons/z_home", "QPE/Launcher", "home()", "buttonsettings", "raise()" }, { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), "devicebuttons/z_menu", "QPE/TaskBar", "toggleMenu()", "QPE/TaskBar", "toggleStartMenu()" }, { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), "devicebuttons/z_mail", "mail", "raise()", "mail", "newMail()" }, }; static QCString makeChannel ( const char *str ) { if ( str && !::strchr ( str, '/' )) return QCString ( "QPE/Application/" ) + str; else return str; } ODevice *ODevice::inst ( ) { static ODevice *dev = 0; if ( !dev ) { if ( QFile::exists ( "/proc/hal/model" )) dev = new iPAQ ( ); else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) dev = new Zaurus ( ); else dev = new ODevice ( ); dev-> init ( ); } return dev; } /************************************************** * * common * **************************************************/ ODevice::ODevice ( ) { d = new ODeviceData; d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; d-> m_modelstr = "Unknown"; d-> m_model = Model_Unknown; d-> m_vendorstr = "Unknown"; d-> m_vendor = Vendor_Unknown; d-> m_systemstr = "Unknown"; d-> m_system = System_Unknown; d-> m_sysverstr = "0.0"; d-> m_rotation = Rot0; d-> m_holdtime = 1000; // 1000ms QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 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 return false; if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices return false; bool res = false; struct timeval tvs, tvn; ::gettimeofday ( &tvs, 0 ); ::sync ( ); // flush fs caches res = ( ::system ( "apm --suspend" ) == 0 ); // This is needed because the iPAQ apm implementation is asynchronous and we // can not be sure when exactly the device is really suspended // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. if ( res ) { do { // wait at most 1.5 sec: either suspend didn't work or the device resumed ::usleep ( 200 * 1000 ); ::gettimeofday ( &tvn, 0 ); } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); } return res; } //#include <linux/fb.h> better not rely on kernel headers in userspace ... #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 /* VESA Blanking Levels */ #define VESA_NO_BLANKING 0 #define VESA_VSYNC_SUSPEND 1 #define VESA_HSYNC_SUSPEND 2 #define VESA_POWERDOWN 3 bool ODevice::setDisplayStatus ( bool on ) { if ( d-> m_model == Model_Unknown ) return false; bool res = false; int fd; if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); ::close ( fd ); } return res; } bool ODevice::setDisplayBrightness ( int ) { return false; } int ODevice::displayBrightnessResolution ( ) const { return 16; } QString ODevice::vendorString ( ) const { return d-> m_vendorstr; } OVendor ODevice::vendor ( ) const { return d-> m_vendor; } @@ -425,207 +424,213 @@ void ODevice::keySound ( ) if ( snd. isFinished ( )) snd. play ( ); #endif } void ODevice::touchSound ( ) { #ifndef QT_NO_SOUND static Sound snd ( "touchsound" ); if ( snd. isFinished ( )) snd. play ( ); #endif } QValueList <OLed> ODevice::ledList ( ) const { return QValueList <OLed> ( ); } QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const { return QValueList <OLedState> ( ); } OLedState ODevice::ledState ( OLed /*which*/ ) const { return Led_Off; } bool ODevice::setLedState ( OLed /*which*/, OLedState /*st*/ ) { return false; } bool ODevice::hasLightSensor ( ) const { return false; } int ODevice::readLightSensor ( ) { return -1; } int ODevice::lightSensorResolution ( ) const { return 0; } const QValueList <ODeviceButton> &ODevice::buttons ( ) const { return d-> m_buttons; } uint ODevice::buttonHoldTime ( ) const { return d-> m_holdtime; } const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) { for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons. begin ( ); it != d-> m_buttons. end ( ); ++it ) { if ( (*it). keycode ( ) == code ) return &(*it); } return 0; } 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 ); + 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 ); 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; QFile f ( "/proc/hal/model" ); if ( f. open ( IO_ReadOnly )) { QTextStream ts ( &f ); d-> m_modelstr = "H" + ts. readLine ( ); if ( d-> m_modelstr == "H3100" ) d-> m_model = Model_iPAQ_H31xx; else if ( d-> m_modelstr == "H3600" ) d-> m_model = Model_iPAQ_H36xx; else if ( d-> m_modelstr == "H3700" ) d-> m_model = Model_iPAQ_H37xx; else if ( d-> m_modelstr == "H3800" ) d-> m_model = Model_iPAQ_H38xx; else if ( d-> m_modelstr == "H3900" ) d-> m_model = Model_iPAQ_H39xx; else d-> m_model = Model_Unknown; f. close ( ); } switch ( d-> m_model ) { case Model_iPAQ_H31xx: case Model_iPAQ_H38xx: d-> m_rotation = Rot90; break; case Model_iPAQ_H36xx: case Model_iPAQ_H37xx: case Model_iPAQ_H39xx: default: d-> m_rotation = Rot270; break; } f. setName ( "/etc/familiar-version" ); if ( f. open ( IO_ReadOnly )) { d-> m_systemstr = "Familiar"; d-> m_system = System_Familiar; QTextStream ts ( &f ); d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); f. close ( ); } m_leds [0] = m_leds [1] = Led_Off; m_power_timer = 0; for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { i_button *ib = ipaq_buttons + i; ODeviceButton b; if (( ib-> model & d-> m_model ) == d-> m_model ) { b. setKeycode ( ib-> code ); diff --git a/libopie/odevicebutton.cpp b/libopie/odevicebutton.cpp index 2270343..4b22358 100644 --- a/libopie/odevicebutton.cpp +++ b/libopie/odevicebutton.cpp @@ -125,110 +125,111 @@ void OQCopMessage::setData ( const QByteArray &data ) */ ODeviceButton::ODeviceButton() { } ODeviceButton::~ODeviceButton() { } /*! Returns the button's keycode. */ ushort ODeviceButton::keycode() const { return m_Keycode; } /*! This function returns a human readable, translated description of the button. */ QString ODeviceButton::userText() const { return m_UserText; } /*! This function returns the pixmap for this button. If there isn't one it will return an empty (null) pixmap. */ QPixmap ODeviceButton::pixmap() const { return m_Pixmap; } /*! This function returns the factory preset (default) action for when this button is pressed. The return value is a legal QCop message. */ OQCopMessage ODeviceButton::factoryPresetPressedAction() const { return m_FactoryPresetPressedAction; } /*! This function returns the user assigned action for when this button is pressed. If no action is assigned, factoryPresetAction() is returned. */ OQCopMessage ODeviceButton::pressedAction() const { if (m_PressedAction.channel().isEmpty()) return factoryPresetPressedAction(); return m_PressedAction; } /*! This function returns the factory preset (default) action for when this button is pressed and held. The return value is a legal QCop message. */ OQCopMessage ODeviceButton::factoryPresetHeldAction() const { return m_FactoryPresetHeldAction; } /*! This function returns the user assigned action for when this button is pressed and held. If no action is assigned, factoryPresetAction() is returned. */ OQCopMessage ODeviceButton::heldAction() const { if (m_HeldAction.channel().isEmpty()) 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; } |