-rw-r--r-- | libopie2/opiecore/okeyconfigmanager.cpp | 16 | ||||
-rw-r--r-- | libopie2/opiecore/okeyconfigmanager.h | 76 |
2 files changed, 88 insertions, 4 deletions
diff --git a/libopie2/opiecore/okeyconfigmanager.cpp b/libopie2/opiecore/okeyconfigmanager.cpp index e6055e0..18740ef 100644 --- a/libopie2/opiecore/okeyconfigmanager.cpp +++ b/libopie2/opiecore/okeyconfigmanager.cpp | |||
@@ -411,2 +411,12 @@ bool OKeyConfigItem::operator!=( const OKeyConfigItem& conf )const { | |||
411 | 411 | ||
412 | /*! \enum OKeyConfigManager::EventMask | ||
413 | <a name="Eventmask flags"></a> | ||
414 | This enum is used to tell OKeyConfigManager which type of key events should inspected. | ||
415 | |||
416 | <ul> | ||
417 | <li>\c MaskPressed When a key is pressed an action performs | ||
418 | <li>\c MaskReleased When a key is released an action performs | ||
419 | </ul> | ||
420 | */ | ||
421 | |||
412 | /** | 422 | /** |
@@ -416,3 +426,3 @@ bool OKeyConfigItem::operator!=( const OKeyConfigItem& conf )const { | |||
416 | * You can use this manager in multiple ways. Either make it handle | 426 | * You can use this manager in multiple ways. Either make it handle |
417 | * QKeyEvents | 427 | * QKeyEvents. The EventMask is set to OKeyConfigManager::MaskReleased by default. |
418 | * | 428 | * |
@@ -475,2 +485,3 @@ OKeyConfigManager::OKeyConfigManager( Opie::Core::OConfig* conf, | |||
475 | QPEApplication::grabKeyboard(); | 485 | QPEApplication::grabKeyboard(); |
486 | m_event_mask = OKeyConfigManager::MaskReleased; | ||
476 | } | 487 | } |
@@ -676,3 +687,4 @@ bool OKeyConfigManager::eventFilter( QObject* obj, QEvent* ev) { | |||
676 | 687 | ||
677 | if ( ev->type() != QEvent::KeyPress && ev->type() != QEvent::KeyRelease ) | 688 | if ( (ev->type() != QEvent::KeyPress||!testEventMask(MaskPressed)) && |
689 | (ev->type() != QEvent::KeyRelease||!testEventMask(MaskReleased)) ) | ||
678 | return false; | 690 | return false; |
diff --git a/libopie2/opiecore/okeyconfigmanager.h b/libopie2/opiecore/okeyconfigmanager.h index d610375..b861675 100644 --- a/libopie2/opiecore/okeyconfigmanager.h +++ b/libopie2/opiecore/okeyconfigmanager.h | |||
@@ -136,3 +136,3 @@ private: | |||
136 | * the event filter and get a signal. | 136 | * the event filter and get a signal. |
137 | * You need to load ans save yourself! | 137 | * You need to load and save yourself! |
138 | * | 138 | * |
@@ -147,3 +147,3 @@ public: | |||
147 | const OKeyPair::List &block = OKeyPair::List(), | 147 | const OKeyPair::List &block = OKeyPair::List(), |
148 | bool grabkeyboard = false, QObject * par = 0, | 148 | bool grabkeyboard = false, QObject * par = 0, |
149 | const char* name = 0 ); | 149 | const char* name = 0 ); |
@@ -170,3 +170,49 @@ public: | |||
170 | 170 | ||
171 | /** | ||
172 | * Sets the event mask flags aMask. | ||
173 | * | ||
174 | * aMask is a combination of OKeyConfigManager::EventMask | ||
175 | * | ||
176 | * @see eventMask(), testEventMask(), addEventMask(), clearEventMask() | ||
177 | */ | ||
178 | void setEventMask(uint aMask); | ||
179 | /** | ||
180 | * Returns the event mask flags set. | ||
181 | * | ||
182 | * aMask is a combination of OKeyConfigManager::EventMask | ||
183 | * | ||
184 | * @see setEventMask(), testEventMask(), addEventMask(), clearEventMask() | ||
185 | */ | ||
186 | uint eventMask()const; | ||
187 | /** | ||
188 | * Test if the event mask flag aMask is set. | ||
189 | * | ||
190 | * @param aMask one of OKeyConfigManager::EventMask | ||
191 | * | ||
192 | * @see eventMask(), setEventMask(), addEventMask(), clearEventMask() | ||
193 | */ | ||
194 | bool testEventMask(uint aMask); | ||
195 | /** | ||
196 | * Add the event mask flag aMask. | ||
197 | * | ||
198 | * @param aMask one of OKeyConfigManager::EventMask | ||
199 | * | ||
200 | * @see eventMask(), setEventMask(), addEventMask(), clearEventMask() | ||
201 | */ | ||
202 | void addEventMask(uint aMask); | ||
203 | /** | ||
204 | * Clears the event mask flag aMask. | ||
205 | * | ||
206 | * @param aMask is one of OKeyConfigManager::EventMask | ||
207 | * | ||
208 | * @see eventMask(), testEventMask(), addEventMask(), setEventMask() | ||
209 | */ | ||
210 | void clearEventMask(uint aMask); | ||
211 | |||
171 | OKeyConfigItem::List keyConfigList()const; | 212 | OKeyConfigItem::List keyConfigList()const; |
213 | |||
214 | enum EventMask { | ||
215 | MaskPressed = 0x1, | ||
216 | MaskReleased = 0x2, | ||
217 | }; | ||
172 | signals: | 218 | signals: |
@@ -199,4 +245,30 @@ private: | |||
199 | Private *d; | 245 | Private *d; |
246 | uint m_event_mask; | ||
200 | }; | 247 | }; |
201 | 248 | ||
249 | inline bool OKeyConfigManager::testEventMask(uint aMask) | ||
250 | { | ||
251 | return (m_event_mask&aMask)!=0; | ||
252 | } | ||
253 | |||
254 | inline void OKeyConfigManager::addEventMask(uint aMask) | ||
255 | { | ||
256 | m_event_mask |= aMask; | ||
257 | } | ||
258 | |||
259 | inline void OKeyConfigManager::clearEventMask(uint aMask) | ||
260 | { | ||
261 | m_event_mask &= ~aMask; | ||
262 | } | ||
263 | |||
264 | inline void OKeyConfigManager::setEventMask(uint aMask) | ||
265 | { | ||
266 | m_event_mask = aMask; | ||
267 | } | ||
268 | |||
269 | inline uint OKeyConfigManager::eventMask()const | ||
270 | { | ||
271 | return m_event_mask; | ||
272 | } | ||
273 | |||
202 | } | 274 | } |