summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/settings/button/button.pro35
-rw-r--r--core/settings/button/buttonsettings.cpp249
-rw-r--r--core/settings/button/buttonsettings.h74
-rw-r--r--core/settings/button/buttonutils.cpp119
-rw-r--r--core/settings/button/buttonutils.h67
-rw-r--r--core/settings/button/config.in4
-rw-r--r--core/settings/button/main.cpp43
-rw-r--r--core/settings/button/opie­button-settings.control9
-rw-r--r--core/settings/button/remapdlg.cpp119
-rw-r--r--core/settings/button/remapdlg.h35
-rw-r--r--core/settings/button/remapdlgbase.ui224
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 @@
1TEMPLATE = app
2CONFIG += qt warn_on release
3DESTDIR = $(OPIEDIR)/bin
4HEADERS = buttonsettings.h \
5 buttonutils.h \
6 remapdlg.h
7
8SOURCES = main.cpp \
9 buttonsettings.cpp \
10 buttonutils.cpp \
11 remapdlg.cpp
12
13INTERFACES = remapdlgbase.ui
14
15INCLUDEPATH += $(OPIEDIR)/include
16DEPENDPATH += $(OPIEDIR)/include
17LIBS += -lqpe -lopie
18TARGET = buttonsettings
19
20TRANSLATIONS = ../../../i18n/de/buttonsettings.ts \
21 ../../../i18n/xx/buttonsettings.ts \
22 ../../../i18n/en/buttonsettings.ts \
23 ../../../i18n/es/buttonsettings.ts \
24 ../../../i18n/fr/buttonsettings.ts \
25 ../../../i18n/hu/buttonsettings.ts \
26 ../../../i18n/ja/buttonsettings.ts \
27 ../../../i18n/ko/buttonsettings.ts \
28 ../../../i18n/no/buttonsettings.ts \
29 ../../../i18n/pl/buttonsettings.ts \
30 ../../../i18n/pt/buttonsettings.ts \
31 ../../../i18n/pt_BR/buttonsettings.ts \
32 ../../../i18n/sl/buttonsettings.ts \
33 ../../../i18n/zh_CN/buttonsettings.ts \
34 ../../../i18n/zh_TW/buttonsettings.ts \
35 ../../../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 @@
1/*
2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
4           .>+-=
5 _;:,     .>    :=|. This file is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This file is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
17..}^=.=       =       ; Public License for more details.
18++=   -.     .`     .:
19 :     =  ...= . :.=- You should have received a copy of the GNU
20 -.   .:....=;==+<; General Public License along with this file;
21  -_. . .   )=.  = see the file COPYING. If not, write to the
22    --        :-=` Free Software Foundation, Inc.,
23 59 Temple Place - Suite 330,
24 Boston, MA 02111-1307, USA.
25
26*/
27
28#include <qlayout.h>
29#include <qlabel.h>
30#include <qtimer.h>
31
32#include <qpe/qpeapplication.h>
33
34#include <opie/odevice.h>
35
36#include "buttonsettings.h"
37#include "buttonutils.h"
38#include "remapdlg.h"
39
40using namespace Opie;
41
42struct buttoninfo {
43 const ODeviceButton *m_button;
44 int m_index;
45
46 OQCopMessage m_pmsg;
47 QLabel *m_picon;
48 QLabel *m_plabel;
49
50 OQCopMessage m_hmsg;
51 QLabel *m_hicon;
52 QLabel *m_hlabel;
53
54 bool m_pdirty : 1;
55 bool m_hdirty : 1;
56};
57
58
59ButtonSettings::ButtonSettings ( )
60 : QDialog ( 0, "ButtonSettings", false, WStyle_ContextHelp )
61{
62 const QValueList <ODeviceButton> &buttons = ODevice::inst ( )-> buttons ( );
63
64 setCaption ( tr( "Button Settings" ));
65
66 QVBoxLayout *toplay = new QVBoxLayout ( this, 3, 3 );
67
68 QLabel *l = new QLabel ( tr( "<center>Press or hold the button you want to remap.</center>" ), this );
69 toplay-> addWidget ( l );
70
71 QGridLayout *lay = new QGridLayout ( toplay );
72 lay-> setMargin ( 0 );
73 lay-> setColStretch ( 0, 0 );
74 lay-> setColStretch ( 1, 0 );
75 lay-> setColStretch ( 2, 0 );
76 lay-> setColStretch ( 3, 10 );
77
78 m_infos. setAutoDelete ( true );
79
80 int i = 1;
81 int index = 0;
82 for ( QValueList<ODeviceButton>::ConstIterator it = buttons. begin ( ); it != buttons. end ( ); it++ ) {
83 if ( it != buttons. begin ( )) {
84 QFrame *f = new QFrame ( this );
85 f-> setFrameStyle ( QFrame::Sunken | QFrame::VLine );
86 lay-> addMultiCellWidget ( f, i, i, 0, 2 );
87 i++;
88 }
89
90 buttoninfo *bi = new buttoninfo ( );
91 bi-> m_button = &(*it);
92 bi-> m_index = index++;
93 bi-> m_pmsg = (*it). pressedAction ( );
94 bi-> m_hmsg = (*it). heldAction ( );
95 bi-> m_pdirty = false;
96 bi-> m_hdirty = false;
97
98 l = new QLabel ( this );
99 l-> setPixmap (( *it ). pixmap ( ));
100
101 lay-> addMultiCellWidget ( l, i, i + 1, 0, 0 );
102
103 l = new QLabel ( tr( "Press:" ), this );
104 lay-> addWidget ( l, i, 1, AlignLeft | AlignBottom );
105 l = new QLabel ( tr( "Hold:" ), this );
106 lay-> addWidget ( l, i + 1, 1, AlignLeft | AlignTop );
107
108 l = new QLabel ( this );
109 l-> setFixedSize ( 16, 16 );
110 lay-> addWidget ( l, i, 2, AlignLeft | AlignBottom );
111 bi-> m_picon = l;
112
113 l = new QLabel ( this );
114 l-> setAlignment ( AlignLeft | AlignVCenter | SingleLine );
115 lay-> addWidget ( l, i, 3, AlignLeft | AlignBottom );
116 bi-> m_plabel = l;
117
118 l = new QLabel ( this );
119 l-> setFixedSize ( 16, 16 );
120 lay-> addWidget ( l, i + 1, 2, AlignLeft | AlignTop );
121 bi-> m_hicon = l;
122
123 l = new QLabel ( this );
124 l-> setAlignment ( AlignLeft | AlignVCenter | SingleLine );
125 lay-> addWidget ( l, i + 1, 3, AlignLeft | AlignTop );
126 bi-> m_hlabel = l;
127
128 i += 2;
129
130 m_infos. append ( bi );
131 }
132
133 toplay-> addStretch ( 10 );
134
135 m_last_button = 0;
136
137 m_timer = new QTimer ( this );
138 connect ( m_timer, SIGNAL( timeout ( )), this, SLOT( keyTimeout ( )));
139
140 updateLabels ( );
141
142 QPEApplication::grabKeyboard ( );
143}
144
145ButtonSettings::~ButtonSettings ( )
146{
147 QPEApplication::ungrabKeyboard ( );
148}
149
150void ButtonSettings::updateLabels ( )
151{
152 for ( QListIterator <buttoninfo> it ( m_infos ); *it; ++it ) {
153 qCopInfo cip = ButtonUtils::inst ( )-> messageToInfo ((*it)-> m_pmsg );
154
155 (*it)-> m_picon-> setPixmap ( cip. m_icon );
156 (*it)-> m_plabel-> setText ( cip. m_name );
157
158 qCopInfo cih = ButtonUtils::inst ( )-> messageToInfo ((*it)-> m_hmsg );
159
160 (*it)-> m_hicon-> setPixmap ( cih. m_icon );
161 (*it)-> m_hlabel-> setText ( cih. m_name );
162 }
163}
164
165buttoninfo *ButtonSettings::buttonInfoForKeycode ( ushort key )
166{
167 for ( QListIterator <buttoninfo> it ( m_infos ); *it; ++it ) {
168 if ((*it)-> m_button-> keycode ( ) == key )
169 return *it;
170 }
171 return 0;
172}
173
174void ButtonSettings::keyPressEvent ( QKeyEvent *e )
175{
176 buttoninfo *bi = buttonInfoForKeycode ( e-> key ( ));
177
178 if ( bi && !e-> isAutoRepeat ( )) {
179 m_timer-> stop ( );
180 m_last_button = bi;
181 m_timer-> start ( ODevice::inst ( )-> buttonHoldTime ( ), true );
182 }
183 else
184 QDialog::keyPressEvent ( e );
185}
186
187void ButtonSettings::keyReleaseEvent ( QKeyEvent *e )
188{
189 buttoninfo *bi = buttonInfoForKeycode ( e-> key ( ));
190
191 if ( bi && !e-> isAutoRepeat ( ) && m_timer-> isActive ( )) {
192 m_timer-> stop ( );
193 edit ( bi, false );
194 }
195 else
196 QDialog::keyReleaseEvent ( e );
197}
198
199void ButtonSettings::keyTimeout ( )
200{
201 if ( m_last_button ) {
202 edit ( m_last_button, true );
203 m_last_button = false;
204 }
205}
206
207void ButtonSettings::edit ( buttoninfo *bi, bool hold )
208{
209 qDebug ( "remap %s for %s", hold ? "hold" : "press", bi-> m_button-> userText ( ). latin1 ( ));
210
211 RemapDlg *d = new RemapDlg ( bi-> m_button, hold, this );
212
213 d-> showMaximized ( );
214 if ( d-> exec ( ) == QDialog::Accepted ) {
215 qDebug ( " -> %s %s", d-> message ( ). channel ( ). data ( ), d-> message ( ). message ( ). data ( ));
216
217 if ( hold ) {
218 bi-> m_hmsg = d-> message ( );
219 bi-> m_hdirty = true;
220 }
221 else {
222 bi-> m_pmsg = d-> message ( );
223 bi-> m_pdirty = true;
224 }
225
226 updateLabels ( );
227 }
228
229 delete d;
230}
231
232void ButtonSettings::accept ( )
233{
234 for ( QListIterator <buttoninfo> it ( m_infos ); *it; ++it ) {
235 buttoninfo *bi = *it;
236
237 if ( bi-> m_pdirty )
238 ODevice::inst ( )-> remapPressedAction ( bi-> m_index, bi-> m_pmsg );
239 if ( bi-> m_hdirty )
240 ODevice::inst ( )-> remapHeldAction ( bi-> m_index, bi-> m_hmsg );
241 }
242 QDialog::accept ( );
243}
244
245void ButtonSettings::done ( int r )
246{
247 QDialog::done ( r );
248 close ( );
249}
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 @@
1/*
2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
4           .>+-=
5 _;:,     .>    :=|. This file is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This file is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
17..}^=.=       =       ; Public License for more details.
18++=   -.     .`     .:
19 :     =  ...= . :.=- You should have received a copy of the GNU
20 -.   .:....=;==+<; General Public License along with this file;
21  -_. . .   )=.  = see the file COPYING. If not, write to the
22    --        :-=` Free Software Foundation, Inc.,
23 59 Temple Place - Suite 330,
24 Boston, MA 02111-1307, USA.
25
26*/
27
28#ifndef __BUTTON_SETTINGS_H__
29#define __BUTTON_SETTINGS_H__
30
31#include <qdialog.h>
32#include <qlist.h>
33#include <opie/odevice.h>
34
35class QTimer;
36
37using namespace Opie;
38
39class buttoninfo;
40
41class ButtonSettings : public QDialog {
42 Q_OBJECT
43
44public:
45 ButtonSettings ( );
46 ~ButtonSettings ( );
47
48 virtual void accept ( );
49 virtual void done ( int r );
50
51private slots:
52 void keyTimeout ( );
53 void updateLabels ( );
54
55protected:
56 virtual void keyPressEvent ( QKeyEvent *e );
57 virtual void keyReleaseEvent ( QKeyEvent *e );
58
59private:
60 buttoninfo *buttonInfoForKeycode ( ushort key );
61
62 void edit ( buttoninfo *bi, bool hold );
63 QString qcopToString ( const OQCopMessage &c );
64
65 private:
66 QTimer *m_timer;
67 buttoninfo *m_last_button;
68
69 QList <buttoninfo> m_infos;
70};
71
72#endif
73
74
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 @@
1#include <stdlib.h>
2
3#include <qapplication.h>
4#include <qlistview.h>
5#include <qpe/applnk.h>
6#include <qpe/mimetype.h>
7#include <qpe/resource.h>
8
9#include "buttonutils.h"
10
11using namespace Opie;
12
13struct predef_qcop {
14 const char *m_text;
15 const char *m_pixmap;
16 const char *m_channel;
17 const char *m_function;
18};
19
20static const predef_qcop predef [] = {
21
22 { QT_TRANSLATE_NOOP( "ButtonSettings", "Beam VCard" ), "beam", "QPE/Application/addressbook", "beamBusinessCard()" },
23 { QT_TRANSLATE_NOOP( "ButtonSettings", "Send eMail" ), "buttonsettings/mail", "QPE/Application/mail", "newMail()" },
24
25
26 { QT_TRANSLATE_NOOP( "ButtonSettings", "Toggle Menu" ), "buttonsettings/menu", "QPE/TaskBar", "toggleMenu()" },
27 { QT_TRANSLATE_NOOP( "ButtonSettings", "Toggle O-Menu" ), "buttonsettings/omenu", "QPE/TaskBar", "toggleStartMenu()" },
28 { QT_TRANSLATE_NOOP( "ButtonSettings", "Show Desktop" ), "home", "QPE/Launcher", "home()" },
29 { QT_TRANSLATE_NOOP( "ButtonSettings", "Toggle Recording" ), "buttonsettings/record", "QPE/VMemo", "toggleRecord()" },
30
31 { 0, 0, 0, 0 }
32};
33
34
35
36
37ButtonUtils *ButtonUtils::ButtonUtils::inst ( )
38{
39 static ButtonUtils *p = 0;
40
41 if ( !p ) {
42 p = new ButtonUtils ( );
43 ::atexit ( cleanup );
44 }
45 return p;
46}
47
48void ButtonUtils::cleanup ( )
49{
50 delete inst ( );
51}
52
53ButtonUtils::ButtonUtils ( )
54{
55 m_apps = new AppLnkSet( MimeType::appsFolderName ( ));
56}
57
58ButtonUtils::~ButtonUtils ( )
59{
60 delete m_apps;
61}
62
63qCopInfo ButtonUtils::messageToInfo ( const OQCopMessage &c )
64{
65 QCString ch = c. channel ( );
66 QCString f = c. message ( );
67
68 if ( ch. isNull ( ))
69 return qCopInfo ( qApp-> translate ( "ButtonSettings", "<nobr>Ignored</nobr>" ));
70
71 for ( const predef_qcop *p = predef; p-> m_text; p++ ) {
72 if (( ch == p-> m_channel ) && ( f == p-> m_function ))
73 return qCopInfo ( qApp-> translate ( "ButtonSettings", p-> m_text ), Resource::loadPixmap ( p-> m_pixmap ));
74 }
75
76 if ( ch. left ( 16 ) == "QPE/Application/" ) {
77 QString app = ch. mid ( 16 );
78 const AppLnk *applnk = m_apps-> findExec ( app );
79 if ( applnk )
80 app = applnk-> name ( );
81
82 if (( f == "raise()" ) || ( f == "nextView()" ))
83 return qCopInfo ( qApp-> translate ( "ButtonSettings", "<nobr>Show <b>%1</b></nobr>" ). arg ( app ), applnk ? applnk-> pixmap ( ) : QPixmap ( ));
84 else
85 return qCopInfo ( qApp-> translate ( "ButtonSettings", "<nobr>Call <b>%1</b>: <i>%2</i></nobr>" ). arg ( app ). arg ( f ), applnk ? applnk-> pixmap ( ) : QPixmap ( ));
86 }
87 else {
88 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 ));
89 }
90}
91
92
93void ButtonUtils::insertActions ( QListViewItem *here )
94{
95 for ( const predef_qcop *p = predef; p-> m_text; p++ ) {
96 QListViewItem *item = new QListViewItem ( here, qApp-> translate ( "ButtonSettings", p-> m_text ), p-> m_channel, p-> m_function );
97 item-> setPixmap ( 0, Resource::loadPixmap ( p-> m_pixmap ));
98 }
99}
100
101
102void ButtonUtils::insertAppLnks ( QListViewItem *here )
103{
104 QStringList types = m_apps-> types ( );
105
106 for ( QStringList::Iterator it = types. begin ( ); it != types. end ( ); ++it ) {
107 QListViewItem *item = new QListViewItem ( here, m_apps-> typeName ( *it ));
108 item-> setPixmap ( 0, m_apps-> typePixmap ( *it ));
109
110 for ( QListIterator <AppLnk> appit ( m_apps-> children ( )); *appit; ++appit ) {
111 AppLnk *l = *appit;
112
113 if ( l-> type ( ) == *it ) {
114 QListViewItem *sub = new QListViewItem ( item, l-> name ( ), QString ( "QPE/Application/" ) + l-> exec ( ), "raise()" );
115 sub-> setPixmap ( 0, l-> pixmap ( ));
116 }
117 }
118 }
119}
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 @@
1/*
2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
4           .>+-=
5 _;:,     .>    :=|. This file is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This file is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
17..}^=.=       =       ; Public License for more details.
18++=   -.     .`     .:
19 :     =  ...= . :.=- You should have received a copy of the GNU
20 -.   .:....=;==+<; General Public License along with this file;
21  -_. . .   )=.  = see the file COPYING. If not, write to the
22    --        :-=` Free Software Foundation, Inc.,
23 59 Temple Place - Suite 330,
24 Boston, MA 02111-1307, USA.
25
26*/
27
28#ifndef __BUTTON_UTILS_H__
29#define __BUTTON_UTILS_H__
30
31#include <opie/odevicebutton.h>
32
33class AppLnkSet;
34class QListViewItem;
35
36
37class qCopInfo {
38public:
39 qCopInfo ( const QString &str, const QPixmap &pix = QPixmap ( ))
40 : m_name ( str ), m_icon ( pix )
41 { }
42
43 QString m_name;
44 QPixmap m_icon;
45};
46
47
48class ButtonUtils {
49public:
50 ~ButtonUtils ( );
51
52 static ButtonUtils *inst ( );
53
54 qCopInfo messageToInfo ( const Opie::OQCopMessage & );
55
56 void insertActions ( QListViewItem *here );
57 void insertAppLnks ( QListViewItem *here );
58
59private:
60 ButtonUtils ( );
61 static void cleanup ( );
62
63private:
64 AppLnkSet *m_apps;
65};
66
67#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 @@
1 config BUTTON-SETTINGS
2 boolean "buttons"
3 default "y"
4 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 @@
1/*
2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
4           .>+-=
5 _;:,     .>    :=|. This file is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This file is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
17..}^=.=       =       ; Public License for more details.
18++=   -.     .`     .:
19 :     =  ...= . :.=- You should have received a copy of the GNU
20 -.   .:....=;==+<; General Public License along with this file;
21  -_. . .   )=.  = see the file COPYING. If not, write to the
22    --        :-=` Free Software Foundation, Inc.,
23 59 Temple Place - Suite 330,
24 Boston, MA 02111-1307, USA.
25
26*/
27
28#include "buttonsettings.h"
29
30#include <qpe/qpeapplication.h>
31
32
33int main ( int argc, char** argv )
34{
35 QPEApplication a ( argc,argv );
36
37 ButtonSettings dlg;
38 a. showMainWidget ( &dlg );
39 dlg. showMaximized ( );
40
41 return a. exec ( );
42}
43
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 @@
1Files: bin/buttonsettings apps/Settings/Button.desktop pics/buttonsettings/*.png
2Priority: optional
3Section: opie/settings
4Maintainer: Robert Griebl <sandman@handhelds.org>
5Architecture: arm
6Version: $QPE_VERSION-$SUB_VERSION
7Depends: opie-base ($QPE_VERSION)
8Description: Device-buttons settings dialog
9 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 @@
1#include <qlistview.h>
2#include <qlabel.h>
3#include <qcombobox.h>
4
5#include "remapdlg.h"
6#include "buttonutils.h"
7
8using namespace Opie;
9
10class NoSortItem : public QListViewItem {
11public:
12 NoSortItem ( QListView *lv, uint pos, const QString &str, const QCString &s1 = 0, const QCString &s2 = 0 )
13 : QListViewItem ( lv, str, s1, s2 )
14 {
15 m_key = QString ( QChar ( 'a' + pos ));
16 m_def = false;
17 }
18
19 void setDefault ( bool b )
20 {
21 m_def = b;
22 }
23
24 virtual QString key ( int /*column*/, bool /*ascending*/ ) const
25 {
26 return m_key;
27 }
28
29 virtual void paintCell ( QPainter * p, const QColorGroup & cg, int column, int width, int align )
30 {
31 if ( m_def ) {
32 QFont f ( listView ( )-> font ( ));
33 f. setBold ( true );
34 p-> setFont ( f );
35 }
36 QListViewItem::paintCell ( p, cg, column, width, align );
37 }
38
39private:
40 QString m_key;
41 bool m_def;
42};
43
44
45RemapDlg::RemapDlg ( const Opie::ODeviceButton *b, bool hold, QWidget *parent, const char *name )
46 : RemapDlgBase ( parent, name, true, WStyle_ContextHelp )
47{
48 setCaption ( tr( "%1 %2", "(hold|press) buttoname" ). arg( hold ? tr( "Held" ) : tr( "Pressed" )). arg ( b-> userText ( )));
49
50 m_msg = hold ? b-> heldAction ( ) : b-> pressedAction ( );
51 m_msg_preset = hold ? b-> factoryPresetHeldAction ( ) : b-> factoryPresetPressedAction ( );
52
53 m_map_none = new NoSortItem ( w_list, 0, tr( "No mapping" ));
54 m_map_preset = new NoSortItem ( w_list, 1, tr( "Default" ), m_msg_preset. channel ( ), m_msg_preset. message ( ));
55 ((NoSortItem *) m_map_preset )-> setDefault ( true );
56 m_map_custom = new NoSortItem ( w_list, 2, tr( "Custom" ), m_msg. channel ( ), m_msg. message ( ));
57
58 QListViewItem *it = new NoSortItem ( w_list, 3, tr( "Actions" ));
59 ButtonUtils::inst ( )-> insertActions ( it );
60 it-> setOpen ( true );
61
62 it = new NoSortItem ( w_list, 4, tr( "Show" ));
63 ButtonUtils::inst ( )-> insertAppLnks ( it );
64
65 m_current = m_map_custom;
66 w_list-> setCurrentItem ( m_current );
67
68 static const char * const def_channels [] = {
69 "QPE/Application/", "QPE/Launcher", "QPE/System", "QPE/TaskBar", "QPE/", 0
70 };
71
72 w_channel-> insertStrList ((const char **) def_channels );
73}
74
75RemapDlg::~RemapDlg ( )
76{
77}
78
79void RemapDlg::itemChanged ( QListViewItem *it )
80{
81 bool enabled = false;
82 OQCopMessage m;
83
84 m_current = it;
85
86 if ( it == m_map_none )
87 m_msg = m = OQCopMessage ( 0, 0 );
88 else if ( it == m_map_preset )
89 m_msg = m = m_msg_preset;
90 else if ( it && !it-> childCount ( )) {
91 enabled = ( it == m_map_custom );
92 m_msg = m = OQCopMessage ( it-> text ( 1 ). latin1 ( ), it-> text ( 2 ). latin1 ( ));
93 }
94
95 w_channel-> setEnabled ( enabled );
96 w_message-> setEnabled ( enabled );
97
98 w_channel-> setEditText ( m. channel ( ));
99 w_message-> setEditText ( m. message ( ));
100}
101
102void RemapDlg::textChanged ( const QString &str )
103{
104 if ( !m_current )
105 return;
106
107 QComboBox *which = (QComboBox *) sender ( );
108
109 if ( which == w_channel )
110 m_current-> setText ( 1, str );
111 else if ( which == w_message )
112 m_current-> setText ( 2, str );
113}
114
115OQCopMessage RemapDlg::message ( )
116{
117 return m_msg;
118}
119
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 @@
1#ifndef __REMAPDLG_H__
2#define __REMAPDLG_H__
3
4#include <opie/odevicebutton.h>
5
6#include "remapdlgbase.h"
7
8class QListViewItem;
9
10
11class RemapDlg : public RemapDlgBase {
12 Q_OBJECT
13
14public:
15 RemapDlg ( const Opie::ODeviceButton *b, bool hold, QWidget* parent = 0, const char* name = 0 );
16 ~RemapDlg ( );
17
18 Opie::OQCopMessage message ( );
19
20public slots:
21 virtual void itemChanged ( QListViewItem * );
22 virtual void textChanged ( const QString & );
23
24private:
25 Opie::OQCopMessage m_msg;
26 Opie::OQCopMessage m_msg_preset;
27
28 QListViewItem *m_current;
29
30 QListViewItem *m_map_none;
31 QListViewItem *m_map_preset;
32 QListViewItem *m_map_custom;
33};
34
35#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 @@
1<!DOCTYPE UI><UI>
2<class>RemapDlgBase</class>
3<widget>
4 <class>QDialog</class>
5 <property stdset="1">
6 <name>name</name>
7 <cstring>RemapDlgBase</cstring>
8 </property>
9 <property stdset="1">
10 <name>geometry</name>
11 <rect>
12 <x>0</x>
13 <y>0</y>
14 <width>239</width>
15 <height>367</height>
16 </rect>
17 </property>
18 <property stdset="1">
19 <name>caption</name>
20 <string>RemapDlgBase</string>
21 </property>
22 <property>
23 <name>layoutMargin</name>
24 </property>
25 <property>
26 <name>layoutSpacing</name>
27 </property>
28 <vbox>
29 <property stdset="1">
30 <name>margin</name>
31 <number>3</number>
32 </property>
33 <property stdset="1">
34 <name>spacing</name>
35 <number>3</number>
36 </property>
37 <widget>
38 <class>QListView</class>
39 <column>
40 <property>
41 <name>text</name>
42 <string>Action</string>
43 </property>
44 <property>
45 <name>clickable</name>
46 <bool>true</bool>
47 </property>
48 <property>
49 <name>resizeable</name>
50 <bool>true</bool>
51 </property>
52 </column>
53 <column>
54 <property>
55 <name>text</name>
56 <string>Channel</string>
57 </property>
58 <property>
59 <name>clickable</name>
60 <bool>true</bool>
61 </property>
62 <property>
63 <name>resizeable</name>
64 <bool>true</bool>
65 </property>
66 </column>
67 <column>
68 <property>
69 <name>text</name>
70 <string>Message</string>
71 </property>
72 <property>
73 <name>clickable</name>
74 <bool>true</bool>
75 </property>
76 <property>
77 <name>resizeable</name>
78 <bool>true</bool>
79 </property>
80 </column>
81 <property stdset="1">
82 <name>name</name>
83 <cstring>w_list</cstring>
84 </property>
85 <property stdset="1">
86 <name>allColumnsShowFocus</name>
87 <bool>true</bool>
88 </property>
89 <property stdset="1">
90 <name>showSortIndicator</name>
91 <bool>false</bool>
92 </property>
93 <property stdset="1">
94 <name>rootIsDecorated</name>
95 <bool>true</bool>
96 </property>
97 </widget>
98 <widget>
99 <class>QLayoutWidget</class>
100 <property stdset="1">
101 <name>name</name>
102 <cstring>Layout1</cstring>
103 </property>
104 <property>
105 <name>layoutSpacing</name>
106 </property>
107 <grid>
108 <property stdset="1">
109 <name>margin</name>
110 <number>0</number>
111 </property>
112 <property stdset="1">
113 <name>spacing</name>
114 <number>3</number>
115 </property>
116 <widget row="0" column="1" >
117 <class>QComboBox</class>
118 <property stdset="1">
119 <name>name</name>
120 <cstring>w_channel</cstring>
121 </property>
122 <property stdset="1">
123 <name>enabled</name>
124 <bool>false</bool>
125 </property>
126 <property stdset="1">
127 <name>sizePolicy</name>
128 <sizepolicy>
129 <hsizetype>3</hsizetype>
130 <vsizetype>0</vsizetype>
131 </sizepolicy>
132 </property>
133 <property stdset="1">
134 <name>editable</name>
135 <bool>true</bool>
136 </property>
137 <property stdset="1">
138 <name>autoCompletion</name>
139 <bool>true</bool>
140 </property>
141 <property stdset="1">
142 <name>duplicatesEnabled</name>
143 <bool>false</bool>
144 </property>
145 </widget>
146 <widget row="1" column="0" >
147 <class>QLabel</class>
148 <property stdset="1">
149 <name>name</name>
150 <cstring>xxxxx</cstring>
151 </property>
152 <property stdset="1">
153 <name>text</name>
154 <string>Message</string>
155 </property>
156 </widget>
157 <widget row="1" column="1" >
158 <class>QComboBox</class>
159 <property stdset="1">
160 <name>name</name>
161 <cstring>w_message</cstring>
162 </property>
163 <property stdset="1">
164 <name>enabled</name>
165 <bool>false</bool>
166 </property>
167 <property stdset="1">
168 <name>sizePolicy</name>
169 <sizepolicy>
170 <hsizetype>3</hsizetype>
171 <vsizetype>0</vsizetype>
172 </sizepolicy>
173 </property>
174 <property stdset="1">
175 <name>editable</name>
176 <bool>true</bool>
177 </property>
178 <property stdset="1">
179 <name>autoCompletion</name>
180 <bool>true</bool>
181 </property>
182 <property stdset="1">
183 <name>duplicatesEnabled</name>
184 <bool>false</bool>
185 </property>
186 </widget>
187 <widget row="0" column="0" >
188 <class>QLabel</class>
189 <property stdset="1">
190 <name>name</name>
191 <cstring>yyyyyy</cstring>
192 </property>
193 <property stdset="1">
194 <name>text</name>
195 <string>Channel</string>
196 </property>
197 </widget>
198 </grid>
199 </widget>
200 </vbox>
201</widget>
202<connections>
203 <connection>
204 <sender>w_list</sender>
205 <signal>selectionChanged(QListViewItem*)</signal>
206 <receiver>RemapDlgBase</receiver>
207 <slot>itemChanged(QListViewItem *)</slot>
208 </connection>
209 <connection>
210 <sender>w_message</sender>
211 <signal>textChanged(const QString&amp;)</signal>
212 <receiver>RemapDlgBase</receiver>
213 <slot>textChanged(const QString &amp;)</slot>
214 </connection>
215 <connection>
216 <sender>w_channel</sender>
217 <signal>textChanged(const QString&amp;)</signal>
218 <receiver>RemapDlgBase</receiver>
219 <slot>textChanged(const QString &amp;)</slot>
220 </connection>
221 <slot access="public">textChanged(const QString &amp;)</slot>
222 <slot access="public">itemChanged(QListViewItem *)</slot>
223</connections>
224</UI>