summaryrefslogtreecommitdiff
path: root/libopie2/opiecore/okeyconfigmanager.h
Unidiff
Diffstat (limited to 'libopie2/opiecore/okeyconfigmanager.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/okeyconfigmanager.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/libopie2/opiecore/okeyconfigmanager.h b/libopie2/opiecore/okeyconfigmanager.h
index d0a6247..12804ee 100644
--- a/libopie2/opiecore/okeyconfigmanager.h
+++ b/libopie2/opiecore/okeyconfigmanager.h
@@ -1,271 +1,272 @@
1/* 1/*
2 * Copyright (C) 2004 2 * Copyright (C) 2004
3 * LGPL v2 zecke@handhelds.org 3 * LGPL v2 zecke@handhelds.org
4 */ 4 */
5 5
6 6
7#ifndef ODP_KEY_MANAGER_WIDGET_H 7#ifndef ODP_KEY_MANAGER_WIDGET_H
8#define ODP_KEY_MANAGER_WIDGET_H 8#define ODP_KEY_MANAGER_WIDGET_H
9 9
10#include <opie2/oconfig.h> 10#include <opie2/oconfig.h>
11#include <opie2/odevice.h> 11#include <opie2/odevice.h>
12 12
13#include <qstring.h> 13#include <qstring.h>
14#include <qpixmap.h> 14#include <qpixmap.h>
15#include <qcstring.h> 15#include <qcstring.h>
16#include <qvaluelist.h> 16#include <qvaluelist.h>
17 17
18namespace Opie { 18namespace Opie {
19namespace Core { 19namespace Core {
20 20
21/** 21/**
22 * \brief small class representing a Key with possible modifiers 22 * \brief small class representing a Key with possible modifiers
23 * This class holds information about key code and possible 23 * This class holds information about key code and possible
24 * modifier state. That is the lowest level of the key input 24 * modifier state. That is the lowest level of the key input
25 * functions. 25 * functions.
26 * There are also static methods to get special keys. 26 * There are also static methods to get special keys.
27 * OKeyPair will be used with \see OKeyConfigItem 27 * OKeyPair will be used with \see OKeyConfigItem
28 * 28 *
29 * @since 1.2 29 * @since 1.2
30 */ 30 */
31class OKeyPair { 31class OKeyPair {
32public: 32public:
33 typedef QValueList<OKeyPair> List; 33 typedef QValueList<OKeyPair> List;
34 OKeyPair( int key = -1, int modifier = -1); 34 OKeyPair( int key = -1, int modifier = -1);
35 ~OKeyPair(); 35 ~OKeyPair();
36 36
37 bool operator==( const OKeyPair& )const; 37 bool operator==( const OKeyPair& )const;
38 bool operator!=( const OKeyPair& )const; 38 bool operator!=( const OKeyPair& )const;
39 39
40 bool isEmpty()const; 40 bool isEmpty()const;
41 41
42 int keycode()const; 42 int keycode()const;
43 int modifier()const; 43 int modifier()const;
44 44
45 void setKeycode( int ); 45 void setKeycode( int );
46 void setModifier( int ); 46 void setModifier( int );
47 47
48 static OKeyPair returnKey(); 48 static OKeyPair returnKey();
49 static OKeyPair leftArrowKey(); 49 static OKeyPair leftArrowKey();
50 static OKeyPair rightArrowKey(); 50 static OKeyPair rightArrowKey();
51 static OKeyPair upArrowKey(); 51 static OKeyPair upArrowKey();
52 static OKeyPair downArrowKey(); 52 static OKeyPair downArrowKey();
53 static OKeyPair emptyKey(); 53 static OKeyPair emptyKey();
54 static OKeyPair::List hardwareKeys(); 54 static OKeyPair::List hardwareKeys();
55 55
56private: 56private:
57 int m_key; 57 int m_key;
58 int m_mod; 58 int m_mod;
59 class Private; 59 class Private;
60 Private* d; 60 Private* d;
61}; 61};
62 62
63/** 63/**
64 * A class to represent an OKeyPair. 64 * A class to represent an OKeyPair.
65 * It consists out of a Text exposed to the user, Config Key Item, 65 * It consists out of a Text exposed to the user, Config Key Item,
66 * Pixmap, A default OKeyPair and the set OKeyPair. 66 * Pixmap, A default OKeyPair and the set OKeyPair.
67 * You can also pass an id to it 67 * You can also pass an id to it
68 * 68 *
69 * @since 1.1.2 69 * @since 1.2
70 */ 70 */
71class OKeyConfigItem { 71class OKeyConfigItem {
72 friend class OKeyConfigManager; 72 friend class OKeyConfigManager;
73public: 73public:
74 typedef QValueList<OKeyConfigItem> List; 74 typedef QValueList<OKeyConfigItem> List;
75 OKeyConfigItem( const QString& text = QString::null , const QCString& config_key = QCString(), 75 OKeyConfigItem( const QString& text = QString::null , const QCString& config_key = QCString(),
76 const QPixmap& symbol = QPixmap(), 76 const QPixmap& symbol = QPixmap(),
77 int id = -1, 77 int id = -1,
78 const OKeyPair& def = OKeyPair::emptyKey(), 78 const OKeyPair& def = OKeyPair::emptyKey(),
79 QObject *caller = 0, const char* slot = 0); 79 QObject *caller = 0, const char* slot = 0);
80 OKeyConfigItem( const Opie::Core::ODeviceButton& ); 80 OKeyConfigItem( const Opie::Core::ODeviceButton& );
81 ~OKeyConfigItem(); 81 ~OKeyConfigItem();
82 82
83 bool operator==( const OKeyConfigItem& )const; 83 bool operator==( const OKeyConfigItem& )const;
84 bool operator!=( const OKeyConfigItem& )const; 84 bool operator!=( const OKeyConfigItem& )const;
85 85
86 QString text()const; 86 QString text()const;
87 QPixmap pixmap()const; 87 QPixmap pixmap()const;
88 int id()const; 88 int id()const;
89 89
90 90
91 91
92 OKeyPair keyPair()const; 92 OKeyPair keyPair()const;
93 OKeyPair defaultKeyPair()const; 93 OKeyPair defaultKeyPair()const;
94 QCString configKey()const; 94 QCString configKey()const;
95 95
96 96
97 void setText( const QString& text ); 97 void setText( const QString& text );
98 void setPixmap( const QPixmap& ); 98 void setPixmap( const QPixmap& );
99 void setKeyPair( const OKeyPair& ); 99 void setKeyPair( const OKeyPair& );
100 void setDefaultKeyPair( const OKeyPair& ); 100 void setDefaultKeyPair( const OKeyPair& );
101 101
102 bool isEmpty()const; 102 bool isEmpty()const;
103 103
104protected: 104protected:
105 QObject *object()const; 105 QObject *object()const;
106 QCString slot()const; 106 QCString slot()const;
107 void setId( int id ); 107 void setId( int id );
108 void setConfigKey( const QCString& ); 108 void setConfigKey( const QCString& );
109 109
110private: 110private:
111 QString m_text; 111 QString m_text;
112 QCString m_config; 112 QCString m_config;
113 QPixmap m_pix; 113 QPixmap m_pix;
114 int m_id; 114 int m_id;
115 OKeyPair m_key; 115 OKeyPair m_key;
116 OKeyPair m_def; 116 OKeyPair m_def;
117 QObject *m_obj; 117 QObject *m_obj;
118 QCString m_str; 118 QCString m_str;
119 class Private; 119 class Private;
120 Private *d; 120 Private *d;
121}; 121};
122 122
123 123
124 124
125/** 125/**
126 * \brief A manager to load and save Key Actions and get notified 126 * \brief A manager to load and save Key Actions and get notified
127 * This is the Manager for KeyActions. 127 * This is the Manager for KeyActions.
128 * You can say from which config and group to read data, to grab the 128 * You can say from which config and group to read data, to grab the
129 * keyboard to handle hardware keys, you can supply a blacklist of 129 * keyboard to handle hardware keys, you can supply a blacklist of
130 * keys which should not be used by allowed to be used. 130 * keys which should not be used by allowed to be used.
131 * You can even pass this manager to a Widget to do the configuration for you. 131 * You can even pass this manager to a Widget to do the configuration for you.
132 * You need to add OKeyConfigItem for your keys and then issue a load() to 132 * You need to add OKeyConfigItem for your keys and then issue a load() to
133 * read the Key information. 133 * read the Key information.
134 * You can either handle the QKeyEvent yourself and ask this class if it is 134 * You can either handle the QKeyEvent yourself and ask this class if it is
135 * handled by your action and let give you the action. Or you can install 135 * handled by your action and let give you the action. Or you can install
136 * the event filter and get a signal. 136 * the event filter and get a signal.
137 * You need to load and save yourself! 137 * You need to load and save yourself!
138 * 138 *
139 * Again if you want to extend it and I missed a virtual, tell me so I can improve (zecke@handhelds.org) 139 * Again if you want to extend it and I missed a virtual, tell me so I can improve (zecke@handhelds.org)
140 * 140 *
141 * @since 1.1.2 141 * @since 1.1.2
142 */ 142 */
143class OKeyConfigManager : public QObject { 143class OKeyConfigManager : public QObject {
144 Q_OBJECT 144 Q_OBJECT
145 typedef QMap<int, OKeyConfigItem::List> OKeyMapConfigPrivate; 145 typedef QMap<int, OKeyConfigItem::List> OKeyMapConfigPrivate;
146public: 146public:
147 enum EventMask { 147 enum EventMask {
148 MaskPressed = 0x1, 148 MaskPressed = 0x1,
149 MaskReleased = 0x2, 149 MaskReleased = 0x2,
150 }; 150 };
151 151
152 OKeyConfigManager(Opie::Core::OConfig *conf = 0, 152 OKeyConfigManager(Opie::Core::OConfig *conf = 0,
153 const QString& group = QString::null, 153 const QString& group = QString::null,
154 const OKeyPair::List &block = OKeyPair::List(), 154 const OKeyPair::List &block = OKeyPair::List(),
155 bool grabkeyboard = false, QObject * par = 0, 155 bool grabkeyboard = false, QObject * par = 0,
156 const char* name = 0 ); 156 const char* name = 0 );
157 virtual ~OKeyConfigManager(); 157 virtual ~OKeyConfigManager();
158 158
159public slots:
159 virtual void load(); 160 virtual void load();
160 virtual void save(); 161 virtual void save();
162 void handleWidget( QWidget* );
161 163
164public:
162 virtual OKeyConfigItem handleKeyEvent( QKeyEvent* ); 165 virtual OKeyConfigItem handleKeyEvent( QKeyEvent* );
163 int handleKeyEventId( QKeyEvent* ); 166 int handleKeyEventId( QKeyEvent* );
164 167
165 void addKeyConfig( const OKeyConfigItem& ); 168 void addKeyConfig( const OKeyConfigItem& );
166 void removeKeyConfig( const OKeyConfigItem& ); 169 void removeKeyConfig( const OKeyConfigItem& );
167 void clearKeyConfig(); 170 void clearKeyConfig();
168 171
169 void addToBlackList( const OKeyPair& ); 172 void addToBlackList( const OKeyPair& );
170 void removeFromBlackList( const OKeyPair& ); 173 void removeFromBlackList( const OKeyPair& );
171 void clearBlackList(); 174 void clearBlackList();
172 OKeyPair::List blackList()const; 175 OKeyPair::List blackList()const;
173 176
174 void handleWidget( QWidget* );
175
176 bool eventFilter( QObject*, QEvent* ); 177 bool eventFilter( QObject*, QEvent* );
177 178
178 /** 179 /**
179 * Sets the event mask flags aMask. 180 * Sets the event mask flags aMask.
180 * 181 *
181 * aMask is a combination of OKeyConfigManager::EventMask 182 * aMask is a combination of OKeyConfigManager::EventMask
182 * 183 *
183 * @see eventMask(), testEventMask(), addEventMask(), clearEventMask() 184 * @see eventMask(), testEventMask(), addEventMask(), clearEventMask()
184 */ 185 */
185 void setEventMask(uint aMask); 186 void setEventMask(uint aMask);
186 /** 187 /**
187 * Returns the event mask flags set. 188 * Returns the event mask flags set.
188 * 189 *
189 * aMask is a combination of OKeyConfigManager::EventMask 190 * aMask is a combination of OKeyConfigManager::EventMask
190 * 191 *
191 * @see setEventMask(), testEventMask(), addEventMask(), clearEventMask() 192 * @see setEventMask(), testEventMask(), addEventMask(), clearEventMask()
192 */ 193 */
193 uint eventMask()const; 194 uint eventMask()const;
194 /** 195 /**
195 * Test if the event mask flag aMask is set. 196 * Test if the event mask flag aMask is set.
196 * 197 *
197 * @param aMask one of OKeyConfigManager::EventMask 198 * @param aMask one of OKeyConfigManager::EventMask
198 * 199 *
199 * @see eventMask(), setEventMask(), addEventMask(), clearEventMask() 200 * @see eventMask(), setEventMask(), addEventMask(), clearEventMask()
200 */ 201 */
201 bool testEventMask(uint aMask); 202 bool testEventMask(uint aMask);
202 /** 203 /**
203 * Add the event mask flag aMask. 204 * Add the event mask flag aMask.
204 * 205 *
205 * @param aMask one of OKeyConfigManager::EventMask 206 * @param aMask one of OKeyConfigManager::EventMask
206 * 207 *
207 * @see eventMask(), setEventMask(), addEventMask(), clearEventMask() 208 * @see eventMask(), setEventMask(), addEventMask(), clearEventMask()
208 */ 209 */
209 void addEventMask(uint aMask); 210 void addEventMask(uint aMask);
210 /** 211 /**
211 * Clears the event mask flag aMask. 212 * Clears the event mask flag aMask.
212 * 213 *
213 * @param aMask is one of OKeyConfigManager::EventMask 214 * @param aMask is one of OKeyConfigManager::EventMask
214 * 215 *
215 * @see eventMask(), testEventMask(), addEventMask(), setEventMask() 216 * @see eventMask(), testEventMask(), addEventMask(), setEventMask()
216 */ 217 */
217 void clearEventMask(uint aMask); 218 void clearEventMask(uint aMask);
218 219
219 OKeyConfigItem::List keyConfigList()const; 220 OKeyConfigItem::List keyConfigList()const;
220 221
221signals: 222signals:
222 /** 223 /**
223 * The Signals are triggered on KeyPress and KeyRelease! 224 * The Signals are triggered on KeyPress and KeyRelease!
224 * You can check the isDown of the QKeyEvent 225 * You can check the isDown of the QKeyEvent
225 * @see QKeyEvent 226 * @see QKeyEvent
226 */ 227 */
227 void actionActivated( QWidget*, QKeyEvent*, const Opie::Core::OKeyConfigItem& ); 228 void actionActivated( QWidget*, QKeyEvent*, const Opie::Core::OKeyConfigItem& );
228 229
229 /** 230 /**
230 * This Signal correspondents to the OKeyConfigItem slot 231 * This Signal correspondents to the OKeyConfigItem slot
231 * and object 232 * and object
232 * 233 *
233 * @see OKeyConfigItem::slot 234 * @see OKeyConfigItem::slot
234 * @see OKeyConfigItem::object 235 * @see OKeyConfigItem::object
235 */ 236 */
236 void actionActivated( QWidget* par, QKeyEvent* key); 237 void actionActivated( QWidget* par, QKeyEvent* key);
237 238
238private: 239private:
239 OKeyConfigItem::List keyList( int ); 240 OKeyConfigItem::List keyList( int );
240 OKeyConfigItem::List m_keys; 241 OKeyConfigItem::List m_keys;
241 QValueList<QWidget*> m_widgets; 242 QValueList<QWidget*> m_widgets;
242 Opie::Core::OConfig *m_conf; 243 Opie::Core::OConfig *m_conf;
243 QString m_group; 244 QString m_group;
244 OKeyPair::List m_blackKeys; 245 OKeyPair::List m_blackKeys;
245 bool m_grab : 1; 246 bool m_grab : 1;
246 OKeyMapConfigPrivate *m_map; 247 OKeyMapConfigPrivate *m_map;
247 class Private; 248 class Private;
248 Private *d; 249 Private *d;
249 uint m_event_mask; 250 uint m_event_mask;
250}; 251};
251 252
252inline bool OKeyConfigManager::testEventMask(uint aMask) 253inline bool OKeyConfigManager::testEventMask(uint aMask)
253{ 254{
254 return (m_event_mask&aMask)!=0; 255 return (m_event_mask&aMask)!=0;
255} 256}
256 257
257inline void OKeyConfigManager::addEventMask(uint aMask) 258inline void OKeyConfigManager::addEventMask(uint aMask)
258{ 259{
259 m_event_mask |= aMask; 260 m_event_mask |= aMask;
260} 261}
261 262
262inline void OKeyConfigManager::clearEventMask(uint aMask) 263inline void OKeyConfigManager::clearEventMask(uint aMask)
263{ 264{
264 m_event_mask &= ~aMask; 265 m_event_mask &= ~aMask;
265} 266}
266 267
267inline void OKeyConfigManager::setEventMask(uint aMask) 268inline void OKeyConfigManager::setEventMask(uint aMask)
268{ 269{
269 m_event_mask = aMask; 270 m_event_mask = aMask;
270} 271}
271 272