-rw-r--r-- | core/settings/button/buttonsettings.cpp | 1 | ||||
-rw-r--r-- | core/settings/button/main.cpp | 1 | ||||
-rw-r--r-- | core/settings/button/remapdlg.cpp | 1 |
3 files changed, 0 insertions, 3 deletions
diff --git a/core/settings/button/buttonsettings.cpp b/core/settings/button/buttonsettings.cpp index b6a07a8..523e295 100644 --- a/core/settings/button/buttonsettings.cpp +++ b/core/settings/button/buttonsettings.cpp | |||
@@ -1,224 +1,223 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> | 3 | .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This file is free software; you can | 5 | _;:, .> :=|. This file is free software; you can |
6 | .> <`_, > . <= redistribute it and/or modify it under | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This file is distributed in the hope that | 12 | .i_,=:_. -<s. This file is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
17 | ..}^=.= = ; Public License for more details. | 17 | ..}^=.= = ; Public License for more details. |
18 | ++= -. .` .: | 18 | ++= -. .` .: |
19 | : = ...= . :.=- You should have received a copy of the GNU | 19 | : = ...= . :.=- You should have received a copy of the GNU |
20 | -. .:....=;==+<; General Public License along with this file; | 20 | -. .:....=;==+<; General Public License along with this file; |
21 | -_. . . )=. = see the file COPYING. If not, write to the | 21 | -_. . . )=. = see the file COPYING. If not, write to the |
22 | -- :-=` Free Software Foundation, Inc., | 22 | -- :-=` Free Software Foundation, Inc., |
23 | 59 Temple Place - Suite 330, | 23 | 59 Temple Place - Suite 330, |
24 | Boston, MA 02111-1307, USA. | 24 | Boston, MA 02111-1307, USA. |
25 | 25 | ||
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qlabel.h> | 29 | #include <qlabel.h> |
30 | #include <qtimer.h> | 30 | #include <qtimer.h> |
31 | 31 | ||
32 | #include <qpe/qpeapplication.h> | ||
33 | 32 | ||
34 | #include <opie/odevice.h> | 33 | #include <opie/odevice.h> |
35 | 34 | ||
36 | #include "buttonsettings.h" | 35 | #include "buttonsettings.h" |
37 | #include "buttonutils.h" | 36 | #include "buttonutils.h" |
38 | #include "remapdlg.h" | 37 | #include "remapdlg.h" |
39 | 38 | ||
40 | using namespace Opie; | 39 | using namespace Opie; |
41 | 40 | ||
42 | struct buttoninfo { | 41 | struct buttoninfo { |
43 | const ODeviceButton *m_button; | 42 | const ODeviceButton *m_button; |
44 | int m_index; | 43 | int m_index; |
45 | 44 | ||
46 | OQCopMessage m_pmsg; | 45 | OQCopMessage m_pmsg; |
47 | QLabel *m_picon; | 46 | QLabel *m_picon; |
48 | QLabel *m_plabel; | 47 | QLabel *m_plabel; |
49 | 48 | ||
50 | OQCopMessage m_hmsg; | 49 | OQCopMessage m_hmsg; |
51 | QLabel *m_hicon; | 50 | QLabel *m_hicon; |
52 | QLabel *m_hlabel; | 51 | QLabel *m_hlabel; |
53 | 52 | ||
54 | bool m_pdirty : 1; | 53 | bool m_pdirty : 1; |
55 | bool m_hdirty : 1; | 54 | bool m_hdirty : 1; |
56 | }; | 55 | }; |
57 | 56 | ||
58 | 57 | ||
59 | ButtonSettings::ButtonSettings ( QWidget *parent , const char *name, bool modal, WFlags f ) | 58 | ButtonSettings::ButtonSettings ( QWidget *parent , const char *name, bool modal, WFlags f ) |
60 | : QDialog ( 0, "ButtonSettings", false, WStyle_ContextHelp ) | 59 | : QDialog ( 0, "ButtonSettings", false, WStyle_ContextHelp ) |
61 | { | 60 | { |
62 | const QValueList <ODeviceButton> &buttons = ODevice::inst ( )-> buttons ( ); | 61 | const QValueList <ODeviceButton> &buttons = ODevice::inst ( )-> buttons ( ); |
63 | (void) ButtonUtils::inst ( ); // initialise | 62 | (void) ButtonUtils::inst ( ); // initialise |
64 | 63 | ||
65 | setCaption ( tr( "Button Settings" )); | 64 | setCaption ( tr( "Button Settings" )); |
66 | 65 | ||
67 | QVBoxLayout *toplay = new QVBoxLayout ( this, 3, 3 ); | 66 | QVBoxLayout *toplay = new QVBoxLayout ( this, 3, 3 ); |
68 | 67 | ||
69 | QLabel *l = new QLabel ( tr( "<center>Press or hold the button you want to remap.</center>" ), this ); | 68 | QLabel *l = new QLabel ( tr( "<center>Press or hold the button you want to remap.</center>" ), this ); |
70 | toplay-> addWidget ( l ); | 69 | toplay-> addWidget ( l ); |
71 | 70 | ||
72 | QGridLayout *lay = new QGridLayout ( toplay ); | 71 | QGridLayout *lay = new QGridLayout ( toplay ); |
73 | lay-> setMargin ( 0 ); | 72 | lay-> setMargin ( 0 ); |
74 | lay-> setColStretch ( 0, 0 ); | 73 | lay-> setColStretch ( 0, 0 ); |
75 | lay-> setColStretch ( 1, 0 ); | 74 | lay-> setColStretch ( 1, 0 ); |
76 | lay-> setColStretch ( 2, 0 ); | 75 | lay-> setColStretch ( 2, 0 ); |
77 | lay-> setColStretch ( 3, 10 ); | 76 | lay-> setColStretch ( 3, 10 ); |
78 | 77 | ||
79 | m_infos. setAutoDelete ( true ); | 78 | m_infos. setAutoDelete ( true ); |
80 | 79 | ||
81 | int i = 1; | 80 | int i = 1; |
82 | int index = 0; | 81 | int index = 0; |
83 | for ( QValueList<ODeviceButton>::ConstIterator it = buttons. begin ( ); it != buttons. end ( ); it++ ) { | 82 | for ( QValueList<ODeviceButton>::ConstIterator it = buttons. begin ( ); it != buttons. end ( ); it++ ) { |
84 | if ( it != buttons. begin ( )) { | 83 | if ( it != buttons. begin ( )) { |
85 | QFrame *f = new QFrame ( this ); | 84 | QFrame *f = new QFrame ( this ); |
86 | f-> setFrameStyle ( QFrame::Sunken | QFrame::VLine ); | 85 | f-> setFrameStyle ( QFrame::Sunken | QFrame::VLine ); |
87 | lay-> addMultiCellWidget ( f, i, i, 0, 3 ); | 86 | lay-> addMultiCellWidget ( f, i, i, 0, 3 ); |
88 | i++; | 87 | i++; |
89 | } | 88 | } |
90 | 89 | ||
91 | buttoninfo *bi = new buttoninfo ( ); | 90 | buttoninfo *bi = new buttoninfo ( ); |
92 | bi-> m_button = &(*it); | 91 | bi-> m_button = &(*it); |
93 | bi-> m_index = index++; | 92 | bi-> m_index = index++; |
94 | bi-> m_pmsg = (*it). pressedAction ( ); | 93 | bi-> m_pmsg = (*it). pressedAction ( ); |
95 | bi-> m_hmsg = (*it). heldAction ( ); | 94 | bi-> m_hmsg = (*it). heldAction ( ); |
96 | bi-> m_pdirty = false; | 95 | bi-> m_pdirty = false; |
97 | bi-> m_hdirty = false; | 96 | bi-> m_hdirty = false; |
98 | 97 | ||
99 | l = new QLabel ( this ); | 98 | l = new QLabel ( this ); |
100 | l-> setPixmap (( *it ). pixmap ( )); | 99 | l-> setPixmap (( *it ). pixmap ( )); |
101 | 100 | ||
102 | lay-> addMultiCellWidget ( l, i, i + 1, 0, 0 ); | 101 | lay-> addMultiCellWidget ( l, i, i + 1, 0, 0 ); |
103 | 102 | ||
104 | l = new QLabel ( tr( "Press:" ), this ); | 103 | l = new QLabel ( tr( "Press:" ), this ); |
105 | lay-> addWidget ( l, i, 1, AlignLeft | AlignBottom ); | 104 | lay-> addWidget ( l, i, 1, AlignLeft | AlignBottom ); |
106 | l = new QLabel ( tr( "Hold:" ), this ); | 105 | l = new QLabel ( tr( "Hold:" ), this ); |
107 | lay-> addWidget ( l, i + 1, 1, AlignLeft | AlignTop ); | 106 | lay-> addWidget ( l, i + 1, 1, AlignLeft | AlignTop ); |
108 | 107 | ||
109 | l = new QLabel ( this ); | 108 | l = new QLabel ( this ); |
110 | l-> setFixedSize ( 16, 16 ); | 109 | l-> setFixedSize ( 16, 16 ); |
111 | lay-> addWidget ( l, i, 2, AlignLeft | AlignBottom ); | 110 | lay-> addWidget ( l, i, 2, AlignLeft | AlignBottom ); |
112 | bi-> m_picon = l; | 111 | bi-> m_picon = l; |
113 | 112 | ||
114 | l = new QLabel ( this ); | 113 | l = new QLabel ( this ); |
115 | l-> setAlignment ( AlignLeft | AlignVCenter | SingleLine ); | 114 | l-> setAlignment ( AlignLeft | AlignVCenter | SingleLine ); |
116 | lay-> addWidget ( l, i, 3, AlignLeft | AlignBottom ); | 115 | lay-> addWidget ( l, i, 3, AlignLeft | AlignBottom ); |
117 | bi-> m_plabel = l; | 116 | bi-> m_plabel = l; |
118 | 117 | ||
119 | l = new QLabel ( this ); | 118 | l = new QLabel ( this ); |
120 | l-> setFixedSize ( 16, 16 ); | 119 | l-> setFixedSize ( 16, 16 ); |
121 | lay-> addWidget ( l, i + 1, 2, AlignLeft | AlignTop ); | 120 | lay-> addWidget ( l, i + 1, 2, AlignLeft | AlignTop ); |
122 | bi-> m_hicon = l; | 121 | bi-> m_hicon = l; |
123 | 122 | ||
124 | l = new QLabel ( this ); | 123 | l = new QLabel ( this ); |
125 | l-> setAlignment ( AlignLeft | AlignVCenter | SingleLine ); | 124 | l-> setAlignment ( AlignLeft | AlignVCenter | SingleLine ); |
126 | lay-> addWidget ( l, i + 1, 3, AlignLeft | AlignTop ); | 125 | lay-> addWidget ( l, i + 1, 3, AlignLeft | AlignTop ); |
127 | bi-> m_hlabel = l; | 126 | bi-> m_hlabel = l; |
128 | 127 | ||
129 | i += 2; | 128 | i += 2; |
130 | 129 | ||
131 | m_infos. append ( bi ); | 130 | m_infos. append ( bi ); |
132 | } | 131 | } |
133 | 132 | ||
134 | toplay-> addStretch ( 10 ); | 133 | toplay-> addStretch ( 10 ); |
135 | 134 | ||
136 | m_last_button = 0; | 135 | m_last_button = 0; |
137 | m_lock = false; | 136 | m_lock = false; |
138 | 137 | ||
139 | m_timer = new QTimer ( this ); | 138 | m_timer = new QTimer ( this ); |
140 | connect ( m_timer, SIGNAL( timeout ( )), this, SLOT( keyTimeout ( ))); | 139 | connect ( m_timer, SIGNAL( timeout ( )), this, SLOT( keyTimeout ( ))); |
141 | 140 | ||
142 | updateLabels ( ); | 141 | updateLabels ( ); |
143 | 142 | ||
144 | QPEApplication::grabKeyboard ( ); | 143 | QPEApplication::grabKeyboard ( ); |
145 | } | 144 | } |
146 | 145 | ||
147 | ButtonSettings::~ButtonSettings ( ) | 146 | ButtonSettings::~ButtonSettings ( ) |
148 | { | 147 | { |
149 | QPEApplication::ungrabKeyboard ( ); | 148 | QPEApplication::ungrabKeyboard ( ); |
150 | } | 149 | } |
151 | 150 | ||
152 | void ButtonSettings::updateLabels ( ) | 151 | void ButtonSettings::updateLabels ( ) |
153 | { | 152 | { |
154 | for ( QListIterator <buttoninfo> it ( m_infos ); *it; ++it ) { | 153 | for ( QListIterator <buttoninfo> it ( m_infos ); *it; ++it ) { |
155 | qCopInfo cip = ButtonUtils::inst ( )-> messageToInfo ((*it)-> m_pmsg ); | 154 | qCopInfo cip = ButtonUtils::inst ( )-> messageToInfo ((*it)-> m_pmsg ); |
156 | 155 | ||
157 | (*it)-> m_picon-> setPixmap ( cip. m_icon ); | 156 | (*it)-> m_picon-> setPixmap ( cip. m_icon ); |
158 | (*it)-> m_plabel-> setText ( cip. m_name ); | 157 | (*it)-> m_plabel-> setText ( cip. m_name ); |
159 | 158 | ||
160 | qCopInfo cih = ButtonUtils::inst ( )-> messageToInfo ((*it)-> m_hmsg ); | 159 | qCopInfo cih = ButtonUtils::inst ( )-> messageToInfo ((*it)-> m_hmsg ); |
161 | 160 | ||
162 | (*it)-> m_hicon-> setPixmap ( cih. m_icon ); | 161 | (*it)-> m_hicon-> setPixmap ( cih. m_icon ); |
163 | (*it)-> m_hlabel-> setText ( cih. m_name ); | 162 | (*it)-> m_hlabel-> setText ( cih. m_name ); |
164 | } | 163 | } |
165 | } | 164 | } |
166 | 165 | ||
167 | buttoninfo *ButtonSettings::buttonInfoForKeycode ( ushort key ) | 166 | buttoninfo *ButtonSettings::buttonInfoForKeycode ( ushort key ) |
168 | { | 167 | { |
169 | for ( QListIterator <buttoninfo> it ( m_infos ); *it; ++it ) { | 168 | for ( QListIterator <buttoninfo> it ( m_infos ); *it; ++it ) { |
170 | if ((*it)-> m_button-> keycode ( ) == key ) | 169 | if ((*it)-> m_button-> keycode ( ) == key ) |
171 | return *it; | 170 | return *it; |
172 | } | 171 | } |
173 | return 0; | 172 | return 0; |
174 | } | 173 | } |
175 | 174 | ||
176 | void ButtonSettings::keyPressEvent ( QKeyEvent *e ) | 175 | void ButtonSettings::keyPressEvent ( QKeyEvent *e ) |
177 | { | 176 | { |
178 | buttoninfo *bi = buttonInfoForKeycode ( e-> key ( )); | 177 | buttoninfo *bi = buttonInfoForKeycode ( e-> key ( )); |
179 | 178 | ||
180 | if ( bi && !e-> isAutoRepeat ( )) { | 179 | if ( bi && !e-> isAutoRepeat ( )) { |
181 | m_timer-> stop ( ); | 180 | m_timer-> stop ( ); |
182 | m_last_button = bi; | 181 | m_last_button = bi; |
183 | m_timer-> start ( ODevice::inst ( )-> buttonHoldTime ( ), true ); | 182 | m_timer-> start ( ODevice::inst ( )-> buttonHoldTime ( ), true ); |
184 | } | 183 | } |
185 | else | 184 | else |
186 | QDialog::keyPressEvent ( e ); | 185 | QDialog::keyPressEvent ( e ); |
187 | } | 186 | } |
188 | 187 | ||
189 | void ButtonSettings::keyReleaseEvent ( QKeyEvent *e ) | 188 | void ButtonSettings::keyReleaseEvent ( QKeyEvent *e ) |
190 | { | 189 | { |
191 | buttoninfo *bi = buttonInfoForKeycode ( e-> key ( )); | 190 | buttoninfo *bi = buttonInfoForKeycode ( e-> key ( )); |
192 | 191 | ||
193 | if ( bi && !e-> isAutoRepeat ( ) && m_timer-> isActive ( )) { | 192 | if ( bi && !e-> isAutoRepeat ( ) && m_timer-> isActive ( )) { |
194 | m_timer-> stop ( ); | 193 | m_timer-> stop ( ); |
195 | edit ( bi, false ); | 194 | edit ( bi, false ); |
196 | } | 195 | } |
197 | else | 196 | else |
198 | QDialog::keyReleaseEvent ( e ); | 197 | QDialog::keyReleaseEvent ( e ); |
199 | } | 198 | } |
200 | 199 | ||
201 | void ButtonSettings::keyTimeout ( ) | 200 | void ButtonSettings::keyTimeout ( ) |
202 | { | 201 | { |
203 | if ( m_last_button ) { | 202 | if ( m_last_button ) { |
204 | edit ( m_last_button, true ); | 203 | edit ( m_last_button, true ); |
205 | m_last_button = false; | 204 | m_last_button = false; |
206 | } | 205 | } |
207 | } | 206 | } |
208 | 207 | ||
209 | void ButtonSettings::edit ( buttoninfo *bi, bool hold ) | 208 | void ButtonSettings::edit ( buttoninfo *bi, bool hold ) |
210 | { | 209 | { |
211 | 210 | ||
212 | if ( m_lock ) | 211 | if ( m_lock ) |
213 | return; | 212 | return; |
214 | m_lock = true; | 213 | m_lock = true; |
215 | 214 | ||
216 | RemapDlg *d = new RemapDlg ( bi-> m_button, hold, this ); | 215 | RemapDlg *d = new RemapDlg ( bi-> m_button, hold, this ); |
217 | 216 | ||
218 | d-> showMaximized ( ); | 217 | d-> showMaximized ( ); |
219 | if ( d-> exec ( ) == QDialog::Accepted ) { | 218 | if ( d-> exec ( ) == QDialog::Accepted ) { |
220 | 219 | ||
221 | 220 | ||
222 | if ( hold ) { | 221 | if ( hold ) { |
223 | bi-> m_hmsg = d-> message ( ); | 222 | bi-> m_hmsg = d-> message ( ); |
224 | bi-> m_hdirty = true; | 223 | bi-> m_hdirty = true; |
diff --git a/core/settings/button/main.cpp b/core/settings/button/main.cpp index c063c3c..e7c5bf9 100644 --- a/core/settings/button/main.cpp +++ b/core/settings/button/main.cpp | |||
@@ -1,33 +1,32 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> | 3 | .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This file is free software; you can | 5 | _;:, .> :=|. This file is free software; you can |
6 | .> <`_, > . <= redistribute it and/or modify it under | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This file is distributed in the hope that | 12 | .i_,=:_. -<s. This file is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
17 | ..}^=.= = ; Public License for more details. | 17 | ..}^=.= = ; Public License for more details. |
18 | ++= -. .` .: | 18 | ++= -. .` .: |
19 | : = ...= . :.=- You should have received a copy of the GNU | 19 | : = ...= . :.=- You should have received a copy of the GNU |
20 | -. .:....=;==+<; General Public License along with this file; | 20 | -. .:....=;==+<; General Public License along with this file; |
21 | -_. . . )=. = see the file COPYING. If not, write to the | 21 | -_. . . )=. = see the file COPYING. If not, write to the |
22 | -- :-=` Free Software Foundation, Inc., | 22 | -- :-=` Free Software Foundation, Inc., |
23 | 59 Temple Place - Suite 330, | 23 | 59 Temple Place - Suite 330, |
24 | Boston, MA 02111-1307, USA. | 24 | Boston, MA 02111-1307, USA. |
25 | 25 | ||
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include "buttonsettings.h" | 28 | #include "buttonsettings.h" |
29 | 29 | ||
30 | #include <qpe/qpeapplication.h> | ||
31 | #include <opie/oapplicationfactory.h> | 30 | #include <opie/oapplicationfactory.h> |
32 | 31 | ||
33 | OPIE_EXPORT_APP( OApplicationFactory<ButtonSettings> ) | 32 | OPIE_EXPORT_APP( OApplicationFactory<ButtonSettings> ) |
diff --git a/core/settings/button/remapdlg.cpp b/core/settings/button/remapdlg.cpp index 939a6bf..7dabe68 100644 --- a/core/settings/button/remapdlg.cpp +++ b/core/settings/button/remapdlg.cpp | |||
@@ -1,156 +1,155 @@ | |||
1 | #include <qlistview.h> | 1 | #include <qlistview.h> |
2 | #include <qlabel.h> | ||
3 | #include <qcombobox.h> | 2 | #include <qcombobox.h> |
4 | #include <qtimer.h> | 3 | #include <qtimer.h> |
5 | 4 | ||
6 | #include "remapdlg.h" | 5 | #include "remapdlg.h" |
7 | #include "buttonutils.h" | 6 | #include "buttonutils.h" |
8 | 7 | ||
9 | using namespace Opie; | 8 | using namespace Opie; |
10 | 9 | ||
11 | class NoSortItem : public QListViewItem { | 10 | class NoSortItem : public QListViewItem { |
12 | public: | 11 | public: |
13 | NoSortItem ( QListView *lv, uint pos, const QString &str, const QCString &s1 = 0, const QCString &s2 = 0 ) | 12 | NoSortItem ( QListView *lv, uint pos, const QString &str, const QCString &s1 = 0, const QCString &s2 = 0 ) |
14 | : QListViewItem ( lv, str, s1, s2 ) | 13 | : QListViewItem ( lv, str, s1, s2 ) |
15 | { | 14 | { |
16 | m_key = QString ( QChar ( 'a' + pos )); | 15 | m_key = QString ( QChar ( 'a' + pos )); |
17 | m_def = false; | 16 | m_def = false; |
18 | } | 17 | } |
19 | 18 | ||
20 | void setDefault ( bool b ) | 19 | void setDefault ( bool b ) |
21 | { | 20 | { |
22 | m_def = b; | 21 | m_def = b; |
23 | } | 22 | } |
24 | 23 | ||
25 | virtual QString key ( int /*column*/, bool /*ascending*/ ) const | 24 | virtual QString key ( int /*column*/, bool /*ascending*/ ) const |
26 | { | 25 | { |
27 | return m_key; | 26 | return m_key; |
28 | } | 27 | } |
29 | 28 | ||
30 | virtual void paintCell ( QPainter * p, const QColorGroup & cg, int column, int width, int align ) | 29 | virtual void paintCell ( QPainter * p, const QColorGroup & cg, int column, int width, int align ) |
31 | { | 30 | { |
32 | if ( m_def ) { | 31 | if ( m_def ) { |
33 | QFont f ( listView ( )-> font ( )); | 32 | QFont f ( listView ( )-> font ( )); |
34 | f. setBold ( true ); | 33 | f. setBold ( true ); |
35 | p-> setFont ( f ); | 34 | p-> setFont ( f ); |
36 | } | 35 | } |
37 | QListViewItem::paintCell ( p, cg, column, width, align ); | 36 | QListViewItem::paintCell ( p, cg, column, width, align ); |
38 | } | 37 | } |
39 | 38 | ||
40 | private: | 39 | private: |
41 | QString m_key; | 40 | QString m_key; |
42 | bool m_def; | 41 | bool m_def; |
43 | }; | 42 | }; |
44 | 43 | ||
45 | 44 | ||
46 | RemapDlg::RemapDlg ( const Opie::ODeviceButton *b, bool hold, QWidget *parent, const char *name ) | 45 | RemapDlg::RemapDlg ( const Opie::ODeviceButton *b, bool hold, QWidget *parent, const char *name ) |
47 | : RemapDlgBase ( parent, name, true, WStyle_ContextHelp ) | 46 | : RemapDlgBase ( parent, name, true, WStyle_ContextHelp ) |
48 | { | 47 | { |
49 | setCaption ( tr( "%1 %2", "(hold|press) buttoname" ). arg( hold ? tr( "Held" ) : tr( "Pressed" )). arg ( b-> userText ( ))); | 48 | setCaption ( tr( "%1 %2", "(hold|press) buttoname" ). arg( hold ? tr( "Held" ) : tr( "Pressed" )). arg ( b-> userText ( ))); |
50 | 49 | ||
51 | m_current = 0; | 50 | m_current = 0; |
52 | 51 | ||
53 | static const char * const def_channels [] = { "QPE/Application/", "QPE/Launcher", "QPE/System", "QPE/TaskBar", "QPE/", 0 }; | 52 | static const char * const def_channels [] = { "QPE/Application/", "QPE/Launcher", "QPE/System", "QPE/TaskBar", "QPE/", 0 }; |
54 | w_channel-> insertStrList ((const char **) def_channels ); | 53 | w_channel-> insertStrList ((const char **) def_channels ); |
55 | 54 | ||
56 | m_msg = hold ? b-> heldAction ( ) : b-> pressedAction ( ); | 55 | m_msg = hold ? b-> heldAction ( ) : b-> pressedAction ( ); |
57 | m_msg_preset = hold ? b-> factoryPresetHeldAction ( ) : b-> factoryPresetPressedAction ( ); | 56 | m_msg_preset = hold ? b-> factoryPresetHeldAction ( ) : b-> factoryPresetPressedAction ( ); |
58 | 57 | ||
59 | m_map_none = new NoSortItem ( w_list, 0, tr( "No mapping" )); | 58 | m_map_none = new NoSortItem ( w_list, 0, tr( "No mapping" )); |
60 | m_map_preset = new NoSortItem ( w_list, 1, tr( "Default" ), m_msg_preset. channel ( ), m_msg_preset. message ( )); | 59 | m_map_preset = new NoSortItem ( w_list, 1, tr( "Default" ), m_msg_preset. channel ( ), m_msg_preset. message ( )); |
61 | ((NoSortItem *) m_map_preset )-> setDefault ( true ); | 60 | ((NoSortItem *) m_map_preset )-> setDefault ( true ); |
62 | 61 | ||
63 | if (m_msg. channel ( ) == "ignore") | 62 | if (m_msg. channel ( ) == "ignore") |
64 | { | 63 | { |
65 | m_map_custom = new NoSortItem ( w_list, 2, tr( "Custom" ), m_msg_preset. channel ( ), m_msg_preset. message ( )); | 64 | m_map_custom = new NoSortItem ( w_list, 2, tr( "Custom" ), m_msg_preset. channel ( ), m_msg_preset. message ( )); |
66 | 65 | ||
67 | m_current = m_map_none; | 66 | m_current = m_map_none; |
68 | } | 67 | } |
69 | else | 68 | else |
70 | { | 69 | { |
71 | m_map_custom = new NoSortItem ( w_list, 2, tr( "Custom" ), m_msg. channel ( ), m_msg. message ( )); | 70 | m_map_custom = new NoSortItem ( w_list, 2, tr( "Custom" ), m_msg. channel ( ), m_msg. message ( )); |
72 | m_current = m_map_custom; | 71 | m_current = m_map_custom; |
73 | } | 72 | } |
74 | 73 | ||
75 | QListViewItem *it = new NoSortItem ( w_list, 3, tr( "Actions" )); | 74 | QListViewItem *it = new NoSortItem ( w_list, 3, tr( "Actions" )); |
76 | ButtonUtils::inst ( )-> insertActions ( it ); | 75 | ButtonUtils::inst ( )-> insertActions ( it ); |
77 | it-> setOpen ( true ); | 76 | it-> setOpen ( true ); |
78 | 77 | ||
79 | m_map_show = new NoSortItem ( w_list, 4, tr( "Show" )); | 78 | m_map_show = new NoSortItem ( w_list, 4, tr( "Show" )); |
80 | 79 | ||
81 | w_list-> setCurrentItem ( m_current ); | 80 | w_list-> setCurrentItem ( m_current ); |
82 | 81 | ||
83 | QTimer::singleShot ( 0, this, SLOT( delayedInit ( ))); | 82 | QTimer::singleShot ( 0, this, SLOT( delayedInit ( ))); |
84 | } | 83 | } |
85 | 84 | ||
86 | RemapDlg::~RemapDlg ( ) | 85 | RemapDlg::~RemapDlg ( ) |
87 | { | 86 | { |
88 | } | 87 | } |
89 | 88 | ||
90 | void RemapDlg::delayedInit ( ) | 89 | void RemapDlg::delayedInit ( ) |
91 | { | 90 | { |
92 | bool b = w_list-> viewport ( )-> isUpdatesEnabled ( ); | 91 | bool b = w_list-> viewport ( )-> isUpdatesEnabled ( ); |
93 | w_list-> viewport ( )-> setUpdatesEnabled ( false ); | 92 | w_list-> viewport ( )-> setUpdatesEnabled ( false ); |
94 | 93 | ||
95 | ButtonUtils::inst ( )-> insertAppLnks ( m_map_show ); | 94 | ButtonUtils::inst ( )-> insertAppLnks ( m_map_show ); |
96 | 95 | ||
97 | w_list-> viewport ( )-> setUpdatesEnabled ( b ); | 96 | w_list-> viewport ( )-> setUpdatesEnabled ( b ); |
98 | 97 | ||
99 | m_map_show-> repaint ( ); | 98 | m_map_show-> repaint ( ); |
100 | } | 99 | } |
101 | 100 | ||
102 | void RemapDlg::itemChanged ( QListViewItem *it ) | 101 | void RemapDlg::itemChanged ( QListViewItem *it ) |
103 | { | 102 | { |
104 | bool enabled = false; | 103 | bool enabled = false; |
105 | OQCopMessage m; | 104 | OQCopMessage m; |
106 | 105 | ||
107 | m_current = it; | 106 | m_current = it; |
108 | 107 | ||
109 | if ( it == m_map_none ) | 108 | if ( it == m_map_none ) |
110 | { | 109 | { |
111 | m_msg = m = OQCopMessage ( "ignore", 0 ); | 110 | m_msg = m = OQCopMessage ( "ignore", 0 ); |
112 | qDebug ("***ignoring"); | 111 | qDebug ("***ignoring"); |
113 | } | 112 | } |
114 | else if ( it == m_map_preset ) | 113 | else if ( it == m_map_preset ) |
115 | { | 114 | { |
116 | m_msg = m = m_msg_preset; | 115 | m_msg = m = m_msg_preset; |
117 | qDebug ("***Preset"); | 116 | qDebug ("***Preset"); |
118 | } | 117 | } |
119 | else if ( it && !it-> childCount ( ) ) | 118 | else if ( it && !it-> childCount ( ) ) |
120 | { | 119 | { |
121 | qDebug ("***Custom: %s %s ",it-> text ( 1 ). latin1 ( ), it-> text ( 2 ). latin1 ( )); | 120 | qDebug ("***Custom: %s %s ",it-> text ( 1 ). latin1 ( ), it-> text ( 2 ). latin1 ( )); |
122 | enabled = ( it == m_map_custom ); | 121 | enabled = ( it == m_map_custom ); |
123 | m_msg = m = OQCopMessage ( it-> text ( 1 ). latin1 ( ), it-> text ( 2 ). latin1 ( )); | 122 | m_msg = m = OQCopMessage ( it-> text ( 1 ). latin1 ( ), it-> text ( 2 ). latin1 ( )); |
124 | } | 123 | } |
125 | 124 | ||
126 | w_channel-> setEnabled ( enabled ); | 125 | w_channel-> setEnabled ( enabled ); |
127 | w_message-> setEnabled ( enabled ); | 126 | w_message-> setEnabled ( enabled ); |
128 | 127 | ||
129 | w_channel-> setEditText ( m. channel ( )); | 128 | w_channel-> setEditText ( m. channel ( )); |
130 | //hack for if user has typed in a message, such as 'suspend()' | 129 | //hack for if user has typed in a message, such as 'suspend()' |
131 | //so raise() is always present | 130 | //so raise() is always present |
132 | if(m. message ( ) != "raise()") | 131 | if(m. message ( ) != "raise()") |
133 | w_message->insertItem("raise()"); | 132 | w_message->insertItem("raise()"); |
134 | w_message-> setEditText ( m. message ( )); | 133 | w_message-> setEditText ( m. message ( )); |
135 | } | 134 | } |
136 | 135 | ||
137 | void RemapDlg::textChanged ( const QString &str ) | 136 | void RemapDlg::textChanged ( const QString &str ) |
138 | { | 137 | { |
139 | if ( !m_current ) | 138 | if ( !m_current ) |
140 | return; | 139 | return; |
141 | 140 | ||
142 | QComboBox *which = (QComboBox *) sender ( ); | 141 | QComboBox *which = (QComboBox *) sender ( ); |
143 | 142 | ||
144 | if ( which == w_channel ) | 143 | if ( which == w_channel ) |
145 | m_current-> setText ( 1, str ); | 144 | m_current-> setText ( 1, str ); |
146 | else if ( which == w_message ) | 145 | else if ( which == w_message ) |
147 | m_current-> setText ( 2, str ); | 146 | m_current-> setText ( 2, str ); |
148 | } | 147 | } |
149 | 148 | ||
150 | OQCopMessage RemapDlg::message ( ) | 149 | OQCopMessage RemapDlg::message ( ) |
151 | { | 150 | { |
152 | //make sure to update message if typed in | 151 | //make sure to update message if typed in |
153 | itemChanged(w_list->currentItem()); | 152 | itemChanged(w_list->currentItem()); |
154 | return m_msg; | 153 | return m_msg; |
155 | } | 154 | } |
156 | 155 | ||