From 92fb302dd801e7f568cd9d66025431e79dad9771 Mon Sep 17 00:00:00 2001 From: sandman Date: Sun, 22 Dec 2002 23:46:02 +0000 Subject: New button settings -- replaces AppsKey, which does not work anymore with the new device button framework --- (limited to 'core') 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 +           .>+-= + _;:,     .>    :=|. 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_,=:_.      -`: 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 +#include +#include + +#include + +#include + +#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 &buttons = ODevice::inst ( )-> buttons ( ); + + setCaption ( tr( "Button Settings" )); + + QVBoxLayout *toplay = new QVBoxLayout ( this, 3, 3 ); + + QLabel *l = new QLabel ( tr( "
Press or hold the button you want to remap.
" ), 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::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 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 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 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 +           .>+-= + _;:,     .>    :=|. 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_,=:_.      -`: 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 +#include +#include + +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 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 + +#include +#include +#include +#include +#include + +#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", "Ignored" )); + + 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", "Show %1" ). arg ( app ), applnk ? applnk-> pixmap ( ) : QPixmap ( )); + else + return qCopInfo ( qApp-> translate ( "ButtonSettings", "Call %1: %2" ). arg ( app ). arg ( f ), applnk ? applnk-> pixmap ( ) : QPixmap ( )); + } + else { + return qCopInfo ( qApp-> translate ( "ButtonSettings", "Call %1 %2" ). 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 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 +           .>+-= + _;:,     .>    :=|. 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_,=:_.      -`: 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 + +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 +           .>+-= + _;:,     .>    :=|. 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_,=:_.      -`: 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 + + +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/opie­button-settings.control b/core/settings/button/opie­button-settings.control new file mode 100644 index 0000000..a2b8115 --- a/dev/null +++ b/core/settings/button/opie­button-settings.control @@ -0,0 +1,9 @@ +Files: bin/buttonsettings apps/Settings/Button.desktop pics/buttonsettings/*.png +Priority: optional +Section: opie/settings +Maintainer: Robert Griebl +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 +#include +#include + +#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 + +#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 @@ + +RemapDlgBase + + QDialog + + name + RemapDlgBase + + + geometry + + 0 + 0 + 239 + 367 + + + + caption + RemapDlgBase + + + layoutMargin + + + layoutSpacing + + + + margin + 3 + + + spacing + 3 + + + QListView + + + text + Action + + + clickable + true + + + resizeable + true + + + + + text + Channel + + + clickable + true + + + resizeable + true + + + + + text + Message + + + clickable + true + + + resizeable + true + + + + name + w_list + + + allColumnsShowFocus + true + + + showSortIndicator + false + + + rootIsDecorated + true + + + + QLayoutWidget + + name + Layout1 + + + layoutSpacing + + + + margin + 0 + + + spacing + 3 + + + QComboBox + + name + w_channel + + + enabled + false + + + sizePolicy + + 3 + 0 + + + + editable + true + + + autoCompletion + true + + + duplicatesEnabled + false + + + + QLabel + + name + xxxxx + + + text + Message + + + + QComboBox + + name + w_message + + + enabled + false + + + sizePolicy + + 3 + 0 + + + + editable + true + + + autoCompletion + true + + + duplicatesEnabled + false + + + + QLabel + + name + yyyyyy + + + text + Channel + + + + + + + + + w_list + selectionChanged(QListViewItem*) + RemapDlgBase + itemChanged(QListViewItem *) + + + w_message + textChanged(const QString&) + RemapDlgBase + textChanged(const QString &) + + + w_channel + textChanged(const QString&) + RemapDlgBase + textChanged(const QString &) + + textChanged(const QString &) + itemChanged(QListViewItem *) + + -- cgit v0.9.0.2