author | zecke <zecke> | 2004-03-27 20:18:11 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-03-27 20:18:11 (UTC) |
commit | 0821e9018b0a3b1ea11ff5a4454db2e047d94d88 (patch) (unidiff) | |
tree | 5a712141869f84167a29b92b97489001ce205148 | |
parent | 9202a4007eb3866acf07264d234da59b310f0a8c (diff) | |
download | opie-0821e9018b0a3b1ea11ff5a4454db2e047d94d88.zip opie-0821e9018b0a3b1ea11ff5a4454db2e047d94d88.tar.gz opie-0821e9018b0a3b1ea11ff5a4454db2e047d94d88.tar.bz2 |
Fix key events.
On true hardware events Shift/Ctrl/Alt are not equal with the ButtonState
On virtual keyboard events no key() is sent...
-rw-r--r-- | libopie2/opieui/okeyconfigwidget.cpp | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/libopie2/opieui/okeyconfigwidget.cpp b/libopie2/opieui/okeyconfigwidget.cpp index b4f1c5e..2ea0bd5 100644 --- a/libopie2/opieui/okeyconfigwidget.cpp +++ b/libopie2/opieui/okeyconfigwidget.cpp | |||
@@ -1,993 +1,1030 @@ | |||
1 | #include "okeyconfigwidget.h" | 1 | #include "okeyconfigwidget.h" |
2 | 2 | ||
3 | #include <opie2/olistview.h> | 3 | #include <opie2/olistview.h> |
4 | 4 | ||
5 | #include <qgroupbox.h> | 5 | #include <qgroupbox.h> |
6 | #include <qradiobutton.h> | 6 | #include <qradiobutton.h> |
7 | #include <qpushbutton.h> | 7 | #include <qpushbutton.h> |
8 | #include <qbuttongroup.h> | 8 | #include <qbuttongroup.h> |
9 | 9 | ||
10 | #include <qaccel.h> | 10 | #include <qaccel.h> |
11 | #include <qlayout.h> | 11 | #include <qlayout.h> |
12 | #include <qlabel.h> | 12 | #include <qlabel.h> |
13 | 13 | ||
14 | 14 | ||
15 | using namespace Opie::Ui; | 15 | using namespace Opie::Ui; |
16 | 16 | ||
17 | 17 | ||
18 | /** | 18 | /** |
19 | * The default Constructor of a OKeyPair. | 19 | * The default Constructor of a OKeyPair. |
20 | * A Key and a Modifier ( Alt/Shift/Ctrl ) | 20 | * A Key and a Modifier ( Alt/Shift/Ctrl ) |
21 | * needs to be supplied. | 21 | * needs to be supplied. |
22 | * Use Qt::Key for the information. | 22 | * Use Qt::Key for the information. |
23 | * The default arguments create an Empty OKeyPair. If you | 23 | * The default arguments create an Empty OKeyPair. If you |
24 | * want to get an empty OKeyPair use the static method for getting | 24 | * want to get an empty OKeyPair use the static method for getting |
25 | * the emptyKey() | 25 | * the emptyKey() |
26 | * | 26 | * |
27 | * @see OKeyPair OKeyPair::emptyKey() | 27 | * @see OKeyPair OKeyPair::emptyKey() |
28 | */ | 28 | */ |
29 | OKeyPair::OKeyPair( int key, int mod ) | 29 | OKeyPair::OKeyPair( int key, int mod ) |
30 | : m_key( key ), m_mod( mod ) | 30 | : m_key( key ), m_mod( mod ) |
31 | {} | 31 | {} |
32 | 32 | ||
33 | /** | 33 | /** |
34 | * The destructor | 34 | * The destructor |
35 | */ | 35 | */ |
36 | OKeyPair::~OKeyPair() {} | 36 | OKeyPair::~OKeyPair() {} |
37 | 37 | ||
38 | 38 | ||
39 | /** | 39 | /** |
40 | * Is this OKeyPair empty/valid? | 40 | * Is this OKeyPair empty/valid? |
41 | */ | 41 | */ |
42 | bool OKeyPair::isEmpty()const { | 42 | bool OKeyPair::isEmpty()const { |
43 | return ( ( m_key == -1 )&& ( m_mod == -1 ) ); | 43 | return ( ( m_key == -1 )&& ( m_mod == -1 ) ); |
44 | } | 44 | } |
45 | 45 | ||
46 | /** | 46 | /** |
47 | * get the keycode for this OKeyPair. The Key relates to Qt::Key. | 47 | * get the keycode for this OKeyPair. The Key relates to Qt::Key. |
48 | * | 48 | * |
49 | * @see Qt::Key | 49 | * @see Qt::Key |
50 | * @see setKey | 50 | * @see setKey |
51 | */ | 51 | */ |
52 | int OKeyPair::keycode()const { | 52 | int OKeyPair::keycode()const { |
53 | return m_key; | 53 | return m_key; |
54 | } | 54 | } |
55 | 55 | ||
56 | /** | 56 | /** |
57 | * get the modifier key for this OKeyPair. The Modifier State relates | 57 | * get the modifier key for this OKeyPair. The Modifier State relates |
58 | * to the Qt::ButtonState | 58 | * to the Qt::ButtonState |
59 | * | 59 | * |
60 | * @see Qt::ButtonState | 60 | * @see Qt::ButtonState |
61 | * @see setModifier | 61 | * @see setModifier |
62 | */ | 62 | */ |
63 | int OKeyPair::modifier()const { | 63 | int OKeyPair::modifier()const { |
64 | return m_mod; | 64 | return m_mod; |
65 | } | 65 | } |
66 | 66 | ||
67 | 67 | ||
68 | /** | 68 | /** |
69 | * Set the keycode | 69 | * Set the keycode |
70 | * @param key The Keycode to set | 70 | * @param key The Keycode to set |
71 | * | 71 | * |
72 | * @see keycode() | 72 | * @see keycode() |
73 | * @see Qt::Key | 73 | * @see Qt::Key |
74 | */ | 74 | */ |
75 | void OKeyPair::setKeycode( int key ) { | 75 | void OKeyPair::setKeycode( int key ) { |
76 | m_key = key; | 76 | m_key = key; |
77 | } | 77 | } |
78 | 78 | ||
79 | /** | 79 | /** |
80 | * Set the modifier key | 80 | * Set the modifier key |
81 | * | 81 | * |
82 | * @param the Modifier key | 82 | * @param the Modifier key |
83 | * @see Qt::ButtonState | 83 | * @see Qt::ButtonState |
84 | * @see modifier() | 84 | * @see modifier() |
85 | */ | 85 | */ |
86 | void OKeyPair::setModifier( int mod ) { | 86 | void OKeyPair::setModifier( int mod ) { |
87 | m_mod = mod; | 87 | m_mod = mod; |
88 | } | 88 | } |
89 | 89 | ||
90 | /** | 90 | /** |
91 | * Return an OKeyPair for the Return Key without any modifier. | 91 | * Return an OKeyPair for the Return Key without any modifier. |
92 | */ | 92 | */ |
93 | OKeyPair OKeyPair::returnKey() { | 93 | OKeyPair OKeyPair::returnKey() { |
94 | return OKeyPair( Qt::Key_Return, 0 ); | 94 | return OKeyPair( Qt::Key_Return, 0 ); |
95 | } | 95 | } |
96 | 96 | ||
97 | /** | 97 | /** |
98 | * Return an OKeyPair for the Left Arrow Key | 98 | * Return an OKeyPair for the Left Arrow Key |
99 | * without any modifier Key | 99 | * without any modifier Key |
100 | */ | 100 | */ |
101 | OKeyPair OKeyPair::leftArrowKey() { | 101 | OKeyPair OKeyPair::leftArrowKey() { |
102 | return OKeyPair( Qt::Key_Left, 0 ); | 102 | return OKeyPair( Qt::Key_Left, 0 ); |
103 | } | 103 | } |
104 | 104 | ||
105 | /** | 105 | /** |
106 | * Return an OKeyPair for the Right Arrow Key | 106 | * Return an OKeyPair for the Right Arrow Key |
107 | * without any modifier Key | 107 | * without any modifier Key |
108 | */ | 108 | */ |
109 | OKeyPair OKeyPair::rightArrowKey() { | 109 | OKeyPair OKeyPair::rightArrowKey() { |
110 | return OKeyPair( Qt::Key_Right, 0 ); | 110 | return OKeyPair( Qt::Key_Right, 0 ); |
111 | } | 111 | } |
112 | 112 | ||
113 | /** | 113 | /** |
114 | * Return an OKeyPair for the Up Arrow Key | 114 | * Return an OKeyPair for the Up Arrow Key |
115 | * without any modifier Key | 115 | * without any modifier Key |
116 | */ | 116 | */ |
117 | OKeyPair OKeyPair::upArrowKey() { | 117 | OKeyPair OKeyPair::upArrowKey() { |
118 | return OKeyPair( Qt::Key_Up, 0 ); | 118 | return OKeyPair( Qt::Key_Up, 0 ); |
119 | } | 119 | } |
120 | 120 | ||
121 | /** | 121 | /** |
122 | * Return an OKeyPair for the Down Arrow Key | 122 | * Return an OKeyPair for the Down Arrow Key |
123 | * without any modifier Key | 123 | * without any modifier Key |
124 | */ | 124 | */ |
125 | OKeyPair OKeyPair::downArrowKey() { | 125 | OKeyPair OKeyPair::downArrowKey() { |
126 | return OKeyPair( Qt::Key_Down, 0 ); | 126 | return OKeyPair( Qt::Key_Down, 0 ); |
127 | } | 127 | } |
128 | 128 | ||
129 | /** | 129 | /** |
130 | * Return an Empty OKeyPair | 130 | * Return an Empty OKeyPair |
131 | */ | 131 | */ |
132 | OKeyPair OKeyPair::emptyKey() { | 132 | OKeyPair OKeyPair::emptyKey() { |
133 | return OKeyPair(); | 133 | return OKeyPair(); |
134 | } | 134 | } |
135 | 135 | ||
136 | /** | 136 | /** |
137 | * This functions uses the Opie::Core::ODevice::buttons | 137 | * This functions uses the Opie::Core::ODevice::buttons |
138 | * for OKeyPairList | 138 | * for OKeyPairList |
139 | * | 139 | * |
140 | * @see Opie::Core::ODevice | 140 | * @see Opie::Core::ODevice |
141 | * @see Opie::Core::ODeviceButton | 141 | * @see Opie::Core::ODeviceButton |
142 | * @see Opie::Core::ODevice::button | 142 | * @see Opie::Core::ODevice::button |
143 | */ | 143 | */ |
144 | OKeyPair::List OKeyPair::hardwareKeys() { | 144 | OKeyPair::List OKeyPair::hardwareKeys() { |
145 | const QValueList<Opie::Core::ODeviceButton> but = Opie::Core::ODevice::inst()->buttons(); | 145 | const QValueList<Opie::Core::ODeviceButton> but = Opie::Core::ODevice::inst()->buttons(); |
146 | OKeyPair::List lst; | 146 | OKeyPair::List lst; |
147 | 147 | ||
148 | for ( QValueList<Opie::Core::ODeviceButton>::ConstIterator it = but.begin(); | 148 | for ( QValueList<Opie::Core::ODeviceButton>::ConstIterator it = but.begin(); |
149 | it != but.end(); ++it ) | 149 | it != but.end(); ++it ) |
150 | lst.append( OKeyPair( (*it).keycode(), 0 ) ); | 150 | lst.append( OKeyPair( (*it).keycode(), 0 ) ); |
151 | 151 | ||
152 | 152 | ||
153 | return lst; | 153 | return lst; |
154 | } | 154 | } |
155 | 155 | ||
156 | /** | 156 | /** |
157 | * Equals operator. Check if two OKeyPairs have the same key and modifier | 157 | * Equals operator. Check if two OKeyPairs have the same key and modifier |
158 | * @see operator!= | 158 | * @see operator!= |
159 | */ | 159 | */ |
160 | bool OKeyPair::operator==( const OKeyPair& pair) { | 160 | bool OKeyPair::operator==( const OKeyPair& pair) { |
161 | if ( m_key != pair.m_key ) return false; | 161 | if ( m_key != pair.m_key ) return false; |
162 | if ( m_mod != pair.m_mod ) return false; | 162 | if ( m_mod != pair.m_mod ) return false; |
163 | 163 | ||
164 | return true; | 164 | return true; |
165 | } | 165 | } |
166 | 166 | ||
167 | /** | 167 | /** |
168 | * Not equal operator. calls the equal operator internally | 168 | * Not equal operator. calls the equal operator internally |
169 | */ | 169 | */ |
170 | bool OKeyPair::operator!=( const OKeyPair& pair) { | 170 | bool OKeyPair::operator!=( const OKeyPair& pair) { |
171 | return !(*this == pair); | 171 | return !(*this == pair); |
172 | } | 172 | } |
173 | 173 | ||
174 | 174 | ||
175 | /** | 175 | /** |
176 | * The normal Constructor to create a OKeyConfigItem | 176 | * The normal Constructor to create a OKeyConfigItem |
177 | * | 177 | * |
178 | * You can set the the key paramater of this item but if | 178 | * You can set the the key paramater of this item but if |
179 | * you use this item with the OKeyConfigManager your setting | 179 | * you use this item with the OKeyConfigManager your setting |
180 | * will be overwritten. | 180 | * will be overwritten. |
181 | * You can also specify a QObject and slot which sould get called | 181 | * You can also specify a QObject and slot which sould get called |
182 | * once this item is activated. This slot only works if you | 182 | * once this item is activated. This slot only works if you |
183 | * use the OKeyConfigManager. | 183 | * use the OKeyConfigManager. |
184 | * The actual Key is read by load() | 184 | * The actual Key is read by load() |
185 | * | 185 | * |
186 | * \code | 186 | * \code |
187 | * void MySlot::create(){ | 187 | * void MySlot::create(){ |
188 | * OKeyConfigItem item(tr("Delete"),"delete",Resource::loadPixmap("trash"), | 188 | * OKeyConfigItem item(tr("Delete"),"delete",Resource::loadPixmap("trash"), |
189 | * 123, OKeyPair(Qt::Key_D,Qt::ControlButton), | 189 | * 123, OKeyPair(Qt::Key_D,Qt::ControlButton), |
190 | * this,SLOT(slotDelete(QWidget*,QKeyEvent*))); | 190 | * this,SLOT(slotDelete(QWidget*,QKeyEvent*))); |
191 | * } | 191 | * } |
192 | * \endcode | 192 | * \endcode |
193 | * | 193 | * |
194 | * @param text The text exposed to the user | 194 | * @param text The text exposed to the user |
195 | * @param config_key The key used in the config | 195 | * @param config_key The key used in the config |
196 | * @param pix A Pixmap associated with this Item | 196 | * @param pix A Pixmap associated with this Item |
197 | * @param def The OKeyPair used as default | 197 | * @param def The OKeyPair used as default |
198 | * @param caller The object where the slot exists | 198 | * @param caller The object where the slot exists |
199 | * @param slot The slot which should get called | 199 | * @param slot The slot which should get called |
200 | * | 200 | * |
201 | */ | 201 | */ |
202 | OKeyConfigItem::OKeyConfigItem( const QString& text, const QCString& config_key, | 202 | OKeyConfigItem::OKeyConfigItem( const QString& text, const QCString& config_key, |
203 | const QPixmap& pix, int id, const OKeyPair& def, | 203 | const QPixmap& pix, int id, const OKeyPair& def, |
204 | QObject *caller, | 204 | QObject *caller, |
205 | const char* slot ) | 205 | const char* slot ) |
206 | : m_text( text ), m_config( config_key ), m_pix( pix ), | 206 | : m_text( text ), m_config( config_key ), m_pix( pix ), |
207 | m_id( id ), m_def( def ), | 207 | m_id( id ), m_def( def ), |
208 | m_obj( caller ), m_str( slot ) {} | 208 | m_obj( caller ), m_str( slot ) {} |
209 | 209 | ||
210 | /** | 210 | /** |
211 | * A special Constructor for converting from an Opie::Core::ODeviceButton | 211 | * A special Constructor for converting from an Opie::Core::ODeviceButton |
212 | * delivered by Opie::Core::ODevice::buttons() | 212 | * delivered by Opie::Core::ODevice::buttons() |
213 | * There is no Config Key set and both default key and key are set | 213 | * There is no Config Key set and both default key and key are set |
214 | * to Opie::Core::ODeviceButton::keycode() and 0 to modifier | 214 | * to Opie::Core::ODeviceButton::keycode() and 0 to modifier |
215 | * | 215 | * |
216 | * @see Opie::Core::ODevice | 216 | * @see Opie::Core::ODevice |
217 | * @see Opie::Core::ODeviceButton | 217 | * @see Opie::Core::ODeviceButton |
218 | * @see Opie::Core::ODevice::buttons() | 218 | * @see Opie::Core::ODevice::buttons() |
219 | */ | 219 | */ |
220 | OKeyConfigItem::OKeyConfigItem( const Opie::Core::ODeviceButton& b ) | 220 | OKeyConfigItem::OKeyConfigItem( const Opie::Core::ODeviceButton& b ) |
221 | : m_text( b.userText() ), m_pix( b.pixmap() ), m_id( -1 ), | 221 | : m_text( b.userText() ), m_pix( b.pixmap() ), m_id( -1 ), |
222 | m_key( OKeyPair( b.keycode(), 0 ) ), m_def( OKeyPair( b.keycode(), 0 ) ) | 222 | m_key( OKeyPair( b.keycode(), 0 ) ), m_def( OKeyPair( b.keycode(), 0 ) ) |
223 | {} | 223 | {} |
224 | 224 | ||
225 | 225 | ||
226 | /** | 226 | /** |
227 | * Destructor | 227 | * Destructor |
228 | */ | 228 | */ |
229 | OKeyConfigItem::~OKeyConfigItem() {} | 229 | OKeyConfigItem::~OKeyConfigItem() {} |
230 | 230 | ||
231 | 231 | ||
232 | /** | 232 | /** |
233 | * The text exposed to the user | 233 | * The text exposed to the user |
234 | * | 234 | * |
235 | * @see setText | 235 | * @see setText |
236 | */ | 236 | */ |
237 | QString OKeyConfigItem::text()const { | 237 | QString OKeyConfigItem::text()const { |
238 | return m_text; | 238 | return m_text; |
239 | } | 239 | } |
240 | 240 | ||
241 | /** | 241 | /** |
242 | * The pixmap shown to the user for your action/key | 242 | * The pixmap shown to the user for your action/key |
243 | * | 243 | * |
244 | * @see setPixmap | 244 | * @see setPixmap |
245 | */ | 245 | */ |
246 | QPixmap OKeyConfigItem::pixmap()const { | 246 | QPixmap OKeyConfigItem::pixmap()const { |
247 | return m_pix; | 247 | return m_pix; |
248 | } | 248 | } |
249 | 249 | ||
250 | /** | 250 | /** |
251 | * Return the OKeyPair this OKeyConfigItem is configured for. | 251 | * Return the OKeyPair this OKeyConfigItem is configured for. |
252 | * | 252 | * |
253 | * @see setKeyPair | 253 | * @see setKeyPair |
254 | */ | 254 | */ |
255 | OKeyPair OKeyConfigItem::keyPair()const { | 255 | OKeyPair OKeyConfigItem::keyPair()const { |
256 | return m_key; | 256 | return m_key; |
257 | } | 257 | } |
258 | 258 | ||
259 | /** | 259 | /** |
260 | * Return the default OKeyPair | 260 | * Return the default OKeyPair |
261 | * @see setDefaultKeyPair | 261 | * @see setDefaultKeyPair |
262 | */ | 262 | */ |
263 | OKeyPair OKeyConfigItem::defaultKeyPair()const { | 263 | OKeyPair OKeyConfigItem::defaultKeyPair()const { |
264 | return m_def; | 264 | return m_def; |
265 | } | 265 | } |
266 | 266 | ||
267 | 267 | ||
268 | /** | 268 | /** |
269 | * Return the Id you assigned to this item. | 269 | * Return the Id you assigned to this item. |
270 | * setting is only possible by the constructor | 270 | * setting is only possible by the constructor |
271 | */ | 271 | */ |
272 | int OKeyConfigItem::id()const{ | 272 | int OKeyConfigItem::id()const{ |
273 | return m_id; | 273 | return m_id; |
274 | } | 274 | } |
275 | 275 | ||
276 | /** | 276 | /** |
277 | * reutrn the Config Key. Setting it is only possible | 277 | * reutrn the Config Key. Setting it is only possible |
278 | * by the constructor | 278 | * by the constructor |
279 | */ | 279 | */ |
280 | QCString OKeyConfigItem::configKey()const { | 280 | QCString OKeyConfigItem::configKey()const { |
281 | return m_config; | 281 | return m_config; |
282 | } | 282 | } |
283 | 283 | ||
284 | /** | 284 | /** |
285 | * @internal | 285 | * @internal |
286 | */ | 286 | */ |
287 | QObject* OKeyConfigItem::object()const{ | 287 | QObject* OKeyConfigItem::object()const{ |
288 | return m_obj; | 288 | return m_obj; |
289 | } | 289 | } |
290 | 290 | ||
291 | /** | 291 | /** |
292 | * @internal | 292 | * @internal |
293 | */ | 293 | */ |
294 | QCString OKeyConfigItem::slot()const { | 294 | QCString OKeyConfigItem::slot()const { |
295 | return m_str; | 295 | return m_str; |
296 | } | 296 | } |
297 | 297 | ||
298 | /** | 298 | /** |
299 | * Set the text | 299 | * Set the text |
300 | * | 300 | * |
301 | * @param text Set the Text of this Action to text | 301 | * @param text Set the Text of this Action to text |
302 | * @see text() | 302 | * @see text() |
303 | */ | 303 | */ |
304 | void OKeyConfigItem::setText( const QString& text ) { | 304 | void OKeyConfigItem::setText( const QString& text ) { |
305 | m_text = text; | 305 | m_text = text; |
306 | } | 306 | } |
307 | 307 | ||
308 | /** | 308 | /** |
309 | * Set the pixmap of this action | 309 | * Set the pixmap of this action |
310 | * | 310 | * |
311 | * @param pix The Pixmap to set | 311 | * @param pix The Pixmap to set |
312 | * @see pixmap() | 312 | * @see pixmap() |
313 | */ | 313 | */ |
314 | void OKeyConfigItem::setPixmap( const QPixmap& pix ) { | 314 | void OKeyConfigItem::setPixmap( const QPixmap& pix ) { |
315 | m_pix = pix; | 315 | m_pix = pix; |
316 | } | 316 | } |
317 | 317 | ||
318 | /** | 318 | /** |
319 | * Set the KeyPair the OKeyConfigItem uses. | 319 | * Set the KeyPair the OKeyConfigItem uses. |
320 | * Your set Key could get overwritten if you use | 320 | * Your set Key could get overwritten if you use |
321 | * the manager or GUI to configure the key | 321 | * the manager or GUI to configure the key |
322 | * | 322 | * |
323 | * @param key Set the OKeyPair used | 323 | * @param key Set the OKeyPair used |
324 | * @see keyPair() | 324 | * @see keyPair() |
325 | */ | 325 | */ |
326 | void OKeyConfigItem::setKeyPair( const OKeyPair& key) { | 326 | void OKeyConfigItem::setKeyPair( const OKeyPair& key) { |
327 | m_key = key; | 327 | m_key = key; |
328 | } | 328 | } |
329 | 329 | ||
330 | /** | 330 | /** |
331 | * Set the default KeyPair. | 331 | * Set the default KeyPair. |
332 | * | 332 | * |
333 | * @param key The default keypair | 333 | * @param key The default keypair |
334 | * @see defaultKeyPair() | 334 | * @see defaultKeyPair() |
335 | */ | 335 | */ |
336 | void OKeyConfigItem::setDefaultKeyPair( const OKeyPair& key ) { | 336 | void OKeyConfigItem::setDefaultKeyPair( const OKeyPair& key ) { |
337 | m_def = key; | 337 | m_def = key; |
338 | } | 338 | } |
339 | 339 | ||
340 | /** | 340 | /** |
341 | * @internal | 341 | * @internal |
342 | */ | 342 | */ |
343 | void OKeyConfigItem::setConfigKey( const QCString& str) { | 343 | void OKeyConfigItem::setConfigKey( const QCString& str) { |
344 | m_config = str; | 344 | m_config = str; |
345 | m_config.detach(); | 345 | m_config.detach(); |
346 | } | 346 | } |
347 | 347 | ||
348 | /** | 348 | /** |
349 | * @internal | 349 | * @internal |
350 | */ | 350 | */ |
351 | void OKeyConfigItem::setId( int id ) { | 351 | void OKeyConfigItem::setId( int id ) { |
352 | m_id = id; | 352 | m_id = id; |
353 | } | 353 | } |
354 | 354 | ||
355 | /** | 355 | /** |
356 | * If the item is not configured isEmpty() will return true | 356 | * If the item is not configured isEmpty() will return true |
357 | * It is empty if no text is present and no default | 357 | * It is empty if no text is present and no default |
358 | * and no configured key | 358 | * and no configured key |
359 | */ | 359 | */ |
360 | bool OKeyConfigItem::isEmpty()const { | 360 | bool OKeyConfigItem::isEmpty()const { |
361 | if ( !m_def.isEmpty() ) return false; | 361 | if ( !m_def.isEmpty() ) return false; |
362 | if ( !m_key.isEmpty() ) return false; | 362 | if ( !m_key.isEmpty() ) return false; |
363 | if ( !m_text.isEmpty() ) return false; | 363 | if ( !m_text.isEmpty() ) return false; |
364 | 364 | ||
365 | return true; | 365 | return true; |
366 | } | 366 | } |
367 | 367 | ||
368 | /** | 368 | /** |
369 | * Check if the KeyPairs are the same | 369 | * Check if the KeyPairs are the same |
370 | */ | 370 | */ |
371 | bool OKeyConfigItem::operator==( const OKeyConfigItem& conf ) { | 371 | bool OKeyConfigItem::operator==( const OKeyConfigItem& conf ) { |
372 | if ( isEmpty() == conf.isEmpty() ) return true; | 372 | if ( isEmpty() == conf.isEmpty() ) return true; |
373 | else if ( isEmpty() != conf.isEmpty() ) return false; | 373 | else if ( isEmpty() != conf.isEmpty() ) return false; |
374 | else if ( !isEmpty()!= conf.isEmpty() ) return false; | 374 | else if ( !isEmpty()!= conf.isEmpty() ) return false; |
375 | 375 | ||
376 | if ( m_id != conf.m_id ) return false; | 376 | if ( m_id != conf.m_id ) return false; |
377 | if ( m_text != conf.m_text ) return false; | 377 | if ( m_text != conf.m_text ) return false; |
378 | if ( m_key != conf.m_key ) return false; | 378 | if ( m_key != conf.m_key ) return false; |
379 | if ( m_def != conf.m_def ) return false; | 379 | if ( m_def != conf.m_def ) return false; |
380 | 380 | ||
381 | return true; | 381 | return true; |
382 | 382 | ||
383 | } | 383 | } |
384 | 384 | ||
385 | bool OKeyConfigItem::operator!=( const OKeyConfigItem& conf ) { | 385 | bool OKeyConfigItem::operator!=( const OKeyConfigItem& conf ) { |
386 | return !( *this == conf ); | 386 | return !( *this == conf ); |
387 | } | 387 | } |
388 | 388 | ||
389 | /** | 389 | /** |
390 | * \brief c'tor | 390 | * \brief c'tor |
391 | * The Constructor for a OKeyConfigManager | 391 | * The Constructor for a OKeyConfigManager |
392 | * | 392 | * |
393 | * You can use this manager in multiple ways. Either make it handle | 393 | * You can use this manager in multiple ways. Either make it handle |
394 | * QKeyEvents | 394 | * QKeyEvents |
395 | * | 395 | * |
396 | * \code | 396 | * \code |
397 | * Opie::Core::Config conf = oApp->config(); | 397 | * Opie::Core::Config conf = oApp->config(); |
398 | * Opie::Ui::OKeyPairList blackList; | 398 | * Opie::Ui::OKeyPairList blackList; |
399 | * blackList.append(Opie::Ui::OKeyPair::leftArrowKey()); | 399 | * blackList.append(Opie::Ui::OKeyPair::leftArrowKey()); |
400 | * blackList.append(Opie::Ui::OKeyPair::rightArrowKey()); | 400 | * blackList.append(Opie::Ui::OKeyPair::rightArrowKey()); |
401 | * Opie::Ui::OKeyConfigManager *manager = new Opie::Ui::OKeyConfigManager(conf,"key_actions",blackList, | 401 | * Opie::Ui::OKeyConfigManager *manager = new Opie::Ui::OKeyConfigManager(conf,"key_actions",blackList, |
402 | * false); | 402 | * false); |
403 | * QListView *view = new QListView(); | 403 | * QListView *view = new QListView(); |
404 | * manager->handleWidget(view); | 404 | * manager->handleWidget(view); |
405 | * manager->addKeyConfig( Opie::Ui::OKeyPair::returnKey()); | 405 | * manager->addKeyConfig( Opie::Ui::OKeyPair::returnKey()); |
406 | * manager->load(); | 406 | * manager->load(); |
407 | * | 407 | * |
408 | * connect(manager,SIGNAL(actionActivated(QWidget*,QKeyEvent*,const Opie::Ui::OKeyConfigItem&)), | 408 | * connect(manager,SIGNAL(actionActivated(QWidget*,QKeyEvent*,const Opie::Ui::OKeyConfigItem&)), |
409 | * this,SLOT(slotHandleKey(QWidget*,QKeyEvent*,const Opie::Ui::OKeyConfigItem&))); | 409 | * this,SLOT(slotHandleKey(QWidget*,QKeyEvent*,const Opie::Ui::OKeyConfigItem&))); |
410 | * | 410 | * |
411 | * .... | 411 | * .... |
412 | * | 412 | * |
413 | * void update(){ | 413 | * void update(){ |
414 | * QDialog diag(true); | 414 | * QDialog diag(true); |
415 | * QHBoxLayout *lay = new QHBoxLayout(&diag); | 415 | * QHBoxLayout *lay = new QHBoxLayout(&diag); |
416 | * Opie::Ui::OKeyConfigWidget *wid = new Opie::Ui::OKeyConfigWidget(manager,&diag); | 416 | * Opie::Ui::OKeyConfigWidget *wid = new Opie::Ui::OKeyConfigWidget(manager,&diag); |
417 | * wid->setChangeMode(Opie::Ui::OKeyConfigWidget::Queu); | 417 | * wid->setChangeMode(Opie::Ui::OKeyConfigWidget::Queu); |
418 | * lay->addWidget(wid); | 418 | * lay->addWidget(wid); |
419 | * if(QPEApplication::execDialog( &diag)== QDialog::Accepted){ | 419 | * if(QPEApplication::execDialog( &diag)== QDialog::Accepted){ |
420 | * wid->save(); | 420 | * wid->save(); |
421 | * } | 421 | * } |
422 | * } | 422 | * } |
423 | * | 423 | * |
424 | * .... | 424 | * .... |
425 | * MyListView::keyPressEvent( QKeyEvent* e ){ | 425 | * MyListView::keyPressEvent( QKeyEvent* e ){ |
426 | * Opie::Ui::OKeyConfigItem item = manager->handleKeyEvent(e); | 426 | * Opie::Ui::OKeyConfigItem item = manager->handleKeyEvent(e); |
427 | * if(!item.isEmpty() ){ | 427 | * if(!item.isEmpty() ){ |
428 | * switch(item.id()){ | 428 | * switch(item.id()){ |
429 | * case My_Delete_Key: | 429 | * case My_Delete_Key: |
430 | * break; | 430 | * break; |
431 | * } | 431 | * } |
432 | * } | 432 | * } |
433 | * } | 433 | * } |
434 | * | 434 | * |
435 | * \endcode | 435 | * \endcode |
436 | * | 436 | * |
437 | * @param conf The Config where the KeySetting should be stored | 437 | * @param conf The Config where the KeySetting should be stored |
438 | * @param group The group where the KeySetting will be stored | 438 | * @param group The group where the KeySetting will be stored |
439 | * @param black Which keys shouldn't be allowed to handle | 439 | * @param black Which keys shouldn't be allowed to handle |
440 | * @param grabkeyboard Calls QPEApplication::grabKeyboard to allow handling of DeviceButtons | 440 | * @param grabkeyboard Calls QPEApplication::grabKeyboard to allow handling of DeviceButtons |
441 | * @param par The parent/owner of this manager | 441 | * @param par The parent/owner of this manager |
442 | * @param name The name of this object | 442 | * @param name The name of this object |
443 | */ | 443 | */ |
444 | OKeyConfigManager::OKeyConfigManager( Opie::Core::OConfig* conf, | 444 | OKeyConfigManager::OKeyConfigManager( Opie::Core::OConfig* conf, |
445 | const QString& group, | 445 | const QString& group, |
446 | const OKeyPair::List& black, | 446 | const OKeyPair::List& black, |
447 | bool grabkeyboard, QObject* par, | 447 | bool grabkeyboard, QObject* par, |
448 | const char* name) | 448 | const char* name) |
449 | : QObject( par, name ), m_conf( conf ), m_group( group ), | 449 | : QObject( par, name ), m_conf( conf ), m_group( group ), |
450 | m_blackKeys( black ), m_grab( grabkeyboard ), m_map( 0 ){ | 450 | m_blackKeys( black ), m_grab( grabkeyboard ), m_map( 0 ){ |
451 | if ( m_grab ) | 451 | if ( m_grab ) |
452 | QPEApplication::grabKeyboard(); | 452 | QPEApplication::grabKeyboard(); |
453 | } | 453 | } |
454 | 454 | ||
455 | 455 | ||
456 | /** | 456 | /** |
457 | * Destructor | 457 | * Destructor |
458 | */ | 458 | */ |
459 | OKeyConfigManager::~OKeyConfigManager() { | 459 | OKeyConfigManager::~OKeyConfigManager() { |
460 | if ( m_grab ) | 460 | if ( m_grab ) |
461 | QPEApplication::ungrabKeyboard(); | 461 | QPEApplication::ungrabKeyboard(); |
462 | } | 462 | } |
463 | 463 | ||
464 | /** | 464 | /** |
465 | * Load the Configuration from the OConfig | 465 | * Load the Configuration from the OConfig |
466 | * If a Key is restricted but was in the config we will | 466 | * If a Key is restricted but was in the config we will |
467 | * make it be the empty key paur | 467 | * make it be the empty key paur |
468 | * We will change the group of the OConfig Item! | 468 | * We will change the group of the OConfig Item! |
469 | * | 469 | * |
470 | * @see OKeyPair::emptyKey | 470 | * @see OKeyPair::emptyKey |
471 | */ | 471 | */ |
472 | void OKeyConfigManager::load() { | 472 | void OKeyConfigManager::load() { |
473 | m_conf->setGroup( m_group ); | 473 | m_conf->setGroup( m_group ); |
474 | 474 | ||
475 | /* | 475 | /* |
476 | * Read each item | 476 | * Read each item |
477 | */ | 477 | */ |
478 | int key, mod; | 478 | int key, mod; |
479 | for( OKeyConfigItem::List::Iterator it = m_keys.begin(); | 479 | for( OKeyConfigItem::List::Iterator it = m_keys.begin(); |
480 | it != m_keys.end(); ++it ) { | 480 | it != m_keys.end(); ++it ) { |
481 | key = m_conf->readNumEntry( (*it).configKey()+"key", (*it).defaultKeyPair().keycode() ); | 481 | key = m_conf->readNumEntry( (*it).configKey()+"key", (*it).defaultKeyPair().keycode() ); |
482 | mod = m_conf->readNumEntry( (*it).configKey()+"mod", (*it).defaultKeyPair().modifier() ); | 482 | mod = m_conf->readNumEntry( (*it).configKey()+"mod", (*it).defaultKeyPair().modifier() ); |
483 | OKeyPair okey( key, mod ); | 483 | OKeyPair okey( key, mod ); |
484 | if ( !m_blackKeys.contains( okey ) && key != -1 && mod != -1 ) | 484 | if ( !m_blackKeys.contains( okey ) && key != -1 && mod != -1 ) |
485 | (*it).setKeyPair( OKeyPair(key, mod) ); | 485 | (*it).setKeyPair( OKeyPair(key, mod) ); |
486 | else | 486 | else |
487 | (*it).setKeyPair( OKeyPair::emptyKey() ); | 487 | (*it).setKeyPair( OKeyPair::emptyKey() ); |
488 | } | 488 | } |
489 | delete m_map; m_map = 0; | 489 | delete m_map; m_map = 0; |
490 | } | 490 | } |
491 | 491 | ||
492 | /** | 492 | /** |
493 | * We will save the current configuration | 493 | * We will save the current configuration |
494 | * to the OConfig. We will change the group. | 494 | * to the OConfig. We will change the group. |
495 | */ | 495 | */ |
496 | void OKeyConfigManager::save() { | 496 | void OKeyConfigManager::save() { |
497 | m_conf->setGroup( m_group ); | 497 | m_conf->setGroup( m_group ); |
498 | 498 | ||
499 | /* | 499 | /* |
500 | * Write each item | 500 | * Write each item |
501 | */ | 501 | */ |
502 | for( OKeyConfigItem::List::Iterator it = m_keys.begin(); | 502 | for( OKeyConfigItem::List::Iterator it = m_keys.begin(); |
503 | it != m_keys.end(); ++it ) { | 503 | it != m_keys.end(); ++it ) { |
504 | if ( (*it).isEmpty() ) | 504 | if ( (*it).isEmpty() ) |
505 | continue; | 505 | continue; |
506 | OKeyPair pair = (*it).keyPair(); | 506 | OKeyPair pair = (*it).keyPair(); |
507 | OKeyPair deft = (*it).defaultKeyPair(); | ||
508 | /* don't write if it is the default setting */ | ||
509 | if ( (pair.keycode() == deft.keycode()) && | ||
510 | (pair.modifier()== deft.modifier() ) ) | ||
511 | return; | ||
512 | |||
507 | m_conf->writeEntry((*it).configKey()+"key", pair.keycode() ); | 513 | m_conf->writeEntry((*it).configKey()+"key", pair.keycode() ); |
508 | m_conf->writeEntry((*it).configKey()+"mod", pair.modifier() ); | 514 | m_conf->writeEntry((*it).configKey()+"mod", pair.modifier() ); |
509 | } | 515 | } |
510 | } | 516 | } |
511 | 517 | ||
512 | /** | 518 | /** |
513 | * This is function uses a QMap internally but you can have the same keycode | 519 | * This is function uses a QMap internally but you can have the same keycode |
514 | * with different modifier key. The behaviour is undefined if you add a OKeyConfigItem | 520 | * with different modifier key. The behaviour is undefined if you add a OKeyConfigItem |
515 | * with same keycode and modifier key. The GUI takes care that a user can't | 521 | * with same keycode and modifier key. The GUI takes care that a user can't |
516 | * cofigure two keys. | 522 | * cofigure two keys. |
517 | * | 523 | * |
518 | * Make sure you call e->ignore if you don't want to handle this event | 524 | * Make sure you call e->ignore if you don't want to handle this event |
519 | */ | 525 | */ |
520 | OKeyConfigItem OKeyConfigManager::handleKeyEvent( QKeyEvent* e ) { | 526 | OKeyConfigItem OKeyConfigManager::handleKeyEvent( QKeyEvent* e ) { |
521 | OKeyConfigItem::List _keyList = keyList( e->key() ); | 527 | /* |
528 | * Fix Up issues with Qt/E, my keybard, and virtual input | ||
529 | * methods | ||
530 | * First my Keyboard delivers 256,512,1024 for shift/ctrl/alt instead of the button state | ||
531 | * Also key() on virtual inputmethods are zero and only ascii. We need to fix upper and lower | ||
532 | * case ascii | ||
533 | */ | ||
534 | int key = e->key(); | ||
535 | int mod = e->state(); | ||
536 | |||
537 | /* | ||
538 | * virtual keyboard | ||
539 | * else change the button mod only | ||
540 | */ | ||
541 | qWarning( "handleKeyEvent...." ); | ||
542 | if ( key == 0 ) { | ||
543 | key = e->ascii(); | ||
544 | if ( key > 96 && key < 123) | ||
545 | key -= 32; | ||
546 | }else{ | ||
547 | int new_mod = 0; | ||
548 | if ( mod & 256 ) | ||
549 | new_mod |= Qt::ShiftButton; | ||
550 | else if ( mod & 512 ) | ||
551 | new_mod |= Qt::AltButton; | ||
552 | else if ( mod & 1024 ) | ||
553 | new_mod |= Qt::ControlButton; | ||
554 | |||
555 | mod = new_mod == 0? mod : new_mod; | ||
556 | } | ||
557 | |||
558 | OKeyConfigItem::List _keyList = keyList( key ); | ||
522 | if ( _keyList.isEmpty() ) | 559 | if ( _keyList.isEmpty() ) |
523 | return OKeyConfigItem(); | 560 | return OKeyConfigItem(); |
524 | 561 | ||
525 | OKeyConfigItem item; | 562 | OKeyConfigItem item; |
526 | for ( OKeyConfigItem::List::Iterator it = _keyList.begin(); it != _keyList.end(); | 563 | for ( OKeyConfigItem::List::Iterator it = _keyList.begin(); it != _keyList.end(); |
527 | ++it ) { | 564 | ++it ) { |
528 | if ( (*it).keyPair().modifier() == e->state() ) { | 565 | if ( (*it).keyPair().modifier() == mod ) { |
529 | item = *it; | 566 | item = *it; |
530 | break; | 567 | break; |
531 | } | 568 | } |
532 | 569 | ||
533 | } | 570 | } |
534 | 571 | ||
535 | return item; | 572 | return item; |
536 | } | 573 | } |
537 | 574 | ||
538 | /** | 575 | /** |
539 | * Return the associated id of the item or -1 if no item | 576 | * Return the associated id of the item or -1 if no item |
540 | * matched the key | 577 | * matched the key |
541 | * | 578 | * |
542 | * @see handleKeyEvent | 579 | * @see handleKeyEvent |
543 | */ | 580 | */ |
544 | int OKeyConfigManager::handleKeyEventId( QKeyEvent* ev) { | 581 | int OKeyConfigManager::handleKeyEventId( QKeyEvent* ev) { |
545 | return handleKeyEvent( ev ).id(); | 582 | return handleKeyEvent( ev ).id(); |
546 | } | 583 | } |
547 | 584 | ||
548 | /** | 585 | /** |
549 | * Add Key Config to the List of items | 586 | * Add Key Config to the List of items |
550 | */ | 587 | */ |
551 | void OKeyConfigManager::addKeyConfig( const OKeyConfigItem& item ) { | 588 | void OKeyConfigManager::addKeyConfig( const OKeyConfigItem& item ) { |
552 | m_keys.append( item ); | 589 | m_keys.append( item ); |
553 | delete m_map; m_map = 0; | 590 | delete m_map; m_map = 0; |
554 | } | 591 | } |
555 | 592 | ||
556 | /** | 593 | /** |
557 | * Remove the Key from the Config. Internal lists will be destroyed | 594 | * Remove the Key from the Config. Internal lists will be destroyed |
558 | * and rebuild on demand later | 595 | * and rebuild on demand later |
559 | */ | 596 | */ |
560 | void OKeyConfigManager::removeKeyConfig( const OKeyConfigItem& item ) { | 597 | void OKeyConfigManager::removeKeyConfig( const OKeyConfigItem& item ) { |
561 | m_keys.remove( item ); | 598 | m_keys.remove( item ); |
562 | delete m_map; m_map = 0; | 599 | delete m_map; m_map = 0; |
563 | } | 600 | } |
564 | 601 | ||
565 | /** | 602 | /** |
566 | * Clears the complete list | 603 | * Clears the complete list |
567 | */ | 604 | */ |
568 | void OKeyConfigManager::clearKeyConfig() { | 605 | void OKeyConfigManager::clearKeyConfig() { |
569 | m_keys.clear(); | 606 | m_keys.clear(); |
570 | delete m_map; m_map = 0; | 607 | delete m_map; m_map = 0; |
571 | } | 608 | } |
572 | 609 | ||
573 | 610 | ||
574 | /** | 611 | /** |
575 | * Add this OKeyPair to the blackList. | 612 | * Add this OKeyPair to the blackList. |
576 | * Internal lists will be destroyed | 613 | * Internal lists will be destroyed |
577 | */ | 614 | */ |
578 | void OKeyConfigManager::addToBlackList( const OKeyPair& key) { | 615 | void OKeyConfigManager::addToBlackList( const OKeyPair& key) { |
579 | m_blackKeys.append( key ); | 616 | m_blackKeys.append( key ); |
580 | delete m_map; m_map = 0; | 617 | delete m_map; m_map = 0; |
581 | } | 618 | } |
582 | 619 | ||
583 | 620 | ||
584 | /** | 621 | /** |
585 | * Remove this OKeyPair from the black List | 622 | * Remove this OKeyPair from the black List |
586 | * Internal lists will be destroyed | 623 | * Internal lists will be destroyed |
587 | */ | 624 | */ |
588 | void OKeyConfigManager::removeFromBlackList( const OKeyPair& key ) { | 625 | void OKeyConfigManager::removeFromBlackList( const OKeyPair& key ) { |
589 | m_blackKeys.remove( key ); | 626 | m_blackKeys.remove( key ); |
590 | delete m_map; m_map = 0; | 627 | delete m_map; m_map = 0; |
591 | } | 628 | } |
592 | 629 | ||
593 | 630 | ||
594 | /** | 631 | /** |
595 | * Clear the blackList | 632 | * Clear the blackList |
596 | */ | 633 | */ |
597 | void OKeyConfigManager::clearBlackList() { | 634 | void OKeyConfigManager::clearBlackList() { |
598 | m_blackKeys.clear(); | 635 | m_blackKeys.clear(); |
599 | delete m_map; m_map = 0; | 636 | delete m_map; m_map = 0; |
600 | } | 637 | } |
601 | 638 | ||
602 | 639 | ||
603 | /** | 640 | /** |
604 | * Return a copy of the blackList | 641 | * Return a copy of the blackList |
605 | */ | 642 | */ |
606 | OKeyPair::List OKeyConfigManager::blackList()const { | 643 | OKeyPair::List OKeyConfigManager::blackList()const { |
607 | return m_blackKeys; | 644 | return m_blackKeys; |
608 | } | 645 | } |
609 | 646 | ||
610 | 647 | ||
611 | /** | 648 | /** |
612 | * Ask the Manager to handle KeyEvents for you. | 649 | * Ask the Manager to handle KeyEvents for you. |
613 | * All handled keys will emit a QSignal and return true | 650 | * All handled keys will emit a QSignal and return true |
614 | * that it handled the keyevent | 651 | * that it handled the keyevent |
615 | */ | 652 | */ |
616 | void OKeyConfigManager::handleWidget( QWidget* wid ) { | 653 | void OKeyConfigManager::handleWidget( QWidget* wid ) { |
617 | wid->installEventFilter( this ); | 654 | wid->installEventFilter( this ); |
618 | } | 655 | } |
619 | 656 | ||
620 | /** | 657 | /** |
621 | * @internal | 658 | * @internal |
622 | */ | 659 | */ |
623 | bool OKeyConfigManager::eventFilter( QObject* obj, QEvent* ev) { | 660 | bool OKeyConfigManager::eventFilter( QObject* obj, QEvent* ev) { |
624 | if ( !obj->isWidgetType() ) | 661 | if ( !obj->isWidgetType() ) |
625 | return false; | 662 | return false; |
626 | 663 | ||
627 | if ( ev->type() != QEvent::KeyPress && ev->type() != QEvent::KeyRelease ) | 664 | if ( ev->type() != QEvent::KeyPress && ev->type() != QEvent::KeyRelease ) |
628 | return false; | 665 | return false; |
629 | 666 | ||
630 | QKeyEvent *key = static_cast<QKeyEvent*>( ev ); | 667 | QKeyEvent *key = static_cast<QKeyEvent*>( ev ); |
631 | OKeyConfigItem item = handleKeyEvent( key ); | 668 | OKeyConfigItem item = handleKeyEvent( key ); |
632 | 669 | ||
633 | if ( item.isEmpty() ) | 670 | if ( item.isEmpty() ) |
634 | return false; | 671 | return false; |
635 | 672 | ||
636 | QWidget *wid = static_cast<QWidget*>( obj ); | 673 | QWidget *wid = static_cast<QWidget*>( obj ); |
637 | 674 | ||
638 | if ( item.object() && !item.slot().isEmpty() ) { | 675 | if ( item.object() && !item.slot().isEmpty() ) { |
639 | connect( this, SIGNAL( actionActivated(QWidget*, QKeyEvent*)), | 676 | connect( this, SIGNAL( actionActivated(QWidget*, QKeyEvent*)), |
640 | item.object(), item.slot().data() ); | 677 | item.object(), item.slot().data() ); |
641 | emit actionActivated(wid, key); | 678 | emit actionActivated(wid, key); |
642 | disconnect( this, SIGNAL(actionActivated(QWidget*,QKeyEvent*)), | 679 | disconnect( this, SIGNAL(actionActivated(QWidget*,QKeyEvent*)), |
643 | item.object(), item.slot().data() ); | 680 | item.object(), item.slot().data() ); |
644 | } | 681 | } |
645 | emit actionActivated( wid, key, item ); | 682 | emit actionActivated( wid, key, item ); |
646 | 683 | ||
647 | return true; | 684 | return true; |
648 | } | 685 | } |
649 | 686 | ||
650 | /** | 687 | /** |
651 | * @internal | 688 | * @internal |
652 | */ | 689 | */ |
653 | OKeyConfigItem::List OKeyConfigManager::keyList( int keycode) { | 690 | OKeyConfigItem::List OKeyConfigManager::keyList( int keycode) { |
654 | /* | 691 | /* |
655 | * Create the map if not existing anymore | 692 | * Create the map if not existing anymore |
656 | */ | 693 | */ |
657 | if ( !m_map ) { | 694 | if ( !m_map ) { |
658 | m_map = new OKeyMapConfigPrivate; | 695 | m_map = new OKeyMapConfigPrivate; |
659 | /* for every key */ | 696 | /* for every key */ |
660 | for ( OKeyConfigItem::List::Iterator it = m_keys.begin(); | 697 | for ( OKeyConfigItem::List::Iterator it = m_keys.begin(); |
661 | it!= m_keys.end(); ++it ) { | 698 | it!= m_keys.end(); ++it ) { |
662 | 699 | ||
663 | bool add = true; | 700 | bool add = true; |
664 | /* see if this key is blocked */ | 701 | /* see if this key is blocked */ |
665 | OKeyPair pair = (*it).keyPair(); | 702 | OKeyPair pair = (*it).keyPair(); |
666 | for ( OKeyPair::List::Iterator pairIt = m_blackKeys.begin(); | 703 | for ( OKeyPair::List::Iterator pairIt = m_blackKeys.begin(); |
667 | pairIt != m_blackKeys.end(); ++pairIt ) { | 704 | pairIt != m_blackKeys.end(); ++pairIt ) { |
668 | if ( (*pairIt).keycode() == pair.keycode() && | 705 | if ( (*pairIt).keycode() == pair.keycode() && |
669 | (*pairIt).modifier() == pair.modifier() ) { | 706 | (*pairIt).modifier() == pair.modifier() ) { |
670 | add = false; | 707 | add = false; |
671 | break; | 708 | break; |
672 | } | 709 | } |
673 | } | 710 | } |
674 | /* check if we added it */ | 711 | /* check if we added it */ |
675 | if ( add ) | 712 | if ( add ) |
676 | (*m_map)[pair.keycode()].append( *it ); | 713 | (*m_map)[pair.keycode()].append( *it ); |
677 | } | 714 | } |
678 | } | 715 | } |
679 | return (*m_map)[keycode]; | 716 | return (*m_map)[keycode]; |
680 | } | 717 | } |
681 | 718 | ||
682 | 719 | ||
683 | 720 | ||
684 | ///////////////////////// | 721 | ///////////////////////// |
685 | //////// Widget Starts Here | 722 | //////// Widget Starts Here |
686 | namespace Opie { | 723 | namespace Opie { |
687 | namespace Ui { | 724 | namespace Ui { |
688 | namespace Private { | 725 | namespace Private { |
689 | static QString keyToString( const OKeyPair& ); | 726 | static QString keyToString( const OKeyPair& ); |
690 | class OKeyListViewItem : public Opie::Ui::OListViewItem { | 727 | class OKeyListViewItem : public Opie::Ui::OListViewItem { |
691 | public: | 728 | public: |
692 | OKeyListViewItem( const OKeyConfigItem& item, OKeyConfigManager*, Opie::Ui::OListViewItem* parent); | 729 | OKeyListViewItem( const OKeyConfigItem& item, OKeyConfigManager*, Opie::Ui::OListViewItem* parent); |
693 | ~OKeyListViewItem(); | 730 | ~OKeyListViewItem(); |
694 | 731 | ||
695 | void setDefault(); | 732 | void setDefault(); |
696 | 733 | ||
697 | OKeyConfigItem& item(); | 734 | OKeyConfigItem& item(); |
698 | void setItem( const OKeyConfigItem& item ); | 735 | void setItem( const OKeyConfigItem& item ); |
699 | 736 | ||
700 | OKeyConfigManager *manager(); | 737 | OKeyConfigManager *manager(); |
701 | private: | 738 | private: |
702 | OKeyConfigItem m_item; | 739 | OKeyConfigItem m_item; |
703 | OKeyConfigManager* m_manager; | 740 | OKeyConfigManager* m_manager; |
704 | 741 | ||
705 | }; | 742 | }; |
706 | 743 | ||
707 | OKeyListViewItem::OKeyListViewItem( const OKeyConfigItem& item, OKeyConfigManager* man, OListViewItem* parent) | 744 | OKeyListViewItem::OKeyListViewItem( const OKeyConfigItem& item, OKeyConfigManager* man, OListViewItem* parent) |
708 | : Opie::Ui::OListViewItem( parent ), m_manager( man ) { | 745 | : Opie::Ui::OListViewItem( parent ), m_manager( man ) { |
709 | setItem( item ); | 746 | setItem( item ); |
710 | } | 747 | } |
711 | OKeyListViewItem::~OKeyListViewItem() {} | 748 | OKeyListViewItem::~OKeyListViewItem() {} |
712 | OKeyConfigItem &OKeyListViewItem::item(){ | 749 | OKeyConfigItem &OKeyListViewItem::item(){ |
713 | return m_item; | 750 | return m_item; |
714 | } | 751 | } |
715 | OKeyConfigManager* OKeyListViewItem::manager() { | 752 | OKeyConfigManager* OKeyListViewItem::manager() { |
716 | return m_manager; | 753 | return m_manager; |
717 | } | 754 | } |
718 | void OKeyListViewItem::setItem( const OKeyConfigItem& item ) { | 755 | void OKeyListViewItem::setItem( const OKeyConfigItem& item ) { |
719 | setPixmap( 0, m_item.pixmap() ); | 756 | setPixmap( 0, m_item.pixmap() ); |
720 | setText ( 1, m_item.text() ); | 757 | setText ( 1, m_item.text() ); |
721 | setText ( 2, keyToString( m_item.keyPair() ) ); | 758 | setText ( 2, keyToString( m_item.keyPair() ) ); |
722 | setText ( 3, keyToString( m_item.defaultKeyPair() ) ); | 759 | setText ( 3, keyToString( m_item.defaultKeyPair() ) ); |
723 | m_item = item; | 760 | m_item = item; |
724 | } | 761 | } |
725 | 762 | ||
726 | QString keyToString( const OKeyPair& pair ) { | 763 | QString keyToString( const OKeyPair& pair ) { |
727 | int mod = 0; | 764 | int mod = 0; |
728 | if ( pair.modifier() & Qt::ShiftButton ) | 765 | if ( pair.modifier() & Qt::ShiftButton ) |
729 | mod |= Qt::SHIFT; | 766 | mod |= Qt::SHIFT; |
730 | if ( pair.modifier() & Qt::ControlButton ) | 767 | if ( pair.modifier() & Qt::ControlButton ) |
731 | mod |= Qt::CTRL; | 768 | mod |= Qt::CTRL; |
732 | if ( pair.modifier() & Qt::AltButton ) | 769 | if ( pair.modifier() & Qt::AltButton ) |
733 | mod |= Qt::ALT; | 770 | mod |= Qt::ALT; |
734 | 771 | ||
735 | return QAccel::keyToString( mod + pair.keycode() ); | 772 | return QAccel::keyToString( mod + pair.keycode() ); |
736 | } | 773 | } |
737 | 774 | ||
738 | struct OKeyConfigWidgetPrivate{ | 775 | struct OKeyConfigWidgetPrivate{ |
739 | OKeyConfigWidgetPrivate(const QString& = QString::null, | 776 | OKeyConfigWidgetPrivate(const QString& = QString::null, |
740 | OKeyConfigManager* = 0); | 777 | OKeyConfigManager* = 0); |
741 | bool operator==( const OKeyConfigWidgetPrivate& ); | 778 | bool operator==( const OKeyConfigWidgetPrivate& ); |
742 | QString name; | 779 | QString name; |
743 | OKeyConfigManager *manager; | 780 | OKeyConfigManager *manager; |
744 | }; | 781 | }; |
745 | 782 | ||
746 | OKeyConfigWidgetPrivate::OKeyConfigWidgetPrivate( const QString& _name, | 783 | OKeyConfigWidgetPrivate::OKeyConfigWidgetPrivate( const QString& _name, |
747 | OKeyConfigManager* man ) | 784 | OKeyConfigManager* man ) |
748 | : name( _name ), manager( man ){} | 785 | : name( _name ), manager( man ){} |
749 | 786 | ||
750 | bool OKeyConfigWidgetPrivate::operator==( const OKeyConfigWidgetPrivate& item) { | 787 | bool OKeyConfigWidgetPrivate::operator==( const OKeyConfigWidgetPrivate& item) { |
751 | if ( manager != item.manager) return false; | 788 | if ( manager != item.manager) return false; |
752 | if ( name != item.name ) return false; | 789 | if ( name != item.name ) return false; |
753 | 790 | ||
754 | return true; | 791 | return true; |
755 | } | 792 | } |
756 | 793 | ||
757 | } | 794 | } |
758 | } | 795 | } |
759 | } | 796 | } |
760 | 797 | ||
761 | 798 | ||
762 | 799 | ||
763 | //////////////////////// | 800 | //////////////////////// |
764 | 801 | ||
765 | 802 | ||
766 | 803 | ||
767 | 804 | ||
768 | 805 | ||
769 | /** | 806 | /** |
770 | * | 807 | * |
771 | * This is a c'tor. You still need to pass the OKeyConfigManager | 808 | * This is a c'tor. You still need to pass the OKeyConfigManager |
772 | * and then issue a load. | 809 | * and then issue a load. |
773 | * The default mode is Immediate | 810 | * The default mode is Immediate |
774 | * | 811 | * |
775 | */ | 812 | */ |
776 | OKeyConfigWidget::OKeyConfigWidget( QWidget* parent, const char *name, WFlags fl ) | 813 | OKeyConfigWidget::OKeyConfigWidget( QWidget* parent, const char *name, WFlags fl ) |
777 | : QWidget( parent, name, fl ) { | 814 | : QWidget( parent, name, fl ) { |
778 | initUi(); | 815 | initUi(); |
779 | } | 816 | } |
780 | 817 | ||
781 | 818 | ||
782 | 819 | ||
783 | /** | 820 | /** |
784 | * c'tor | 821 | * c'tor |
785 | */ | 822 | */ |
786 | OKeyConfigWidget::~OKeyConfigWidget() { | 823 | OKeyConfigWidget::~OKeyConfigWidget() { |
787 | } | 824 | } |
788 | 825 | ||
789 | 826 | ||
790 | /** | 827 | /** |
791 | * @internal | 828 | * @internal |
792 | */ | 829 | */ |
793 | void OKeyConfigWidget::initUi() { | 830 | void OKeyConfigWidget::initUi() { |
794 | QBoxLayout *layout = new QVBoxLayout( this ); | 831 | QBoxLayout *layout = new QVBoxLayout( this ); |
795 | QGridLayout *gridLay = new QGridLayout( 2, 2 ); | 832 | QGridLayout *gridLay = new QGridLayout( 2, 2 ); |
796 | layout->addLayout( gridLay, 10 ); | 833 | layout->addLayout( gridLay, 10 ); |
797 | gridLay->setRowStretch( 1, 10 ); // let only the ListView strecth | 834 | gridLay->setRowStretch( 1, 10 ); // let only the ListView strecth |
798 | 835 | ||
799 | /* | 836 | /* |
800 | * LISTVIEW with the Keys | 837 | * LISTVIEW with the Keys |
801 | */ | 838 | */ |
802 | m_view = new Opie::Ui::OListView( this ); | 839 | m_view = new Opie::Ui::OListView( this ); |
803 | m_view->setFocus(); | 840 | m_view->setFocus(); |
804 | m_view->setAllColumnsShowFocus( true ); | 841 | m_view->setAllColumnsShowFocus( true ); |
805 | m_view->addColumn( tr("Pixmap") ); | 842 | m_view->addColumn( tr("Pixmap") ); |
806 | m_view->addColumn( tr("Name","Name of the Action in the ListView Header" ) ); | 843 | m_view->addColumn( tr("Name","Name of the Action in the ListView Header" ) ); |
807 | m_view->addColumn( tr("Key" ) ); | 844 | m_view->addColumn( tr("Key" ) ); |
808 | m_view->addColumn( tr("Default Key" ) ); | 845 | m_view->addColumn( tr("Default Key" ) ); |
809 | connect(m_view, SIGNAL(currentChanged(QListViewItem*)), | 846 | connect(m_view, SIGNAL(currentChanged(QListViewItem*)), |
810 | this, SLOT(slotListViewItem(QListViewItem*)) ); | 847 | this, SLOT(slotListViewItem(QListViewItem*)) ); |
811 | 848 | ||
812 | gridLay->addMultiCellWidget( m_view, 1, 1, 0, 1 ); | 849 | gridLay->addMultiCellWidget( m_view, 1, 1, 0, 1 ); |
813 | 850 | ||
814 | /* | 851 | /* |
815 | * GROUP with button info | 852 | * GROUP with button info |
816 | */ | 853 | */ |
817 | 854 | ||
818 | QGroupBox *box = new QGroupBox( this ); | 855 | QGroupBox *box = new QGroupBox( this ); |
819 | box ->setEnabled( false ); | 856 | box ->setEnabled( false ); |
820 | box ->setTitle( tr("Shortcut for Selected Action") ); | 857 | box ->setTitle( tr("Shortcut for Selected Action") ); |
821 | box ->setFrameStyle( QFrame::Box | QFrame::Sunken ); | 858 | box ->setFrameStyle( QFrame::Box | QFrame::Sunken ); |
822 | layout->addWidget( box, 1 ); | 859 | layout->addWidget( box, 1 ); |
823 | 860 | ||
824 | gridLay = new QGridLayout( box, 3, 4 ); | 861 | gridLay = new QGridLayout( box, 3, 4 ); |
825 | gridLay->addRowSpacing( 0, fontMetrics().lineSpacing() ); | 862 | gridLay->addRowSpacing( 0, fontMetrics().lineSpacing() ); |
826 | gridLay->setMargin( 4 ); | 863 | gridLay->setMargin( 4 ); |
827 | 864 | ||
828 | QButtonGroup *gr = new QButtonGroup( box ); | 865 | QButtonGroup *gr = new QButtonGroup( box ); |
829 | gr->hide(); | 866 | gr->hide(); |
830 | gr->setExclusive( true ); | 867 | gr->setExclusive( true ); |
831 | 868 | ||
832 | QRadioButton *rad = new QRadioButton( tr( "&None" ), box ); | 869 | QRadioButton *rad = new QRadioButton( tr( "&None" ), box ); |
833 | connect( rad, SIGNAL(clicked()), | 870 | connect( rad, SIGNAL(clicked()), |
834 | this, SLOT(slotNoKey()) ); | 871 | this, SLOT(slotNoKey()) ); |
835 | gr->insert( rad, 10 ); | 872 | gr->insert( rad, 10 ); |
836 | gridLay->addWidget( rad, 1, 0 ); | 873 | gridLay->addWidget( rad, 1, 0 ); |
837 | m_none = rad; | 874 | m_none = rad; |
838 | 875 | ||
839 | rad = new QRadioButton( tr("&Default" ), box ); | 876 | rad = new QRadioButton( tr("&Default" ), box ); |
840 | connect( rad, SIGNAL(clicked()), | 877 | connect( rad, SIGNAL(clicked()), |
841 | this, SLOT(slotDefaultKey()) ); | 878 | this, SLOT(slotDefaultKey()) ); |
842 | gr->insert( rad, 11 ); | 879 | gr->insert( rad, 11 ); |
843 | gridLay->addWidget( rad, 1, 1 ); | 880 | gridLay->addWidget( rad, 1, 1 ); |
844 | m_def = rad; | 881 | m_def = rad; |
845 | 882 | ||
846 | rad = new QRadioButton( tr("C&ustom"), box ); | 883 | rad = new QRadioButton( tr("C&ustom"), box ); |
847 | connect( rad, SIGNAL(clicked()), | 884 | connect( rad, SIGNAL(clicked()), |
848 | this, SLOT(slotCustomKey()) ); | 885 | this, SLOT(slotCustomKey()) ); |
849 | gr->insert( rad, 12 ); | 886 | gr->insert( rad, 12 ); |
850 | gridLay->addWidget( rad, 1, 2 ); | 887 | gridLay->addWidget( rad, 1, 2 ); |
851 | m_cus = rad; | 888 | m_cus = rad; |
852 | 889 | ||
853 | m_btn = new QPushButton( tr("Configure Key"), box ); | 890 | m_btn = new QPushButton( tr("Configure Key"), box ); |
854 | gridLay->addWidget( m_btn, 1, 4 ); | 891 | gridLay->addWidget( m_btn, 1, 4 ); |
855 | 892 | ||
856 | m_lbl= new QLabel( tr( "Default: " ), box ); | 893 | m_lbl= new QLabel( tr( "Default: " ), box ); |
857 | gridLay->addWidget( m_lbl, 2, 0 ); | 894 | gridLay->addWidget( m_lbl, 2, 0 ); |
858 | 895 | ||
859 | 896 | ||
860 | m_box = gr; | 897 | m_box = gr; |
861 | } | 898 | } |
862 | 899 | ||
863 | /** | 900 | /** |
864 | * Set the ChangeMode. | 901 | * Set the ChangeMode. |
865 | * You need to call this function prior to load | 902 | * You need to call this function prior to load |
866 | * If you call this function past load the behaviour is undefined | 903 | * If you call this function past load the behaviour is undefined |
867 | * But caling load again is safe | 904 | * But caling load again is safe |
868 | */ | 905 | */ |
869 | void OKeyConfigWidget::setChangeMode( enum ChangeMode mode) { | 906 | void OKeyConfigWidget::setChangeMode( enum ChangeMode mode) { |
870 | m_mode = mode; | 907 | m_mode = mode; |
871 | } | 908 | } |
872 | 909 | ||
873 | 910 | ||
874 | /** | 911 | /** |
875 | * return the current mode | 912 | * return the current mode |
876 | */ | 913 | */ |
877 | OKeyConfigWidget::ChangeMode OKeyConfigWidget::changeMode()const { | 914 | OKeyConfigWidget::ChangeMode OKeyConfigWidget::changeMode()const { |
878 | return m_mode; | 915 | return m_mode; |
879 | } | 916 | } |
880 | 917 | ||
881 | 918 | ||
882 | /** | 919 | /** |
883 | * insert these items before calling load | 920 | * insert these items before calling load |
884 | */ | 921 | */ |
885 | void OKeyConfigWidget::insert( const QString& str, OKeyConfigManager* man ) { | 922 | void OKeyConfigWidget::insert( const QString& str, OKeyConfigManager* man ) { |
886 | Opie::Ui::Private::OKeyConfigWidgetPrivate root( str, man ); | 923 | Opie::Ui::Private::OKeyConfigWidgetPrivate root( str, man ); |
887 | m_list.append(root); | 924 | m_list.append(root); |
888 | } | 925 | } |
889 | 926 | ||
890 | 927 | ||
891 | /** | 928 | /** |
892 | * loads the items and allows editing them | 929 | * loads the items and allows editing them |
893 | */ | 930 | */ |
894 | void OKeyConfigWidget::load() { | 931 | void OKeyConfigWidget::load() { |
895 | 932 | ||
896 | } | 933 | } |
897 | 934 | ||
898 | /** | 935 | /** |
899 | * Saves if in Queue Mode. It'll update the supplied | 936 | * Saves if in Queue Mode. It'll update the supplied |
900 | * OKeyConfigManager objects. | 937 | * OKeyConfigManager objects. |
901 | * If in Queue mode it'll just return | 938 | * If in Queue mode it'll just return |
902 | */ | 939 | */ |
903 | void OKeyConfigWidget::save() { | 940 | void OKeyConfigWidget::save() { |
904 | 941 | ||
905 | } | 942 | } |
906 | 943 | ||
907 | 944 | ||
908 | /** | 945 | /** |
909 | * @internal | 946 | * @internal |
910 | */ | 947 | */ |
911 | void OKeyConfigWidget::slotListViewItem( QListViewItem* _item) { | 948 | void OKeyConfigWidget::slotListViewItem( QListViewItem* _item) { |
912 | if ( !_item || !_item->parent() ) { | 949 | if ( !_item || !_item->parent() ) { |
913 | m_box->setEnabled( false ); | 950 | m_box->setEnabled( false ); |
914 | m_none->setChecked( true ); | 951 | m_none->setChecked( true ); |
915 | m_btn ->setEnabled( false ); | 952 | m_btn ->setEnabled( false ); |
916 | m_def ->setChecked( false ); | 953 | m_def ->setChecked( false ); |
917 | m_cus ->setChecked( false ); | 954 | m_cus ->setChecked( false ); |
918 | }else{ | 955 | }else{ |
919 | m_box->setEnabled( true ); | 956 | m_box->setEnabled( true ); |
920 | Opie::Ui::Private::OKeyListViewItem *item = static_cast<Opie::Ui::Private::OKeyListViewItem*>( _item ); | 957 | Opie::Ui::Private::OKeyListViewItem *item = static_cast<Opie::Ui::Private::OKeyListViewItem*>( _item ); |
921 | OKeyConfigItem keyItem= item->item(); | 958 | OKeyConfigItem keyItem= item->item(); |
922 | if ( keyItem.keyPair().isEmpty() ) { | 959 | if ( keyItem.keyPair().isEmpty() ) { |
923 | m_none->setChecked( true ); | 960 | m_none->setChecked( true ); |
924 | m_btn ->setEnabled( false ); | 961 | m_btn ->setEnabled( false ); |
925 | m_def ->setChecked( false ); | 962 | m_def ->setChecked( false ); |
926 | m_cus ->setChecked( false ); | 963 | m_cus ->setChecked( false ); |
927 | }else { | 964 | }else { |
928 | m_none->setChecked( false ); | 965 | m_none->setChecked( false ); |
929 | m_cus ->setChecked( true ); | 966 | m_cus ->setChecked( true ); |
930 | m_btn ->setEnabled( true ); | 967 | m_btn ->setEnabled( true ); |
931 | m_def ->setChecked( false ); | 968 | m_def ->setChecked( false ); |
932 | } | 969 | } |
933 | } | 970 | } |
934 | } | 971 | } |
935 | 972 | ||
936 | void OKeyConfigWidget::slotNoKey() { | 973 | void OKeyConfigWidget::slotNoKey() { |
937 | m_none->setChecked( true ); | 974 | m_none->setChecked( true ); |
938 | m_cus ->setChecked( false ); | 975 | m_cus ->setChecked( false ); |
939 | m_btn ->setEnabled( false ); | 976 | m_btn ->setEnabled( false ); |
940 | m_def ->setChecked( false ); | 977 | m_def ->setChecked( false ); |
941 | 978 | ||
942 | if ( !m_view->currentItem() || m_view->currentItem()->parent() ) | 979 | if ( !m_view->currentItem() || m_view->currentItem()->parent() ) |
943 | return; | 980 | return; |
944 | 981 | ||
945 | 982 | ||
946 | 983 | ||
947 | /* | 984 | /* |
948 | * If immediate we need to remove and readd the key | 985 | * If immediate we need to remove and readd the key |
949 | */ | 986 | */ |
950 | Opie::Ui::Private::OKeyListViewItem *item = static_cast<Opie::Ui::Private::OKeyListViewItem*>(m_view->currentItem()); | 987 | Opie::Ui::Private::OKeyListViewItem *item = static_cast<Opie::Ui::Private::OKeyListViewItem*>(m_view->currentItem()); |
951 | if ( m_mode == Imediate ) | 988 | if ( m_mode == Imediate ) |
952 | item->manager()->removeKeyConfig( item->item() ); | 989 | item->manager()->removeKeyConfig( item->item() ); |
953 | item->item().setKeyPair( OKeyPair::emptyKey() ); | 990 | item->item().setKeyPair( OKeyPair::emptyKey() ); |
954 | 991 | ||
955 | if ( m_mode == Imediate ) | 992 | if ( m_mode == Imediate ) |
956 | item->manager()->addKeyConfig( item->item() ); | 993 | item->manager()->addKeyConfig( item->item() ); |
957 | 994 | ||
958 | } | 995 | } |
959 | 996 | ||
960 | void OKeyConfigWidget::slotDefaultKey() { | 997 | void OKeyConfigWidget::slotDefaultKey() { |
961 | m_none->setChecked( true ); | 998 | m_none->setChecked( true ); |
962 | m_cus ->setChecked( false ); | 999 | m_cus ->setChecked( false ); |
963 | m_btn ->setEnabled( false ); | 1000 | m_btn ->setEnabled( false ); |
964 | m_def ->setChecked( false ); | 1001 | m_def ->setChecked( false ); |
965 | 1002 | ||
966 | if ( !m_view->currentItem() || m_view->currentItem()->parent() ) | 1003 | if ( !m_view->currentItem() || m_view->currentItem()->parent() ) |
967 | return; | 1004 | return; |
968 | 1005 | ||
969 | Opie::Ui::Private::OKeyListViewItem *item = static_cast<Opie::Ui::Private::OKeyListViewItem*>(m_view->currentItem()); | 1006 | Opie::Ui::Private::OKeyListViewItem *item = static_cast<Opie::Ui::Private::OKeyListViewItem*>(m_view->currentItem()); |
970 | 1007 | ||
971 | /* | 1008 | /* |
972 | * If immediate we need to remove and readd the key | 1009 | * If immediate we need to remove and readd the key |
973 | */ | 1010 | */ |
974 | if ( m_mode == Imediate ) | 1011 | if ( m_mode == Imediate ) |
975 | item->manager()->removeKeyConfig( item->item() ); | 1012 | item->manager()->removeKeyConfig( item->item() ); |
976 | 1013 | ||
977 | item->item().setKeyPair( item->item().defaultKeyPair() ); | 1014 | item->item().setKeyPair( item->item().defaultKeyPair() ); |
978 | 1015 | ||
979 | if ( m_mode == Imediate ) | 1016 | if ( m_mode == Imediate ) |
980 | item->manager()->addKeyConfig( item->item() ); | 1017 | item->manager()->addKeyConfig( item->item() ); |
981 | } | 1018 | } |
982 | 1019 | ||
983 | void OKeyConfigWidget::slotCustomKey() { | 1020 | void OKeyConfigWidget::slotCustomKey() { |
984 | m_cus ->setChecked( true ); | 1021 | m_cus ->setChecked( true ); |
985 | m_btn ->setEnabled( true ); | 1022 | m_btn ->setEnabled( true ); |
986 | m_def ->setChecked( false ); | 1023 | m_def ->setChecked( false ); |
987 | m_none->setChecked( false ); | 1024 | m_none->setChecked( false ); |
988 | 1025 | ||
989 | if ( !m_view->currentItem() || m_view->currentItem()->parent() ) | 1026 | if ( !m_view->currentItem() || m_view->currentItem()->parent() ) |
990 | return; | 1027 | return; |
991 | 1028 | ||
992 | } | 1029 | } |
993 | 1030 | ||