author | alwin <alwin> | 2004-04-20 14:08:07 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-04-20 14:08:07 (UTC) |
commit | 135990877f009bd05f00b064a1a255be3e5ab087 (patch) (side-by-side diff) | |
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 @@ -411,2 +411,12 @@ bool OKeyConfigItem::operator!=( const OKeyConfigItem& conf )const { +/*! \enum OKeyConfigManager::EventMask + <a name="Eventmask flags"></a> + This enum is used to tell OKeyConfigManager which type of key events should inspected. + + <ul> + <li>\c MaskPressed When a key is pressed an action performs + <li>\c MaskReleased When a key is released an action performs + </ul> +*/ + /** @@ -416,3 +426,3 @@ bool OKeyConfigItem::operator!=( const OKeyConfigItem& conf )const { * You can use this manager in multiple ways. Either make it handle - * QKeyEvents + * QKeyEvents. The EventMask is set to OKeyConfigManager::MaskReleased by default. * @@ -475,2 +485,3 @@ OKeyConfigManager::OKeyConfigManager( Opie::Core::OConfig* conf, QPEApplication::grabKeyboard(); + m_event_mask = OKeyConfigManager::MaskReleased; } @@ -676,3 +687,4 @@ bool OKeyConfigManager::eventFilter( QObject* obj, QEvent* ev) { - if ( ev->type() != QEvent::KeyPress && ev->type() != QEvent::KeyRelease ) + if ( (ev->type() != QEvent::KeyPress||!testEventMask(MaskPressed)) && + (ev->type() != QEvent::KeyRelease||!testEventMask(MaskReleased)) ) 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: * the event filter and get a signal. - * You need to load ans save yourself! + * You need to load and save yourself! * @@ -170,3 +170,49 @@ public: + /** + * Sets the event mask flags aMask. + * + * aMask is a combination of OKeyConfigManager::EventMask + * + * @see eventMask(), testEventMask(), addEventMask(), clearEventMask() + */ + void setEventMask(uint aMask); + /** + * Returns the event mask flags set. + * + * aMask is a combination of OKeyConfigManager::EventMask + * + * @see setEventMask(), testEventMask(), addEventMask(), clearEventMask() + */ + uint eventMask()const; + /** + * Test if the event mask flag aMask is set. + * + * @param aMask one of OKeyConfigManager::EventMask + * + * @see eventMask(), setEventMask(), addEventMask(), clearEventMask() + */ + bool testEventMask(uint aMask); + /** + * Add the event mask flag aMask. + * + * @param aMask one of OKeyConfigManager::EventMask + * + * @see eventMask(), setEventMask(), addEventMask(), clearEventMask() + */ + void addEventMask(uint aMask); + /** + * Clears the event mask flag aMask. + * + * @param aMask is one of OKeyConfigManager::EventMask + * + * @see eventMask(), testEventMask(), addEventMask(), setEventMask() + */ + void clearEventMask(uint aMask); + OKeyConfigItem::List keyConfigList()const; + + enum EventMask { + MaskPressed = 0x1, + MaskReleased = 0x2, + }; signals: @@ -199,4 +245,30 @@ private: Private *d; + uint m_event_mask; }; +inline bool OKeyConfigManager::testEventMask(uint aMask) +{ + return (m_event_mask&aMask)!=0; +} + +inline void OKeyConfigManager::addEventMask(uint aMask) +{ + m_event_mask |= aMask; +} + +inline void OKeyConfigManager::clearEventMask(uint aMask) +{ + m_event_mask &= ~aMask; +} + +inline void OKeyConfigManager::setEventMask(uint aMask) +{ + m_event_mask = aMask; +} + +inline uint OKeyConfigManager::eventMask()const +{ + return m_event_mask; +} + } |