-rw-r--r-- | libopie2/opieui/okeyconfigwidget.cpp | 408 | ||||
-rw-r--r-- | libopie2/opieui/okeyconfigwidget.h | 142 |
2 files changed, 529 insertions, 21 deletions
diff --git a/libopie2/opieui/okeyconfigwidget.cpp b/libopie2/opieui/okeyconfigwidget.cpp new file mode 100644 index 0000000..d52a55f --- a/dev/null +++ b/libopie2/opieui/okeyconfigwidget.cpp | |||
@@ -0,0 +1,408 @@ | |||
1 | #include "okeyconfigwidget.h" | ||
2 | |||
3 | |||
4 | |||
5 | |||
6 | using namespace Opie::Ui; | ||
7 | |||
8 | |||
9 | /** | ||
10 | * The default Constructor of a OKeyPair. | ||
11 | * A Key and a Modifier ( Alt/Shift/Ctrl ) | ||
12 | * needs to be supplied. | ||
13 | * Use Qt::Key for the information. | ||
14 | * The default arguments create an Empty OKeyPair. If you | ||
15 | * want to get an empty OKeyPair use the static method for getting | ||
16 | * the emptyKey() | ||
17 | * | ||
18 | * @see OKeyPair OKeyPair::emptyKey() | ||
19 | */ | ||
20 | OKeyPair::OKeyPair( int key, int mod ) | ||
21 | : m_key( key ), m_mod( mod ) | ||
22 | {} | ||
23 | |||
24 | /** | ||
25 | * The destructor | ||
26 | */ | ||
27 | OKeyPair::~OKeyPair() {} | ||
28 | |||
29 | |||
30 | /** | ||
31 | * Is this OKeyPair empty/valid? | ||
32 | */ | ||
33 | bool OKeyPair::isEmpty()const { | ||
34 | return ( ( m_key == -1 )&& ( m_mod == -1 ) ); | ||
35 | } | ||
36 | |||
37 | /** | ||
38 | * get the keycode for this OKeyPair. The Key relates to Qt::Key. | ||
39 | * | ||
40 | * @see Qt::Key | ||
41 | * @see setKey | ||
42 | */ | ||
43 | int OKeyPair::keycode()const { | ||
44 | return m_key; | ||
45 | } | ||
46 | |||
47 | /** | ||
48 | * get the modifier key for this OKeyPair. The Modifier State relates | ||
49 | * to the Qt::Modifier | ||
50 | * | ||
51 | * @see Qt::Modifier | ||
52 | * @see setModifier | ||
53 | */ | ||
54 | int OKeyPair::modifier()const { | ||
55 | return m_mod; | ||
56 | } | ||
57 | |||
58 | |||
59 | /** | ||
60 | * Set the keycode | ||
61 | * @param key The Keycode to set | ||
62 | * | ||
63 | * @see keycode() | ||
64 | * @see Qt::Key | ||
65 | */ | ||
66 | void OKeyPair::setKeycode( int key ) { | ||
67 | |||
68 | } | ||
69 | |||
70 | /** | ||
71 | * Set the modifier key | ||
72 | * | ||
73 | * @param the Modifier key | ||
74 | * @see Qt::Modifier | ||
75 | * @see modifier() | ||
76 | */ | ||
77 | void OKeyPair::setModifier( int mod ) { | ||
78 | |||
79 | } | ||
80 | |||
81 | /** | ||
82 | * Return an OKeyPair for the Return Key without any modifier. | ||
83 | */ | ||
84 | OKeyPair OKeyPair::returnKey() { | ||
85 | return OKeyPair( Qt::Key_Return, 0 ); | ||
86 | } | ||
87 | |||
88 | /** | ||
89 | * Return an OKeyPair for the Left Arrow Key | ||
90 | * without any modifier Key | ||
91 | */ | ||
92 | OKeyPair OKeyPair::leftArrowKey() { | ||
93 | return OKeyPair( Qt::Key_Left, 0 ); | ||
94 | } | ||
95 | |||
96 | /** | ||
97 | * Return an OKeyPair for the Right Arrow Key | ||
98 | * without any modifier Key | ||
99 | */ | ||
100 | OKeyPair OKeyPair::rightArrowKey() { | ||
101 | return OKeyPair( Qt::Key_Right, 0 ); | ||
102 | } | ||
103 | |||
104 | /** | ||
105 | * Return an OKeyPair for the Up Arrow Key | ||
106 | * without any modifier Key | ||
107 | */ | ||
108 | OKeyPair OKeyPair::upArrowKey() { | ||
109 | return OKeyPair( Qt::Key_Up, 0 ); | ||
110 | } | ||
111 | |||
112 | /** | ||
113 | * Return an OKeyPair for the Down Arrow Key | ||
114 | * without any modifier Key | ||
115 | */ | ||
116 | OKeyPair OKeyPair::downArrowKey() { | ||
117 | return OKeyPair( Qt::Key_Down, 0 ); | ||
118 | } | ||
119 | |||
120 | /** | ||
121 | * Return an Empty OKeyPair | ||
122 | */ | ||
123 | OKeyPair OKeyPair::emptyKey() { | ||
124 | return OKeyPair; | ||
125 | } | ||
126 | |||
127 | /** | ||
128 | * This functions uses the Opie::Core::ODevice::buttons | ||
129 | * for OKeyPairList | ||
130 | * | ||
131 | * @see Opie::Core::ODevice | ||
132 | * @see Opie::Core::ODeviceButton | ||
133 | * @see Opie::Core::ODevice::button | ||
134 | */ | ||
135 | OKeyPairList OKeyPair::hardwareKeys() { | ||
136 | const QValueList<Opie::Core::ODeviceButton> but = Opie::Core::ODevice::inst()->buttons(); | ||
137 | OKeyPairList lst; | ||
138 | |||
139 | for ( QValueList<Opie::Core::ODeviceButton>::Iterator it = but.begin(); | ||
140 | it != but.end(); ++it ) | ||
141 | lst.append( OKeyPair( (*it).keycode(), 0 ) ); | ||
142 | |||
143 | |||
144 | return lst; | ||
145 | } | ||
146 | |||
147 | /** | ||
148 | * The normal Constructor to create a OKeyConfigItem | ||
149 | * | ||
150 | * You can set the the key paramater of this item but if | ||
151 | * you use this item with the OKeyConfigManager your setting | ||
152 | * will be overwritten. | ||
153 | * | ||
154 | * @param text The text exposed to the user | ||
155 | * @param config_key The key used in the config | ||
156 | * @param pix A Pixmap associated with this Item | ||
157 | * @param key The OKeyPair used | ||
158 | * @param def The OKeyPair used as default | ||
159 | * | ||
160 | */ | ||
161 | OKeyConfigItem::OKeyConfigItem( const QString& text, const QCString& config_key, | ||
162 | const QPixmap& pix, int id, const OKeyPair& def, | ||
163 | const OKeyPair& key) | ||
164 | : m_text( text ), m_config( config_key ), m_pix( pix ), | ||
165 | m_id( id ), m_def( def ), m_key( key ) {} | ||
166 | |||
167 | /** | ||
168 | * A special Constructor for converting from an Opie::Core::ODeviceButton | ||
169 | * delivered by Opie::Core::ODevice::buttons() | ||
170 | * There is no Config Key set and both default key and key are set | ||
171 | * to Opie::Core::ODeviceButton::keycode() and 0 to modifier | ||
172 | * | ||
173 | * @see Opie::Core::ODevice | ||
174 | * @see Opie::Core::ODeviceButton | ||
175 | * @see Opie::Core::ODevice::buttons() | ||
176 | */ | ||
177 | OKeyConfigItem::OKeyConfigItem( Opie::Core::ODeviceButton& b ) | ||
178 | : m_text( b.userText() ), m_pix( b.pixmap() ), m_id( -1 ) | ||
179 | m_def( OKeyPair( b.keycode(), 0 ) ), m_key( OKeyPair( b.keycode(), 0 ) ) | ||
180 | {} | ||
181 | |||
182 | |||
183 | /** | ||
184 | * Destructor | ||
185 | */ | ||
186 | OKeyConfigItem::~OKeyConfigItem() {} | ||
187 | |||
188 | |||
189 | /** | ||
190 | * The text exposed to the user | ||
191 | * | ||
192 | * @see setText | ||
193 | */ | ||
194 | QString OKeyConfigItem::text()const { | ||
195 | return m_text; | ||
196 | } | ||
197 | |||
198 | /** | ||
199 | * The pixmap shown to the user for your action/key | ||
200 | * | ||
201 | * @see setPixmap | ||
202 | */ | ||
203 | QPixmap OKeyConfigItem::pixmap()const { | ||
204 | return m_pix; | ||
205 | } | ||
206 | |||
207 | /** | ||
208 | * Return the OKeyPair this OKeyConfigItem is configured for. | ||
209 | * | ||
210 | * @see setKeyPair | ||
211 | */ | ||
212 | OKeyPair OKeyConfigItem::keyPair()const { | ||
213 | return m_key; | ||
214 | } | ||
215 | |||
216 | /** | ||
217 | * Return the default OKeyPair | ||
218 | * @see setDefaultKeyPair | ||
219 | */ | ||
220 | OKeyPair OKeyConfigItem::defaultKeyPair()const { | ||
221 | return m_def; | ||
222 | } | ||
223 | |||
224 | |||
225 | /** | ||
226 | * Return the Id you assigned to this item. | ||
227 | * setting is only possible by the constructor | ||
228 | */ | ||
229 | int OKeyConfigItem::id()const{ | ||
230 | return m_id; | ||
231 | } | ||
232 | |||
233 | /** | ||
234 | * reutrn the Config Key. Setting it is only possible | ||
235 | * by the constructor | ||
236 | */ | ||
237 | QCString OKeyConfigItem::configKey()const { | ||
238 | return m_config; | ||
239 | } | ||
240 | |||
241 | /** | ||
242 | * Set the text | ||
243 | * | ||
244 | * @param text Set the Text of this Action to text | ||
245 | * @see text() | ||
246 | */ | ||
247 | void OKeyConfigItem::setText( const QString& text ) { | ||
248 | m_text = text; | ||
249 | } | ||
250 | |||
251 | /** | ||
252 | * Set the pixmap of this action | ||
253 | * | ||
254 | * @param pix The Pixmap to set | ||
255 | * @see pixmap() | ||
256 | */ | ||
257 | void OKeyConfigItem::setPixmap( const QPixmap& pix ) { | ||
258 | m_pix = pix; | ||
259 | } | ||
260 | |||
261 | /** | ||
262 | * Set the KeyPair the OKeyConfigItem uses. | ||
263 | * Your set Key could get overwritten if you use | ||
264 | * the manager or GUI to configure the key | ||
265 | * | ||
266 | * @param key Set the OKeyPair used | ||
267 | * @see keyPair() | ||
268 | */ | ||
269 | void OKeyConfigItem::setKeyPair( const OKeyPair& key) { | ||
270 | m_key = key; | ||
271 | } | ||
272 | |||
273 | /** | ||
274 | * Set the default KeyPair. | ||
275 | * | ||
276 | * @param key The default keypair | ||
277 | * @see defaultKeyPair() | ||
278 | */ | ||
279 | void OKeyConfigItem::setDefaultKeyPair( const OKeyPair& key ) { | ||
280 | m_def = key; | ||
281 | } | ||
282 | |||
283 | /** | ||
284 | * @internal | ||
285 | */ | ||
286 | void OKeyConfigItem::setConfigKey( const QCString& str) { | ||
287 | m_config = str; | ||
288 | m_config.detach(); | ||
289 | } | ||
290 | |||
291 | /** | ||
292 | * @internal | ||
293 | */ | ||
294 | void OKeyConfigItem::setId( int id ) { | ||
295 | m_id = id; | ||
296 | } | ||
297 | |||
298 | /** | ||
299 | * If the item is not configured isEmpty() will return true | ||
300 | * It is empty if no text is present and no default | ||
301 | * and no configured key | ||
302 | */ | ||
303 | bool OKeyConfigItem::isEmpty()const { | ||
304 | if ( !m_def.isEmpty() ) return false; | ||
305 | if ( !m_key.isEmpty() ) return false; | ||
306 | if ( !m_text.isEmpty() ) return false; | ||
307 | |||
308 | return true; | ||
309 | } | ||
310 | |||
311 | /** | ||
312 | * \brief c'tor | ||
313 | * The Constructor for a OKeyConfigManager | ||
314 | * | ||
315 | * You can use this manager in multiple ways. Either make it handle | ||
316 | * QKeyEvents | ||
317 | * | ||
318 | * \code | ||
319 | * Opie::Core::Config conf = oApp->config(); | ||
320 | * Opie::Ui::OKeyPairList blackList; | ||
321 | * blackList.append(Opie::Ui::OKeyPair::leftArrowKey()); | ||
322 | * blackList.append(Opie::Ui::OKeyPair::rightArrowKey()); | ||
323 | * Opie::Ui::OKeyConfigManager *manager = new Opie::Ui::OKeyConfigManager(conf,"key_actions",blackList, | ||
324 | * false); | ||
325 | * QListView *view = new QListView(); | ||
326 | * manager->handleWidget(view); | ||
327 | * manager->addKeyConfig( Opie::Ui::OKeyPair::returnKey()); | ||
328 | * manager->load(); | ||
329 | * | ||
330 | * connect(manager,SIGNAL(actionActivated(QWidget*,QKeyEvent*,const Opie::Ui::OKeyConfigItem&)), | ||
331 | * this,SLOT(slotHandleKey(QWidget*,QKeyEvent*,const Opie::Ui::OKeyConfigItem&))); | ||
332 | * | ||
333 | * .... | ||
334 | * | ||
335 | * void update(){ | ||
336 | * QDialog diag(true); | ||
337 | * QHBoxLayout *lay = new QHBoxLayout(&diag); | ||
338 | * Opie::Ui::OKeyConfigWidget *wid = new Opie::Ui::OKeyConfigWidget(manager,&diag); | ||
339 | * wid->setChangeMode(Opie::Ui::OKeyConfigWidget::Queu); | ||
340 | * lay->addWidget(wid); | ||
341 | * if(QPEApplication::execDialog( &diag)== QDialog::Accept){ | ||
342 | * wid->save(); | ||
343 | * } | ||
344 | * } | ||
345 | * | ||
346 | * .... | ||
347 | * MyListView::keyPressEvent( QKeyEvent* e ){ | ||
348 | * Opie::Ui::OKeyConfigItem item = manager->handleKeyEvent(e); | ||
349 | * if(!item.isEmpty() ){ | ||
350 | * switch(item.id()){ | ||
351 | * case My_Delete_Key: | ||
352 | * break; | ||
353 | * } | ||
354 | * } | ||
355 | * } | ||
356 | * | ||
357 | * \endcode | ||
358 | * | ||
359 | * @param conf The Config where the KeySetting should be stored | ||
360 | * @param group The group where the KeySetting will be stored | ||
361 | * @param black Which keys shouldn't be allowed to handle | ||
362 | * @param grabkeyboard Calls QPEApplication::grabKeyboard to allow handling of DeviceButtons | ||
363 | * @param par The parent/owner of this manager | ||
364 | * @param name The name of this object | ||
365 | */ | ||
366 | OKeyConfigManager::OKeyConfigManager( Opie::Core::OConfig* conf, | ||
367 | const QString& group, | ||
368 | OKeyPairList black, | ||
369 | bool grabkeyboard, QObject* par, | ||
370 | const char* name) | ||
371 | : QObject( par, name ), m_conf( conf ), m_group( group ), | ||
372 | m_blackKeys( black ), m_grab( grabkeyboard ) | ||
373 | {} | ||
374 | |||
375 | |||
376 | /** | ||
377 | * Destructor | ||
378 | */ | ||
379 | OKeyConfigWidget::~OKeyConfigWidget() {} | ||
380 | |||
381 | /** | ||
382 | * Load the Configuration from the OConfig | ||
383 | * If a Key is restricted but was in the config we will | ||
384 | * make the empty | ||
385 | * We will change the group of the OConfig Item! | ||
386 | */ | ||
387 | void OKeyConfigWidget::load() { | ||
388 | m_conf->setGroup( m_group ); | ||
389 | |||
390 | /* | ||
391 | * Read each item | ||
392 | */ | ||
393 | int key, mod; | ||
394 | for( OKeyConfigItemList::Iterator it = m_keys.begin(); | ||
395 | it != m_keys.end(); ++it ) { | ||
396 | key = m_conf->readNumEntry( (*it).configKey()+"key", (*it).defaultKeyPair().keycode() ); | ||
397 | mod = m_conf->readNumEntry( (*it).configKey()+"mod", (*it).defaultKeyPair().modifier() ); | ||
398 | (*it).setKeyPair( OKeyPair(key, mod) ); | ||
399 | } | ||
400 | } | ||
401 | |||
402 | /** | ||
403 | * We will save the current configuration | ||
404 | * to the OConfig. We will change the group. | ||
405 | */ | ||
406 | void OKeyConfigWidget::save() { | ||
407 | |||
408 | } | ||
diff --git a/libopie2/opieui/okeyconfigwidget.h b/libopie2/opieui/okeyconfigwidget.h index bcbb579..0d5d26f 100644 --- a/libopie2/opieui/okeyconfigwidget.h +++ b/libopie2/opieui/okeyconfigwidget.h | |||
@@ -1,8 +1,15 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2004 | ||
3 | * LGPL v2 zecke@handhelds.org | ||
4 | */ | ||
5 | |||
6 | |||
1 | #ifndef ODP_KEY_CONFIG_WIDGET_H | 7 | #ifndef ODP_KEY_CONFIG_WIDGET_H |
2 | #define ODP_KEY_CONFIG_WIDGET_H | 8 | #define ODP_KEY_CONFIG_WIDGET_H |
3 | 9 | ||
4 | #include <opie2/oconfig.h> | 10 | #include <opie2/oconfig.h> |
11 | #include <opie2/odevice.h> | ||
5 | 12 | ||
6 | #include <qstring.h> | 13 | #include <qstring.h> |
7 | #include <qpixmap.h> | 14 | #include <qpixmap.h> |
8 | #include <qbytearray.h> | 15 | #include <qbytearray.h> |
@@ -13,52 +20,130 @@ class QKeyEvent; | |||
13 | 20 | ||
14 | namespace Opie { | 21 | namespace Opie { |
15 | namespace Ui { | 22 | namespace Ui { |
16 | 23 | ||
24 | |||
25 | /** | ||
26 | * \brief small class representing a Key with possible modifiers | ||
27 | * This class holds information about key code and possible | ||
28 | * modifier state. That is the lowest level of the key input | ||
29 | * functions. | ||
30 | * There are also static methods to get special keys. | ||
31 | * OKeyPair will be used with \see OKeyConfigItem | ||
32 | * | ||
33 | * @since 1.2 | ||
34 | */ | ||
35 | class OKeyPair { | ||
36 | public: | ||
37 | typedef QValueList<OKeyPair> OKeyPairList; | ||
38 | OKeyPair( int key = -1, int modifier = -1); | ||
39 | ~OKeyPair(); | ||
40 | |||
41 | bool operator==( const OKeyPair& ); | ||
42 | bool operator!=( const OKeyPair& ); | ||
43 | |||
44 | bool isEmpty()const; | ||
45 | |||
46 | int keycode()const; | ||
47 | int modifier()const; | ||
48 | |||
49 | void setKeycode( int ); | ||
50 | void setModifier( int ); | ||
51 | |||
52 | static OKeyPair returnKey(); | ||
53 | static OKeyPair leftArrowKey(); | ||
54 | static OKeyPair rightArrowKey(); | ||
55 | static OKeyPair upArrowKey(); | ||
56 | static OKeyPair downArrowKey(); | ||
57 | static OKeyPair emptyKey(); | ||
58 | static OKeyPairList hardwareKeys(); | ||
59 | |||
60 | private: | ||
61 | int m_key = -1; | ||
62 | int m_mod = -1; | ||
63 | class Private; | ||
64 | Private* d; | ||
65 | }; | ||
66 | |||
67 | /** | ||
68 | * A class to represent an OKeyPair. | ||
69 | * It consists out of a Text exposed to the user, Config Key Item, | ||
70 | * Pixmap, A default OKeyPair and the set OKeyPair. | ||
71 | * You can also pass an id to it | ||
72 | * | ||
73 | * @since 1.1.2 | ||
74 | */ | ||
17 | class OKeyConfigItem { | 75 | class OKeyConfigItem { |
18 | friend class OKeyConfigManager; | 76 | friend class OKeyConfigManager; |
19 | public: | 77 | public: |
20 | typedef QValueList<OKeyConfigItem> OKeyConfigItemList; | 78 | typedef QValueList<OKeyConfigItem> OKeyConfigItemList; |
21 | OKeyConfigItem( const QString& text = QString::null , const QCString& config_key = QCString(), | 79 | OKeyConfigItem( const QString& text = QString::null , const QCString& config_key = QCString(), |
22 | const QPixmap& symbol = QPixmap(), | 80 | const QPixmap& symbol = QPixmap(), |
23 | int key = 0, int mod = 0, | 81 | int id = -1, |
24 | int default_key = 0, int default_modified = 0 ); | 82 | const OKeyPair& set = OKeyPair::emptyKey(), |
83 | const OKeyPair& def = OKeyPair::emptyKey() ); | ||
84 | OKeyConfigItem( const Opie::Core::ODeviceButton& ); | ||
25 | ~OKeyConfigItem(); | 85 | ~OKeyConfigItem(); |
26 | 86 | ||
87 | bool operator==( const OKeyConfigItem& ); | ||
88 | bool operator!=( const OKeyConfigItem& ); | ||
89 | |||
27 | QString text()const; | 90 | QString text()const; |
28 | QPixmap pixmap()const; | 91 | QPixmap pixmap()const; |
29 | int key()const; | 92 | int id()const; |
30 | int modifier()const; | 93 | |
31 | int defaultKey()const; | 94 | OKeyPair keyPair()const; |
32 | int defaultModifier()const; | 95 | OKeyPair defaultKeyPair()const; |
96 | QCString configKey()const; | ||
33 | 97 | ||
34 | void setText( const QString& text ); | 98 | void setText( const QString& text ); |
35 | void setPixmap( const QPixmap& ); | 99 | void setPixmap( const QPixmap& ); |
36 | void setKey( int ); | 100 | void setKeyPair( const OKeyPair& ); |
37 | void setModied( int ); | 101 | void setDefaultKeyPair( const OKeyPair& ); |
38 | void setDefaultKey( int ); | ||
39 | void setDefaultModifier( int ); | ||
40 | 102 | ||
41 | bool isConfigured()const; | ||
42 | bool isEmpty()const; | 103 | bool isEmpty()const; |
104 | |||
105 | protected: | ||
106 | void setId( int id ); | ||
107 | void setConfigKey( const QCString& ); | ||
108 | |||
43 | private: | 109 | private: |
110 | int m_id; | ||
44 | QString m_text; | 111 | QString m_text; |
45 | QCString m_config; | 112 | QCString m_config; |
46 | QPixmap m_pix; | 113 | QPixmap m_pix; |
47 | int m_key; | 114 | OKeyPair m_key; |
48 | int m_mod; | 115 | OKeyPair m_def; |
49 | int m_defKey; | ||
50 | int m_defMod; | ||
51 | class Private; | 116 | class Private; |
52 | Private *d; | 117 | Private *d; |
53 | }; | 118 | }; |
54 | 119 | ||
55 | 120 | ||
56 | class OKeyConfig : public QObject { | 121 | |
122 | /** | ||
123 | * \brief A manager to load and save Key Actions and get notified | ||
124 | * This is the Manager for KeyActions. | ||
125 | * You can say from which config and group to read data, to grab the | ||
126 | * keyboard to handle hardware keys, you can supply a blacklist of | ||
127 | * keys which should not be used by allowed to be used. | ||
128 | * You can even pass this manager to a Widget to do the configuration for you. | ||
129 | * You need to add OKeyConfigItem for your keys and then issue a load() to | ||
130 | * read the Key information. | ||
131 | * You can either handle the QKeyEvent yourself and ask this class if it is | ||
132 | * handled by your action and let give you the action. Or you can install | ||
133 | * the event filter and get a signal. | ||
134 | * | ||
135 | * @since 1.1.2 | ||
136 | */ | ||
137 | class OKeyConfigManager : public QObject { | ||
57 | Q_OBJECT | 138 | Q_OBJECT |
58 | public: | 139 | public: |
59 | OKeyConfig(Opie::Core::OConfig *conf = 0, bool grabkeyboard); | 140 | OKeyConfigManager(Opie::Core::OConfig *conf = 0, |
60 | ~OKeyConfig(); | 141 | const QString& group = QString::null, |
142 | OKeyPairList &block = OKeyPairList(), | ||
143 | bool grabkeyboard = false, QObject *= 0, | ||
144 | const char* name = 0 ); | ||
145 | ~OKeyConfigManager(); | ||
61 | 146 | ||
62 | void load(); | 147 | void load(); |
63 | void save(); | 148 | void save(); |
64 | 149 | ||
@@ -67,16 +152,27 @@ public: | |||
67 | 152 | ||
68 | void addKeyConfig( const OKeyConfigItem& ); | 153 | void addKeyConfig( const OKeyConfigItem& ); |
69 | void removeKeyConfig( const OKeyConfigItem& ); | 154 | void removeKeyConfig( const OKeyConfigItem& ); |
70 | 155 | ||
156 | void addBlackList( const OKeyPair& ); | ||
157 | void removeBlackList( const OKeyPair& ); | ||
158 | void clearBlackList(); | ||
159 | OKeyPairList blackList()const; | ||
160 | |||
71 | void handleWidget( QWidget* ); | 161 | void handleWidget( QWidget* ); |
162 | |||
163 | bool eventFilter( QObject*, QEvent* ); | ||
72 | signals: | 164 | signals: |
73 | void keyConfigChanged( OKeyConfig* ); | 165 | void keyConfigChanged( Opie::Ui::OKeyConfigManager* ); |
74 | void actionActivated( QWidget*, QKeyEvent*, const OKeyConfigItem& ); | 166 | void actionActivated( QWidget*, QKeyEvent*, const Opie::Ui::OKeyConfigItem& ); |
75 | 167 | ||
76 | private: | 168 | private: |
169 | OKeyPairList m_blackKeys; | ||
77 | OKeyConfigItemList m_keys; | 170 | OKeyConfigItemList m_keys; |
78 | QValueList<QWidget*> m_widgets; | 171 | QValueList<QWidget*> m_widgets; |
172 | Opie::Core::OConfig *m_conf; | ||
173 | QString m_group; | ||
174 | bool m_grab : 1; | ||
79 | class Private; | 175 | class Private; |
80 | Private *d; | 176 | Private *d; |
81 | }; | 177 | }; |
82 | 178 | ||
@@ -85,16 +181,20 @@ class OKeyConfigWidget : public QHBox { | |||
85 | Q_OBJECT | 181 | Q_OBJECT |
86 | public: | 182 | public: |
87 | enum ChangeMode { Imediate, Queu }; | 183 | enum ChangeMode { Imediate, Queu }; |
88 | OKeyConfigWidget( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 184 | OKeyConfigWidget( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
89 | OKeyConfigWidget( OKeyConfig *, QWidget* parent = 0, const char* = 0, WFlags = 0 ); | 185 | OKeyConfigWidget( OKeyConfigManager *, QWidget* parent = 0, const char* = 0, WFlags = 0 ); |
90 | ~OKeyConfigWidget(); | 186 | ~OKeyConfigWidget(); |
91 | 187 | ||
92 | void setChangeMode( enum ChangeMode ); | 188 | void setChangeMode( enum ChangeMode ); |
93 | ChangeMode changeMode()const; | 189 | ChangeMode changeMode()const; |
94 | 190 | ||
191 | void setKeyConfig( OKeyConfigManager* ); | ||
192 | |||
95 | void reload(); | 193 | void reload(); |
194 | void save(); | ||
96 | private: | 195 | private: |
196 | OKeyConfigManager* m_manager; | ||
97 | class Private; | 197 | class Private; |
98 | Private *d; | 198 | Private *d; |
99 | }; | 199 | }; |
100 | 200 | ||