author | alwin <alwin> | 2004-04-20 14:08:07 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-04-20 14:08:07 (UTC) |
commit | 135990877f009bd05f00b064a1a255be3e5ab087 (patch) (unidiff) | |
tree | 4265e1686a329afe435f2695115eeba93a37e617 | |
parent | 76b2ca3aff26929dd4e86b66a6f49e99cddd1bda (diff) | |
download | opie-135990877f009bd05f00b064a1a255be3e5ab087.zip opie-135990877f009bd05f00b064a1a255be3e5ab087.tar.gz opie-135990877f009bd05f00b064a1a255be3e5ab087.tar.bz2 |
added EventMask for keynotifiers. eg., a mask on which type of keyevents
(press and/or release) the keyconfig makes an action
-rw-r--r-- | libopie2/opiecore/okeyconfigmanager.cpp | 16 | ||||
-rw-r--r-- | libopie2/opiecore/okeyconfigmanager.h | 74 |
2 files changed, 87 insertions, 3 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 | |||
@@ -409,12 +409,22 @@ bool OKeyConfigItem::operator!=( const OKeyConfigItem& conf )const { | |||
409 | return !( *this == conf ); | 409 | return !( *this == conf ); |
410 | } | 410 | } |
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 | /** |
413 | * \brief c'tor | 423 | * \brief c'tor |
414 | * The Constructor for a OKeyConfigManager | 424 | * The Constructor for a OKeyConfigManager |
415 | * | 425 | * |
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 | * |
419 | * \code | 429 | * \code |
420 | * Opie::Core::Config conf = oApp->config(); | 430 | * Opie::Core::Config conf = oApp->config(); |
@@ -473,6 +483,7 @@ OKeyConfigManager::OKeyConfigManager( Opie::Core::OConfig* conf, | |||
473 | m_blackKeys( black ), m_grab( grabkeyboard ), m_map( 0 ){ | 483 | m_blackKeys( black ), m_grab( grabkeyboard ), m_map( 0 ){ |
474 | if ( m_grab ) | 484 | if ( m_grab ) |
475 | QPEApplication::grabKeyboard(); | 485 | QPEApplication::grabKeyboard(); |
486 | m_event_mask = OKeyConfigManager::MaskReleased; | ||
476 | } | 487 | } |
477 | 488 | ||
478 | 489 | ||
@@ -674,7 +685,8 @@ bool OKeyConfigManager::eventFilter( QObject* obj, QEvent* ev) { | |||
674 | if ( !obj->isWidgetType() ) | 685 | if ( !obj->isWidgetType() ) |
675 | return false; | 686 | return false; |
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; |
679 | 691 | ||
680 | QKeyEvent *key = static_cast<QKeyEvent*>( ev ); | 692 | QKeyEvent *key = static_cast<QKeyEvent*>( ev ); |
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 | |||
@@ -134,7 +134,7 @@ private: | |||
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 ans save yourself! | 137 | * You need to load and save yourself! |
138 | * | 138 | * |
139 | * @since 1.1.2 | 139 | * @since 1.1.2 |
140 | */ | 140 | */ |
@@ -168,7 +168,53 @@ public: | |||
168 | 168 | ||
169 | bool eventFilter( QObject*, QEvent* ); | 169 | bool eventFilter( QObject*, QEvent* ); |
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: |
173 | /** | 219 | /** |
174 | * The Signals are triggered on KeyPress and KeyRelease! | 220 | * The Signals are triggered on KeyPress and KeyRelease! |
@@ -197,8 +243,34 @@ private: | |||
197 | OKeyMapConfigPrivate *m_map; | 243 | OKeyMapConfigPrivate *m_map; |
198 | class Private; | 244 | class 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 | } |
203 | } | 275 | } |
204 | 276 | ||