-rw-r--r-- | core/settings/button/button.pro | 35 | ||||
-rw-r--r-- | core/settings/button/buttonsettings.cpp | 249 | ||||
-rw-r--r-- | core/settings/button/buttonsettings.h | 74 | ||||
-rw-r--r-- | core/settings/button/buttonutils.cpp | 119 | ||||
-rw-r--r-- | core/settings/button/buttonutils.h | 67 | ||||
-rw-r--r-- | core/settings/button/config.in | 4 | ||||
-rw-r--r-- | core/settings/button/main.cpp | 43 | ||||
-rw-r--r-- | core/settings/button/opiebutton-settings.control | 9 | ||||
-rw-r--r-- | core/settings/button/remapdlg.cpp | 119 | ||||
-rw-r--r-- | core/settings/button/remapdlg.h | 35 | ||||
-rw-r--r-- | core/settings/button/remapdlgbase.ui | 224 |
11 files changed, 978 insertions, 0 deletions
diff --git a/core/settings/button/button.pro b/core/settings/button/button.pro new file mode 100644 index 0000000..389695c --- a/dev/null +++ b/core/settings/button/button.pro @@ -0,0 +1,35 @@ +TEMPLATE = app +CONFIG += qt warn_on release +DESTDIR = $(OPIEDIR)/bin +HEADERS = buttonsettings.h \ + buttonutils.h \ + remapdlg.h + +SOURCES = main.cpp \ + buttonsettings.cpp \ + buttonutils.cpp \ + remapdlg.cpp + +INTERFACES = remapdlgbase.ui + +INCLUDEPATH += $(OPIEDIR)/include +DEPENDPATH += $(OPIEDIR)/include +LIBS += -lqpe -lopie +TARGET = buttonsettings + +TRANSLATIONS = ../../../i18n/de/buttonsettings.ts \ + ../../../i18n/xx/buttonsettings.ts \ + ../../../i18n/en/buttonsettings.ts \ + ../../../i18n/es/buttonsettings.ts \ + ../../../i18n/fr/buttonsettings.ts \ + ../../../i18n/hu/buttonsettings.ts \ + ../../../i18n/ja/buttonsettings.ts \ + ../../../i18n/ko/buttonsettings.ts \ + ../../../i18n/no/buttonsettings.ts \ + ../../../i18n/pl/buttonsettings.ts \ + ../../../i18n/pt/buttonsettings.ts \ + ../../../i18n/pt_BR/buttonsettings.ts \ + ../../../i18n/sl/buttonsettings.ts \ + ../../../i18n/zh_CN/buttonsettings.ts \ + ../../../i18n/zh_TW/buttonsettings.ts \ + ../../../i18n/da/buttonsettings.ts diff --git a/core/settings/button/buttonsettings.cpp b/core/settings/button/buttonsettings.cpp new file mode 100644 index 0000000..c71514c --- a/dev/null +++ b/core/settings/button/buttonsettings.cpp @@ -0,0 +1,249 @@ +/* + =. This file is part of the OPIE Project + .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> + .>+-= + _;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: + : = ...= . :.=- You should have received a copy of the GNU + -. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., + 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ + +#include <qlayout.h> +#include <qlabel.h> +#include <qtimer.h> + +#include <qpe/qpeapplication.h> + +#include <opie/odevice.h> + +#include "buttonsettings.h" +#include "buttonutils.h" +#include "remapdlg.h" + +using namespace Opie; + +struct buttoninfo { + const ODeviceButton *m_button; + int m_index; + + OQCopMessage m_pmsg; + QLabel *m_picon; + QLabel *m_plabel; + + OQCopMessage m_hmsg; + QLabel *m_hicon; + QLabel *m_hlabel; + + bool m_pdirty : 1; + bool m_hdirty : 1; +}; + + +ButtonSettings::ButtonSettings ( ) + : QDialog ( 0, "ButtonSettings", false, WStyle_ContextHelp ) +{ + const QValueList <ODeviceButton> &buttons = ODevice::inst ( )-> buttons ( ); + + setCaption ( tr( "Button Settings" )); + + QVBoxLayout *toplay = new QVBoxLayout ( this, 3, 3 ); + + QLabel *l = new QLabel ( tr( "<center>Press or hold the button you want to remap.</center>" ), this ); + toplay-> addWidget ( l ); + + QGridLayout *lay = new QGridLayout ( toplay ); + lay-> setMargin ( 0 ); + lay-> setColStretch ( 0, 0 ); + lay-> setColStretch ( 1, 0 ); + lay-> setColStretch ( 2, 0 ); + lay-> setColStretch ( 3, 10 ); + + m_infos. setAutoDelete ( true ); + + int i = 1; + int index = 0; + for ( QValueList<ODeviceButton>::ConstIterator it = buttons. begin ( ); it != buttons. end ( ); it++ ) { + if ( it != buttons. begin ( )) { + QFrame *f = new QFrame ( this ); + f-> setFrameStyle ( QFrame::Sunken | QFrame::VLine ); + lay-> addMultiCellWidget ( f, i, i, 0, 2 ); + i++; + } + + buttoninfo *bi = new buttoninfo ( ); + bi-> m_button = &(*it); + bi-> m_index = index++; + bi-> m_pmsg = (*it). pressedAction ( ); + bi-> m_hmsg = (*it). heldAction ( ); + bi-> m_pdirty = false; + bi-> m_hdirty = false; + + l = new QLabel ( this ); + l-> setPixmap (( *it ). pixmap ( )); + + lay-> addMultiCellWidget ( l, i, i + 1, 0, 0 ); + + l = new QLabel ( tr( "Press:" ), this ); + lay-> addWidget ( l, i, 1, AlignLeft | AlignBottom ); + l = new QLabel ( tr( "Hold:" ), this ); + lay-> addWidget ( l, i + 1, 1, AlignLeft | AlignTop ); + + l = new QLabel ( this ); + l-> setFixedSize ( 16, 16 ); + lay-> addWidget ( l, i, 2, AlignLeft | AlignBottom ); + bi-> m_picon = l; + + l = new QLabel ( this ); + 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_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 ( )); + + 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; +} + +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/buttonsettings.h b/core/settings/button/buttonsettings.h new file mode 100644 index 0000000..f571825 --- a/dev/null +++ b/core/settings/button/buttonsettings.h @@ -0,0 +1,74 @@ +/* + =. This file is part of the OPIE Project + .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> + .>+-= + _;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: + : = ...= . :.=- You should have received a copy of the GNU + -. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., + 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ + +#ifndef __BUTTON_SETTINGS_H__ +#define __BUTTON_SETTINGS_H__ + +#include <qdialog.h> +#include <qlist.h> +#include <opie/odevice.h> + +class QTimer; + +using namespace Opie; + +class buttoninfo; + +class ButtonSettings : public QDialog { + Q_OBJECT + +public: + ButtonSettings ( ); + ~ButtonSettings ( ); + + virtual void accept ( ); + virtual void done ( int r ); + +private slots: + void keyTimeout ( ); + void updateLabels ( ); + +protected: + virtual void keyPressEvent ( QKeyEvent *e ); + virtual void keyReleaseEvent ( QKeyEvent *e ); + +private: + buttoninfo *buttonInfoForKeycode ( ushort key ); + + void edit ( buttoninfo *bi, bool hold ); + QString qcopToString ( const OQCopMessage &c ); + +private: + QTimer *m_timer; + buttoninfo *m_last_button; + + QList <buttoninfo> m_infos; +}; + +#endif + + diff --git a/core/settings/button/buttonutils.cpp b/core/settings/button/buttonutils.cpp new file mode 100644 index 0000000..bb70047 --- a/dev/null +++ b/core/settings/button/buttonutils.cpp @@ -0,0 +1,119 @@ +#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 ( )) + 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 ( ); + + 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 )); + + for ( QListIterator <AppLnk> appit ( m_apps-> children ( )); *appit; ++appit ) { + AppLnk *l = *appit; + + if ( l-> type ( ) == *it ) { + QListViewItem *sub = new QListViewItem ( item, l-> name ( ), QString ( "QPE/Application/" ) + l-> exec ( ), "raise()" ); + sub-> setPixmap ( 0, l-> pixmap ( )); + } + } + } +} diff --git a/core/settings/button/buttonutils.h b/core/settings/button/buttonutils.h new file mode 100644 index 0000000..5ea59bb --- a/dev/null +++ b/core/settings/button/buttonutils.h @@ -0,0 +1,67 @@ +/* + =. This file is part of the OPIE Project + .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> + .>+-= + _;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: + : = ...= . :.=- You should have received a copy of the GNU + -. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., + 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ + +#ifndef __BUTTON_UTILS_H__ +#define __BUTTON_UTILS_H__ + +#include <opie/odevicebutton.h> + +class AppLnkSet; +class QListViewItem; + + +class qCopInfo { +public: + qCopInfo ( const QString &str, const QPixmap &pix = QPixmap ( )) + : m_name ( str ), m_icon ( pix ) + { } + + QString m_name; + QPixmap m_icon; +}; + + +class ButtonUtils { +public: + ~ButtonUtils ( ); + + static ButtonUtils *inst ( ); + + qCopInfo messageToInfo ( const Opie::OQCopMessage & ); + + void insertActions ( QListViewItem *here ); + void insertAppLnks ( QListViewItem *here ); + +private: + ButtonUtils ( ); + static void cleanup ( ); + +private: + AppLnkSet *m_apps; +}; + +#endif diff --git a/core/settings/button/config.in b/core/settings/button/config.in new file mode 100644 index 0000000..6f466f5 --- a/dev/null +++ b/core/settings/button/config.in @@ -0,0 +1,4 @@ + config BUTTON-SETTINGS + boolean "buttons" + default "y" + depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE diff --git a/core/settings/button/main.cpp b/core/settings/button/main.cpp new file mode 100644 index 0000000..db274f8 --- a/dev/null +++ b/core/settings/button/main.cpp @@ -0,0 +1,43 @@ +/* + =. This file is part of the OPIE Project + .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> + .>+-= + _;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: + : = ...= . :.=- You should have received a copy of the GNU + -. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., + 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ + +#include "buttonsettings.h" + +#include <qpe/qpeapplication.h> + + +int main ( int argc, char** argv ) +{ + QPEApplication a ( argc,argv ); + + ButtonSettings dlg; + a. showMainWidget ( &dlg ); + dlg. showMaximized ( ); + + return a. exec ( ); +} + diff --git a/core/settings/button/opiebutton-settings.control b/core/settings/button/opiebutton-settings.control new file mode 100644 index 0000000..a2b8115 --- a/dev/null +++ b/core/settings/button/opiebutton-settings.control @@ -0,0 +1,9 @@ +Files: bin/buttonsettings apps/Settings/Button.desktop pics/buttonsettings/*.png +Priority: optional +Section: opie/settings +Maintainer: Robert Griebl <sandman@handhelds.org> +Architecture: arm +Version: $QPE_VERSION-$SUB_VERSION +Depends: opie-base ($QPE_VERSION) +Description: Device-buttons settings dialog + For the Opie environment. diff --git a/core/settings/button/remapdlg.cpp b/core/settings/button/remapdlg.cpp new file mode 100644 index 0000000..511d0e7 --- a/dev/null +++ b/core/settings/button/remapdlg.cpp @@ -0,0 +1,119 @@ +#include <qlistview.h> +#include <qlabel.h> +#include <qcombobox.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_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 ( )); + + QListViewItem *it = new NoSortItem ( w_list, 3, tr( "Actions" )); + ButtonUtils::inst ( )-> insertActions ( it ); + it-> setOpen ( true ); + + it = new NoSortItem ( w_list, 4, tr( "Show" )); + ButtonUtils::inst ( )-> insertAppLnks ( it ); + + m_current = m_map_custom; + w_list-> setCurrentItem ( m_current ); + + static const char * const def_channels [] = { + "QPE/Application/", "QPE/Launcher", "QPE/System", "QPE/TaskBar", "QPE/", 0 + }; + + w_channel-> insertStrList ((const char **) def_channels ); +} + +RemapDlg::~RemapDlg ( ) +{ +} + +void RemapDlg::itemChanged ( QListViewItem *it ) +{ + bool enabled = false; + OQCopMessage m; + + m_current = it; + + if ( it == m_map_none ) + m_msg = m = OQCopMessage ( 0, 0 ); + else if ( it == m_map_preset ) + m_msg = m = m_msg_preset; + else if ( it && !it-> childCount ( )) { + 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/core/settings/button/remapdlg.h b/core/settings/button/remapdlg.h new file mode 100644 index 0000000..8c9cc02 --- a/dev/null +++ b/core/settings/button/remapdlg.h @@ -0,0 +1,35 @@ +#ifndef __REMAPDLG_H__ +#define __REMAPDLG_H__ + +#include <opie/odevicebutton.h> + +#include "remapdlgbase.h" + +class QListViewItem; + + +class RemapDlg : public RemapDlgBase { + Q_OBJECT + +public: + RemapDlg ( const Opie::ODeviceButton *b, bool hold, QWidget* parent = 0, const char* name = 0 ); + ~RemapDlg ( ); + + Opie::OQCopMessage message ( ); + +public slots: + virtual void itemChanged ( QListViewItem * ); + virtual void textChanged ( const QString & ); + +private: + Opie::OQCopMessage m_msg; + Opie::OQCopMessage m_msg_preset; + + QListViewItem *m_current; + + QListViewItem *m_map_none; + QListViewItem *m_map_preset; + QListViewItem *m_map_custom; +}; + +#endif diff --git a/core/settings/button/remapdlgbase.ui b/core/settings/button/remapdlgbase.ui new file mode 100644 index 0000000..1f0a243 --- a/dev/null +++ b/core/settings/button/remapdlgbase.ui @@ -0,0 +1,224 @@ +<!DOCTYPE UI><UI> +<class>RemapDlgBase</class> +<widget> + <class>QDialog</class> + <property stdset="1"> + <name>name</name> + <cstring>RemapDlgBase</cstring> + </property> + <property stdset="1"> + <name>geometry</name> + <rect> + <x>0</x> + <y>0</y> + <width>239</width> + <height>367</height> + </rect> + </property> + <property stdset="1"> + <name>caption</name> + <string>RemapDlgBase</string> + </property> + <property> + <name>layoutMargin</name> + </property> + <property> + <name>layoutSpacing</name> + </property> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>3</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>3</number> + </property> + <widget> + <class>QListView</class> + <column> + <property> + <name>text</name> + <string>Action</string> + </property> + <property> + <name>clickable</name> + <bool>true</bool> + </property> + <property> + <name>resizeable</name> + <bool>true</bool> + </property> + </column> + <column> + <property> + <name>text</name> + <string>Channel</string> + </property> + <property> + <name>clickable</name> + <bool>true</bool> + </property> + <property> + <name>resizeable</name> + <bool>true</bool> + </property> + </column> + <column> + <property> + <name>text</name> + <string>Message</string> + </property> + <property> + <name>clickable</name> + <bool>true</bool> + </property> + <property> + <name>resizeable</name> + <bool>true</bool> + </property> + </column> + <property stdset="1"> + <name>name</name> + <cstring>w_list</cstring> + </property> + <property stdset="1"> + <name>allColumnsShowFocus</name> + <bool>true</bool> + </property> + <property stdset="1"> + <name>showSortIndicator</name> + <bool>false</bool> + </property> + <property stdset="1"> + <name>rootIsDecorated</name> + <bool>true</bool> + </property> + </widget> + <widget> + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout1</cstring> + </property> + <property> + <name>layoutSpacing</name> + </property> + <grid> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>3</number> + </property> + <widget row="0" column="1" > + <class>QComboBox</class> + <property stdset="1"> + <name>name</name> + <cstring>w_channel</cstring> + </property> + <property stdset="1"> + <name>enabled</name> + <bool>false</bool> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>3</hsizetype> + <vsizetype>0</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>editable</name> + <bool>true</bool> + </property> + <property stdset="1"> + <name>autoCompletion</name> + <bool>true</bool> + </property> + <property stdset="1"> + <name>duplicatesEnabled</name> + <bool>false</bool> + </property> + </widget> + <widget row="1" column="0" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>xxxxx</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Message</string> + </property> + </widget> + <widget row="1" column="1" > + <class>QComboBox</class> + <property stdset="1"> + <name>name</name> + <cstring>w_message</cstring> + </property> + <property stdset="1"> + <name>enabled</name> + <bool>false</bool> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>3</hsizetype> + <vsizetype>0</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>editable</name> + <bool>true</bool> + </property> + <property stdset="1"> + <name>autoCompletion</name> + <bool>true</bool> + </property> + <property stdset="1"> + <name>duplicatesEnabled</name> + <bool>false</bool> + </property> + </widget> + <widget row="0" column="0" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>yyyyyy</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Channel</string> + </property> + </widget> + </grid> + </widget> + </vbox> +</widget> +<connections> + <connection> + <sender>w_list</sender> + <signal>selectionChanged(QListViewItem*)</signal> + <receiver>RemapDlgBase</receiver> + <slot>itemChanged(QListViewItem *)</slot> + </connection> + <connection> + <sender>w_message</sender> + <signal>textChanged(const QString&)</signal> + <receiver>RemapDlgBase</receiver> + <slot>textChanged(const QString &)</slot> + </connection> + <connection> + <sender>w_channel</sender> + <signal>textChanged(const QString&)</signal> + <receiver>RemapDlgBase</receiver> + <slot>textChanged(const QString &)</slot> + </connection> + <slot access="public">textChanged(const QString &)</slot> + <slot access="public">itemChanged(QListViewItem *)</slot> +</connections> +</UI> |