-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 @@ -410,4 +410,14 @@ 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> +*/ + /** * \brief c'tor @@ -415,5 +425,5 @@ 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. * * \code @@ -474,4 +484,5 @@ OKeyConfigManager::OKeyConfigManager( Opie::Core::OConfig* conf, if ( m_grab ) QPEApplication::grabKeyboard(); + m_event_mask = OKeyConfigManager::MaskReleased; } @@ -675,5 +686,6 @@ bool OKeyConfigManager::eventFilter( QObject* obj, QEvent* ev) { return false; - 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 @@ -135,5 +135,5 @@ private: * handled by your action and let give you the action. Or you can install * the event filter and get a signal. - * You need to load ans save yourself! + * You need to load and save yourself! * * @since 1.1.2 @@ -146,5 +146,5 @@ public: const QString& group = QString::null, const OKeyPair::List &block = OKeyPair::List(), - bool grabkeyboard = false, QObject * par = 0, + bool grabkeyboard = false, QObject * par = 0, const char* name = 0 ); ~OKeyConfigManager(); @@ -169,5 +169,51 @@ public: bool eventFilter( QObject*, QEvent* ); + /** + * 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: /** @@ -198,6 +244,32 @@ private: class 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; +} + } } |