summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/okeyconfigmanager.cpp16
-rw-r--r--libopie2/opiecore/okeyconfigmanager.h76
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
@@ -406,18 +406,28 @@ bool OKeyConfigItem::operator==( const OKeyConfigItem& conf )const {
406} 406}
407 407
408bool OKeyConfigItem::operator!=( const OKeyConfigItem& conf )const { 408bool 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();
421 * Opie::Core::OKeyPairList blackList; 431 * Opie::Core::OKeyPairList blackList;
422 * blackList.append(Opie::Core::OKeyPair::leftArrowKey()); 432 * blackList.append(Opie::Core::OKeyPair::leftArrowKey());
423 * blackList.append(Opie::Core::OKeyPair::rightArrowKey()); 433 * blackList.append(Opie::Core::OKeyPair::rightArrowKey());
@@ -470,12 +480,13 @@ OKeyConfigManager::OKeyConfigManager( Opie::Core::OConfig* conf,
470 bool grabkeyboard, QObject* par, 480 bool grabkeyboard, QObject* par,
471 const char* name) 481 const char* name)
472 : QObject( par, name ), m_conf( conf ), m_group( group ), 482 : QObject( par, name ), m_conf( conf ), m_group( group ),
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
479/** 490/**
480 * Destructor 491 * Destructor
481 */ 492 */
@@ -671,13 +682,14 @@ void OKeyConfigManager::handleWidget( QWidget* wid ) {
671 * @internal 682 * @internal
672 */ 683 */
673bool OKeyConfigManager::eventFilter( QObject* obj, QEvent* ev) { 684bool 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 );
681 OKeyConfigItem item = handleKeyEvent( key ); 693 OKeyConfigItem item = handleKeyEvent( key );
682 694
683 if ( item.isEmpty() ) 695 if ( item.isEmpty() )
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
@@ -131,24 +131,24 @@ private:
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 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 */
141class OKeyConfigManager : public QObject { 141class OKeyConfigManager : public QObject {
142 Q_OBJECT 142 Q_OBJECT
143 typedef QMap<int, OKeyConfigItem::List> OKeyMapConfigPrivate; 143 typedef QMap<int, OKeyConfigItem::List> OKeyMapConfigPrivate;
144public: 144public:
145 OKeyConfigManager(Opie::Core::OConfig *conf = 0, 145 OKeyConfigManager(Opie::Core::OConfig *conf = 0,
146 const QString& group = QString::null, 146 const QString& group = QString::null,
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 );
150 ~OKeyConfigManager(); 150 ~OKeyConfigManager();
151 151
152 void load(); 152 void load();
153 void save(); 153 void save();
154 154
@@ -165,13 +165,59 @@ public:
165 OKeyPair::List blackList()const; 165 OKeyPair::List blackList()const;
166 166
167 void handleWidget( QWidget* ); 167 void handleWidget( QWidget* );
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 };
172signals: 218signals:
173 /** 219 /**
174 * The Signals are triggered on KeyPress and KeyRelease! 220 * The Signals are triggered on KeyPress and KeyRelease!
175 * You can check the isDown of the QKeyEvent 221 * You can check the isDown of the QKeyEvent
176 * @see QKeyEvent 222 * @see QKeyEvent
177 */ 223 */
@@ -194,12 +240,38 @@ private:
194 QString m_group; 240 QString m_group;
195 OKeyPair::List m_blackKeys; 241 OKeyPair::List m_blackKeys;
196 bool m_grab : 1; 242 bool m_grab : 1;
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
249inline bool OKeyConfigManager::testEventMask(uint aMask)
250{
251 return (m_event_mask&aMask)!=0;
252}
253
254inline void OKeyConfigManager::addEventMask(uint aMask)
255{
256 m_event_mask |= aMask;
257}
258
259inline void OKeyConfigManager::clearEventMask(uint aMask)
260{
261 m_event_mask &= ~aMask;
262}
263
264inline void OKeyConfigManager::setEventMask(uint aMask)
265{
266 m_event_mask = aMask;
267}
268
269inline uint OKeyConfigManager::eventMask()const
270{
271 return m_event_mask;
272}
273
202} 274}
203} 275}
204 276
205#endif 277#endif