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 | 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 | |||
@@ -380,128 +380,139 @@ bool OKeyConfigItem::isEmpty()const { | |||
380 | if ( !m_key.isEmpty() ) return false; | 380 | if ( !m_key.isEmpty() ) return false; |
381 | if ( !m_text.isEmpty() ) return false; | 381 | if ( !m_text.isEmpty() ) return false; |
382 | if ( m_id != -1 ) return false; | 382 | if ( m_id != -1 ) return false; |
383 | 383 | ||
384 | return true; | 384 | return true; |
385 | } | 385 | } |
386 | 386 | ||
387 | /** | 387 | /** |
388 | * Check if the KeyPairs are the same | 388 | * Check if the KeyPairs are the same |
389 | */ | 389 | */ |
390 | bool OKeyConfigItem::operator==( const OKeyConfigItem& conf )const { | 390 | bool OKeyConfigItem::operator==( const OKeyConfigItem& conf )const { |
391 | /* if ( isEmpty() == conf.isEmpty() ) return true; | 391 | /* if ( isEmpty() == conf.isEmpty() ) return true; |
392 | else if ( isEmpty() != conf.isEmpty() ) return false; | 392 | else if ( isEmpty() != conf.isEmpty() ) return false; |
393 | else if ( !isEmpty()!= conf.isEmpty() ) return false; | 393 | else if ( !isEmpty()!= conf.isEmpty() ) return false; |
394 | */ | 394 | */ |
395 | 395 | ||
396 | if ( m_id != conf.m_id ) return false; | 396 | if ( m_id != conf.m_id ) return false; |
397 | if ( m_obj != conf.m_obj ) return false; | 397 | if ( m_obj != conf.m_obj ) return false; |
398 | if ( m_text != conf.m_text ) return false; | 398 | if ( m_text != conf.m_text ) return false; |
399 | if ( m_key != conf.m_key ) return false; | 399 | if ( m_key != conf.m_key ) return false; |
400 | if ( m_def != conf.m_def ) return false; | 400 | if ( m_def != conf.m_def ) return false; |
401 | 401 | ||
402 | 402 | ||
403 | 403 | ||
404 | return true; | 404 | return true; |
405 | 405 | ||
406 | } | 406 | } |
407 | 407 | ||
408 | bool OKeyConfigItem::operator!=( const OKeyConfigItem& conf )const { | 408 | 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(); |
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()); |
424 | * Opie::Core::OKeyConfigManager *manager = new Opie::Core::OKeyConfigManager(conf,"key_actions",blackList, | 434 | * Opie::Core::OKeyConfigManager *manager = new Opie::Core::OKeyConfigManager(conf,"key_actions",blackList, |
425 | * false); | 435 | * false); |
426 | * QListView *view = new QListView(); | 436 | * QListView *view = new QListView(); |
427 | * manager->handleWidget(view); | 437 | * manager->handleWidget(view); |
428 | * manager->addKeyConfig( Opie::Core::OKeyPair::returnKey()); | 438 | * manager->addKeyConfig( Opie::Core::OKeyPair::returnKey()); |
429 | * manager->load(); | 439 | * manager->load(); |
430 | * | 440 | * |
431 | * connect(manager,SIGNAL(actionActivated(QWidget*,QKeyEvent*,const Opie::Core::OKeyConfigItem&)), | 441 | * connect(manager,SIGNAL(actionActivated(QWidget*,QKeyEvent*,const Opie::Core::OKeyConfigItem&)), |
432 | * this,SLOT(slotHandleKey(QWidget*,QKeyEvent*,const Opie::Core::OKeyConfigItem&))); | 442 | * this,SLOT(slotHandleKey(QWidget*,QKeyEvent*,const Opie::Core::OKeyConfigItem&))); |
433 | * | 443 | * |
434 | * .... | 444 | * .... |
435 | * | 445 | * |
436 | * void update(){ | 446 | * void update(){ |
437 | * QDialog diag(true); | 447 | * QDialog diag(true); |
438 | * QHBoxLayout *lay = new QHBoxLayout(&diag); | 448 | * QHBoxLayout *lay = new QHBoxLayout(&diag); |
439 | * Opie::Ui::OKeyConfigWidget *wid = new Opie::Ui::OKeyConfigWidget(manager,&diag); | 449 | * Opie::Ui::OKeyConfigWidget *wid = new Opie::Ui::OKeyConfigWidget(manager,&diag); |
440 | * wid->setChangeMode(Opie::Ui::OKeyConfigWidget::Queu); | 450 | * wid->setChangeMode(Opie::Ui::OKeyConfigWidget::Queu); |
441 | * lay->addWidget(wid); | 451 | * lay->addWidget(wid); |
442 | * if(QPEApplication::execDialog( &diag)== QDialog::Accepted){ | 452 | * if(QPEApplication::execDialog( &diag)== QDialog::Accepted){ |
443 | * wid->save(); | 453 | * wid->save(); |
444 | * } | 454 | * } |
445 | * } | 455 | * } |
446 | * | 456 | * |
447 | * .... | 457 | * .... |
448 | * MyListView::keyPressEvent( QKeyEvent* e ){ | 458 | * MyListView::keyPressEvent( QKeyEvent* e ){ |
449 | * Opie::Ui::OKeyConfigItem item = manager->handleKeyEvent(e); | 459 | * Opie::Ui::OKeyConfigItem item = manager->handleKeyEvent(e); |
450 | * if(!item.isEmpty() ){ | 460 | * if(!item.isEmpty() ){ |
451 | * switch(item.id()){ | 461 | * switch(item.id()){ |
452 | * case My_Delete_Key: | 462 | * case My_Delete_Key: |
453 | * break; | 463 | * break; |
454 | * } | 464 | * } |
455 | * } | 465 | * } |
456 | * } | 466 | * } |
457 | * | 467 | * |
458 | * \endcode | 468 | * \endcode |
459 | * | 469 | * |
460 | * @param conf The Config where the KeySetting should be stored | 470 | * @param conf The Config where the KeySetting should be stored |
461 | * @param group The group where the KeySetting will be stored | 471 | * @param group The group where the KeySetting will be stored |
462 | * @param black Which keys shouldn't be allowed to handle | 472 | * @param black Which keys shouldn't be allowed to handle |
463 | * @param grabkeyboard Calls QPEApplication::grabKeyboard to allow handling of DeviceButtons | 473 | * @param grabkeyboard Calls QPEApplication::grabKeyboard to allow handling of DeviceButtons |
464 | * @param par The parent/owner of this manager | 474 | * @param par The parent/owner of this manager |
465 | * @param name The name of this object | 475 | * @param name The name of this object |
466 | */ | 476 | */ |
467 | OKeyConfigManager::OKeyConfigManager( Opie::Core::OConfig* conf, | 477 | OKeyConfigManager::OKeyConfigManager( Opie::Core::OConfig* conf, |
468 | const QString& group, | 478 | const QString& group, |
469 | const OKeyPair::List& black, | 479 | const OKeyPair::List& black, |
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 | */ |
482 | OKeyConfigManager::~OKeyConfigManager() { | 493 | OKeyConfigManager::~OKeyConfigManager() { |
483 | if ( m_grab ) | 494 | if ( m_grab ) |
484 | QPEApplication::ungrabKeyboard(); | 495 | QPEApplication::ungrabKeyboard(); |
485 | } | 496 | } |
486 | 497 | ||
487 | /** | 498 | /** |
488 | * Load the Configuration from the OConfig | 499 | * Load the Configuration from the OConfig |
489 | * If a Key is restricted but was in the config we will | 500 | * If a Key is restricted but was in the config we will |
490 | * make it be the empty key paur | 501 | * make it be the empty key paur |
491 | * We will change the group but restore to the previous. | 502 | * We will change the group but restore to the previous. |
492 | * | 503 | * |
493 | * @see OKeyPair::emptyKey | 504 | * @see OKeyPair::emptyKey |
494 | */ | 505 | */ |
495 | void OKeyConfigManager::load() { | 506 | void OKeyConfigManager::load() { |
496 | Opie::Core::OConfigGroupSaver( m_conf, m_group ); | 507 | Opie::Core::OConfigGroupSaver( m_conf, m_group ); |
497 | 508 | ||
498 | /* | 509 | /* |
499 | * Read each item | 510 | * Read each item |
500 | */ | 511 | */ |
501 | int key, mod; | 512 | int key, mod; |
502 | for( OKeyConfigItem::List::Iterator it = m_keys.begin(); it != m_keys.end(); ++it ) { | 513 | for( OKeyConfigItem::List::Iterator it = m_keys.begin(); it != m_keys.end(); ++it ) { |
503 | key = m_conf->readNumEntry( (*it).configKey()+"key", (*it).defaultKeyPair().keycode() ); | 514 | key = m_conf->readNumEntry( (*it).configKey()+"key", (*it).defaultKeyPair().keycode() ); |
504 | mod = m_conf->readNumEntry( (*it).configKey()+"mod", (*it).defaultKeyPair().modifier() ); | 515 | mod = m_conf->readNumEntry( (*it).configKey()+"mod", (*it).defaultKeyPair().modifier() ); |
505 | OKeyPair okey( key, mod ); | 516 | OKeyPair okey( key, mod ); |
506 | 517 | ||
507 | if ( !m_blackKeys.contains( okey ) && key != -1 && mod != -1 ) | 518 | if ( !m_blackKeys.contains( okey ) && key != -1 && mod != -1 ) |
@@ -645,65 +656,66 @@ void OKeyConfigManager::removeFromBlackList( const OKeyPair& key ) { | |||
645 | * Clear the blackList | 656 | * Clear the blackList |
646 | */ | 657 | */ |
647 | void OKeyConfigManager::clearBlackList() { | 658 | void OKeyConfigManager::clearBlackList() { |
648 | m_blackKeys.clear(); | 659 | m_blackKeys.clear(); |
649 | delete m_map; m_map = 0; | 660 | delete m_map; m_map = 0; |
650 | } | 661 | } |
651 | 662 | ||
652 | 663 | ||
653 | /** | 664 | /** |
654 | * Return a copy of the blackList | 665 | * Return a copy of the blackList |
655 | */ | 666 | */ |
656 | OKeyPair::List OKeyConfigManager::blackList()const { | 667 | OKeyPair::List OKeyConfigManager::blackList()const { |
657 | return m_blackKeys; | 668 | return m_blackKeys; |
658 | } | 669 | } |
659 | 670 | ||
660 | 671 | ||
661 | /** | 672 | /** |
662 | * Ask the Manager to handle KeyEvents for you. | 673 | * Ask the Manager to handle KeyEvents for you. |
663 | * All handled keys will emit a QSignal and return true | 674 | * All handled keys will emit a QSignal and return true |
664 | * that it handled the keyevent | 675 | * that it handled the keyevent |
665 | */ | 676 | */ |
666 | void OKeyConfigManager::handleWidget( QWidget* wid ) { | 677 | void OKeyConfigManager::handleWidget( QWidget* wid ) { |
667 | wid->installEventFilter( this ); | 678 | wid->installEventFilter( this ); |
668 | } | 679 | } |
669 | 680 | ||
670 | /** | 681 | /** |
671 | * @internal | 682 | * @internal |
672 | */ | 683 | */ |
673 | bool OKeyConfigManager::eventFilter( QObject* obj, QEvent* ev) { | 684 | 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 ); |
681 | OKeyConfigItem item = handleKeyEvent( key ); | 693 | OKeyConfigItem item = handleKeyEvent( key ); |
682 | 694 | ||
683 | if ( item.isEmpty() ) | 695 | if ( item.isEmpty() ) |
684 | return false; | 696 | return false; |
685 | 697 | ||
686 | QWidget *wid = static_cast<QWidget*>( obj ); | 698 | QWidget *wid = static_cast<QWidget*>( obj ); |
687 | 699 | ||
688 | if ( item.object() && !item.slot().isEmpty() ) { | 700 | if ( item.object() && !item.slot().isEmpty() ) { |
689 | connect( this, SIGNAL( actionActivated(QWidget*, QKeyEvent*)), | 701 | connect( this, SIGNAL( actionActivated(QWidget*, QKeyEvent*)), |
690 | item.object(), item.slot().data() ); | 702 | item.object(), item.slot().data() ); |
691 | emit actionActivated(wid, key); | 703 | emit actionActivated(wid, key); |
692 | disconnect( this, SIGNAL(actionActivated(QWidget*,QKeyEvent*)), | 704 | disconnect( this, SIGNAL(actionActivated(QWidget*,QKeyEvent*)), |
693 | item.object(), item.slot().data() ); | 705 | item.object(), item.slot().data() ); |
694 | } | 706 | } |
695 | emit actionActivated( wid, key, item ); | 707 | emit actionActivated( wid, key, item ); |
696 | 708 | ||
697 | return true; | 709 | return true; |
698 | } | 710 | } |
699 | 711 | ||
700 | /** | 712 | /** |
701 | * @internal | 713 | * @internal |
702 | */ | 714 | */ |
703 | OKeyConfigItem::List OKeyConfigManager::keyList( int keycode) { | 715 | OKeyConfigItem::List OKeyConfigManager::keyList( int keycode) { |
704 | /* | 716 | /* |
705 | * Create the map if not existing anymore | 717 | * Create the map if not existing anymore |
706 | */ | 718 | */ |
707 | if ( !m_map ) { | 719 | if ( !m_map ) { |
708 | m_map = new OKeyMapConfigPrivate; | 720 | m_map = new OKeyMapConfigPrivate; |
709 | /* for every key */ | 721 | /* for every key */ |
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 | |||
@@ -105,101 +105,173 @@ protected: | |||
105 | QObject *object()const; | 105 | QObject *object()const; |
106 | QCString slot()const; | 106 | QCString slot()const; |
107 | void setId( int id ); | 107 | void setId( int id ); |
108 | void setConfigKey( const QCString& ); | 108 | void setConfigKey( const QCString& ); |
109 | 109 | ||
110 | private: | 110 | private: |
111 | QString m_text; | 111 | QString m_text; |
112 | QCString m_config; | 112 | QCString m_config; |
113 | QPixmap m_pix; | 113 | QPixmap m_pix; |
114 | int m_id; | 114 | int m_id; |
115 | OKeyPair m_key; | 115 | OKeyPair m_key; |
116 | OKeyPair m_def; | 116 | OKeyPair m_def; |
117 | QObject *m_obj; | 117 | QObject *m_obj; |
118 | QCString m_str; | 118 | QCString m_str; |
119 | class Private; | 119 | class Private; |
120 | Private *d; | 120 | Private *d; |
121 | }; | 121 | }; |
122 | 122 | ||
123 | 123 | ||
124 | 124 | ||
125 | /** | 125 | /** |
126 | * \brief A manager to load and save Key Actions and get notified | 126 | * \brief A manager to load and save Key Actions and get notified |
127 | * This is the Manager for KeyActions. | 127 | * This is the Manager for KeyActions. |
128 | * You can say from which config and group to read data, to grab the | 128 | * You can say from which config and group to read data, to grab the |
129 | * keyboard to handle hardware keys, you can supply a blacklist of | 129 | * keyboard to handle hardware keys, you can supply a blacklist of |
130 | * keys which should not be used by allowed to be used. | 130 | * keys which should not be used by allowed to be used. |
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 | */ |
141 | class OKeyConfigManager : public QObject { | 141 | class OKeyConfigManager : public QObject { |
142 | Q_OBJECT | 142 | Q_OBJECT |
143 | typedef QMap<int, OKeyConfigItem::List> OKeyMapConfigPrivate; | 143 | typedef QMap<int, OKeyConfigItem::List> OKeyMapConfigPrivate; |
144 | public: | 144 | public: |
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 | ||
155 | OKeyConfigItem handleKeyEvent( QKeyEvent* ); | 155 | OKeyConfigItem handleKeyEvent( QKeyEvent* ); |
156 | int handleKeyEventId( QKeyEvent* ); | 156 | int handleKeyEventId( QKeyEvent* ); |
157 | 157 | ||
158 | void addKeyConfig( const OKeyConfigItem& ); | 158 | void addKeyConfig( const OKeyConfigItem& ); |
159 | void removeKeyConfig( const OKeyConfigItem& ); | 159 | void removeKeyConfig( const OKeyConfigItem& ); |
160 | void clearKeyConfig(); | 160 | void clearKeyConfig(); |
161 | 161 | ||
162 | void addToBlackList( const OKeyPair& ); | 162 | void addToBlackList( const OKeyPair& ); |
163 | void removeFromBlackList( const OKeyPair& ); | 163 | void removeFromBlackList( const OKeyPair& ); |
164 | void clearBlackList(); | 164 | void clearBlackList(); |
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 | }; | ||
172 | signals: | 218 | signals: |
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 | */ |
178 | void actionActivated( QWidget*, QKeyEvent*, const Opie::Core::OKeyConfigItem& ); | 224 | void actionActivated( QWidget*, QKeyEvent*, const Opie::Core::OKeyConfigItem& ); |
179 | 225 | ||
180 | /** | 226 | /** |
181 | * This Signal correspondents to the OKeyConfigItem slot | 227 | * This Signal correspondents to the OKeyConfigItem slot |
182 | * and object | 228 | * and object |
183 | * | 229 | * |
184 | * @see OKeyConfigItem::slot | 230 | * @see OKeyConfigItem::slot |
185 | * @see OKeyConfigItem::object | 231 | * @see OKeyConfigItem::object |
186 | */ | 232 | */ |
187 | void actionActivated( QWidget* par, QKeyEvent* key); | 233 | void actionActivated( QWidget* par, QKeyEvent* key); |
188 | 234 | ||
189 | private: | 235 | private: |
190 | OKeyConfigItem::List keyList( int ); | 236 | OKeyConfigItem::List keyList( int ); |
191 | OKeyConfigItem::List m_keys; | 237 | OKeyConfigItem::List m_keys; |
192 | QValueList<QWidget*> m_widgets; | 238 | QValueList<QWidget*> m_widgets; |
193 | Opie::Core::OConfig *m_conf; | 239 | Opie::Core::OConfig *m_conf; |
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 | ||
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 | ||
205 | #endif | 277 | #endif |