Commit bf20a24e authored by Dirk Wilden's avatar Dirk Wilden

added multiUse to keyInterface

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@2834 383ad7c9-94d9-4d36-a494-682f7c89f535
parent c2d87043
......@@ -64,8 +64,9 @@ class KeyInterface {
* @param _key the key that should be registered
* @param _modifiers the keyboard modifiers
* @param _description a short description about the functionality
* @param _multiUse can the key additionally be registered by another plugin
*/
virtual void registerKey(int _key, Qt::KeyboardModifiers _modifiers, QString _description) {};
virtual void registerKey(int _key, Qt::KeyboardModifiers _modifiers, QString _description, bool _multiUse = false) {};
public slots :
......
......@@ -12,6 +12,7 @@ struct KeyBinding{
int key;
Qt::KeyboardModifiers modifiers;
QString description;
bool multiUse;
};
/** Type defining a currently loaded Plugin */
......
......@@ -576,9 +576,9 @@ void Core::loadPlugin(QString filename, bool silent){
if ( keyPlugin && OpenFlipper::Options::gui() ) {
supported = supported + "KeyboardEvents ";
if ( checkSignal(plugin,"registerKey(int,Qt::KeyboardModifiers,QString)") )
connect(plugin,SIGNAL( registerKey(int, Qt::KeyboardModifiers, QString) ),
coreWidget_,SLOT(slotRegisterKey(int, Qt::KeyboardModifiers, QString)) );
if ( checkSignal(plugin,"registerKey(int,Qt::KeyboardModifiers,QString,bool)") )
connect(plugin,SIGNAL( registerKey(int, Qt::KeyboardModifiers, QString, bool) ),
coreWidget_,SLOT(slotRegisterKey(int, Qt::KeyboardModifiers, QString, bool)) );
// if ( checkSlot( plugin , "slotKeyEvent(QKeyEvent*)" ) )
// connect(coreWidget_,SIGNAL(PluginKeyEvent(QKeyEvent* )), plugin,SLOT(slotKeyEvent(QKeyEvent*)));
......
......@@ -403,9 +403,10 @@ CoreWidget::mapKeyPressEvent(QKeyEvent* _e){
if (keyPlugin){
// if ( checkSlot( plugins_[i].plugin , "slotKeyEvent(QKeyEvent*)" ) )
keyPlugin->slotKeyEvent(_e);
return;
}
//only inform further plugins if this is a multiUse key
if (!plugins_[i].keys[k].multiUse)
return;
}
}
......@@ -428,9 +429,10 @@ CoreWidget::mapKeyReleaseEvent(QKeyEvent* _e){
if (keyPlugin){
// if ( checkSlot( plugins_[i].plugin , "slotKeyReleaseEvent(QKeyEvent*)" ) )
keyPlugin->slotKeyReleaseEvent(_e);
return;
}
//only inform further plugins if this is a multiUse key
if (!plugins_[i].keys[k].multiUse)
return;
}
}
......@@ -438,13 +440,15 @@ CoreWidget::mapKeyReleaseEvent(QKeyEvent* _e){
/** Register a key to a plugin */
void
CoreWidget::slotRegisterKey(int _key, Qt::KeyboardModifiers _modifiers, QString _description){
CoreWidget::slotRegisterKey(int _key, Qt::KeyboardModifiers _modifiers, QString _description, bool _multiUse){
//first check if the key is already registered by the coreWidget
bool found = false;
bool multi = false;
for (uint i=0; i < coreKeys_.size(); i++)
if (coreKeys_[i].key == _key && coreKeys_[i].modifiers == _modifiers){
found = true;
multi = coreKeys_[i].multiUse;
break;
}
......@@ -453,8 +457,11 @@ CoreWidget::slotRegisterKey(int _key, Qt::KeyboardModifiers _modifiers, QString
for (uint i=0; i < plugins_.size(); i++)
for (int k=0; k < plugins_[i].keys.count(); k++)
if (plugins_[i].keys[k].key == _key
&& plugins_[i].keys[k].modifiers == _modifiers)
&& plugins_[i].keys[k].modifiers == _modifiers){
found = true;
multi = plugins_[i].keys[k].multiUse;
break;
}
if (found)
emit log(LOGERR, "Key already registered elsewhere.");
......@@ -465,6 +472,8 @@ CoreWidget::slotRegisterKey(int _key, Qt::KeyboardModifiers _modifiers, QString
kb.key = _key;
kb.modifiers = _modifiers;
kb.description = _description;
kb.multiUse = multi || _multiUse;
coreKeys_.push_back( kb );
return;
}
......@@ -485,6 +494,7 @@ CoreWidget::slotRegisterKey(int _key, Qt::KeyboardModifiers _modifiers, QString
kb.key = _key;
kb.modifiers = _modifiers;
kb.description = _description;
kb.multiUse = multi || _multiUse;
pluginInfo->keys.append( kb );
}
......
......@@ -163,7 +163,7 @@ public:
void PluginKeyReleaseEvent(QKeyEvent* );
/// internal signal to register CoreWidget keys
void registerKey(int _key, Qt::KeyboardModifiers _modifiers, QString _description);
void registerKey(int _key, Qt::KeyboardModifiers _modifiers, QString _description, bool _multiUse = false);
private:
void mapKeyPressEvent(QKeyEvent* _e);
......@@ -172,7 +172,7 @@ public:
std::vector<KeyBinding> coreKeys_;
private slots:
void slotRegisterKey(int _key, Qt::KeyboardModifiers _modifiers, QString _description);
void slotRegisterKey(int _key, Qt::KeyboardModifiers _modifiers, QString _description, bool _multiUse = false);
/** @} */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment