54 for (uint i=0; i <
plugins().size(); i++){
55 if (
plugins()[i].plugin == _plugin)
56 return plugins()[i].keys[_keyIndex];
59 emit
log(
LOGERR,tr(
"ERROR: could not get KeyBinding"));
67 for (uint i=0; i <
plugins().size(); i++){
68 if (
plugins()[i].plugin == _plugin)
72 emit
log(
LOGERR,tr(
"ERROR: could not get rpcname"));
79 std::pair< int,Qt::KeyboardModifiers > key = std::make_pair(_e->key(), _e->modifiers() );
85 for (it=range.first; it != range.second; ++it){
87 QObject* plugin = (*it).second.first;
96 emit
call(
"core." + binding.description, ok);
104 QKeyEvent mappedEvent (_e->type(),binding.key, binding.modifiers,
105 _e->text(), _e->isAutoRepeat(), _e->count() );
110 if (binding.multiUse)
134 QKeyEvent mappedEvent(_e->type(),binding.key, binding.modifiers,
135 _e->text(), _e->isAutoRepeat(), _e->count() );
141 if (!binding.multiUse)
151 if (_e->isAutoRepeat())
return;
153 std::pair< int,Qt::KeyboardModifiers > key = std::make_pair(_e->key(), _e->modifiers() );
159 for (it=range.first; it != range.second; ++it){
161 QObject* plugin = (*it).second.first;
170 QKeyEvent mappedEvent (_e->type(),binding.key, binding.modifiers,
171 _e->text(), _e->isAutoRepeat(), _e->count() );
175 if (binding.multiUse)
191 QKeyEvent mappedEvent (_e->type(),binding.key, binding.modifiers,
192 _e->text(), _e->isAutoRepeat(), _e->count() );
198 if (!binding.multiUse)
212 for (uint i=0; i <
coreKeys_.size(); i++)
222 for (uint i=0; i <
plugins().size(); i++)
223 for (
int k=0; k <
plugins()[i].keys.count(); k++)
224 if (
plugins()[i].keys[k].key == _key
225 &&
plugins()[i].keys[k].modifiers == _modifiers){
227 multi =
plugins()[i].keys[k].multiUse;
233 emit
log(
LOGERR, tr(
"Key already registered by '%1'").arg( name ) );
236 if (sender() ==
this){
239 kb.modifiers = _modifiers;
240 kb.description = _description;
241 kb.multiUse = multi || _multiUse;
244 if (multi && !_multiUse)
245 emit
log(
LOGERR, tr(
"Key already registered by '%1'. Forced registration as multiUse key.").arg( name ));
249 keys_.insert( std::make_pair( std::make_pair(_key, _modifiers) , std::make_pair ((QObject*)0,
int(
coreKeys_.size()-1 ) ) )) ;
250 invKeys_.insert( std::make_pair( std::make_pair ((QObject*)0,
int(
coreKeys_.size()-1) ) , std::make_pair(_key, _modifiers) ) );
257 for (uint i=0; i <
plugins().size(); i++)
258 if (
plugins()[i].plugin == sender())
261 if (pluginInfo == 0){
262 emit
log(
LOGERR, tr(
"Unable to register key. Plugin not found!"));
268 kb.modifiers = _modifiers;
269 kb.description = _description;
270 kb.multiUse = multi || _multiUse;
273 if (multi && !_multiUse)
274 emit
log(
LOGERR, tr(
"Key already registered by '%1'. Forced registration as multiUse key.").arg( name ));
276 pluginInfo->
keys.append( kb );
278 keys_.insert( std::make_pair( std::make_pair(_key, _modifiers) , std::make_pair(pluginInfo->
plugin, pluginInfo->
keys.size()-1) ) );
279 invKeys_.insert( std::make_pair( std::make_pair(pluginInfo->
plugin, pluginInfo->
keys.size()-1) , std::make_pair(_key, _modifiers) ) );
289 if ( !
coreSlots_.at(i).slotName.contains(
"()" ) )
301 keys_.insert( std::make_pair( std::make_pair(-1, (QFlags<Qt::KeyboardModifier>)0) , std::make_pair ((QObject*)0,
int(
coreKeys_.size()-1) ) )) ;
302 invKeys_.insert( std::make_pair( std::make_pair ((QObject*)0,
int(
coreKeys_.size()-1) ) , std::make_pair(-1, (QFlags<Qt::KeyboardModifier>)0) ) );
306 for (uint i=0; i <
plugins().size(); i++)
308 for (
int j=0; j <
plugins()[i].rpcFunctions.count(); j++){
311 if ( !
plugins()[i].rpcFunctions[j].contains(
"()" )
312 ||
plugins()[i].rpcFunctions[j] ==
"version()")
318 kb.description =
plugins()[i].rpcFunctions[j];
322 plugins()[i].keys.append( kb );
324 keys_.insert( std::make_pair( std::make_pair(-1, (QFlags<Qt::KeyboardModifier>)0) , std::make_pair(
plugins()[i].plugin,
plugins()[i].keys.size()-1) ) );
325 invKeys_.insert( std::make_pair( std::make_pair(
plugins()[i].plugin,
plugins()[i].keys.size()-1) , std::make_pair(-1, (QFlags<Qt::KeyboardModifier>)0) ) );
332 std::pair< int,Qt::KeyboardModifiers > keyCombi = std::make_pair(_key, _modifiers );
333 std::pair< int,Qt::KeyboardModifiers > oldCombi;
334 std::pair< QObject*, int > oldTarget;
336 bool replace =
false;
340 for (it=
keys_.begin(); it !=
keys_.end(); ++it){
342 int key = (*it).first.first;
343 Qt::KeyboardModifiers modifiers = (*it).first.second;
344 QObject* plugin = (*it).second.first;
345 int bindingID = (*it).second.second;
349 if (plugin == _plugin && bindingID == _keyBindingID){
351 oldCombi = (*it).first;
352 oldTarget = (*it).second;
357 if (_key == key && _modifiers == modifiers ){
359 if (!binding.multiUse){
361 emit
log(
LOGERR, tr(
"Could not add key mapping. Key already assigned to the core."));
366 emit
log(
LOGERR, tr(
"Could not add key mapping. Key already assigned to %1").arg( basePlugin->
name() ) );
368 emit
log(
LOGERR, tr(
"Could not add key mapping. Key already assigned to an unknown plugin."));
378 if (!keyBinding.multiUse)
379 if ( (replace &&
keys_.count(keyCombi) > 1) || (!replace &&
keys_.count(keyCombi) > 0) ){
380 emit
log(
LOGERR, tr(
"Could not add (single usage) key mapping. Key already assigned."));
385 keys_.erase(oldCombi);
390 keys_.insert ( std::make_pair( keyCombi , std::make_pair(_plugin, _keyBindingID) ));
391 invKeys_.insert( std::make_pair( std::make_pair(_plugin, _keyBindingID), keyCombi ));
399 QVector< int > modifiers;
400 QStringList pluginNames;
401 QVector< int > bindingIDs;
408 if (_ini.
get_entry(keyCount,
"KeyBindings",
"KeyCount") ){
415 for (
int i=0; i < keyCount; i++){
417 if (!_ini.
get_entry(key,
"KeyBindings",
"Key" + QString::number(i) ) )
continue;
418 if (!_ini.
get_entry(mod,
"KeyBindings",
"KeyModifiers" + QString::number(i) ) )
continue;
419 if (!_ini.
get_entry(name,
"KeyBindings",
"KeyTarget" + QString::number(i) ) )
continue;
420 if (!_ini.
get_entry(binding,
"KeyBindings",
"KeyBinding" + QString::number(i) ) )
continue;
422 keys.push_back( key );
423 modifiers.push_back( mod );
424 pluginNames.push_back( name );
425 bindingIDs.push_back( binding );
430 for (
int i=0; i < keys.count(); i++){
435 if (pluginNames[i] !=
"Core" ){
437 for (uint i=0; i <
plugins().size(); i++)
438 if (
plugins()[i].rpcName == pluginNames[i] ){
447 slotAddKeyMapping( keys[i], (Qt::KeyboardModifiers) modifiers[i], plugin, bindingIDs[i] );
456 QVector< int > modifiers;
457 QStringList pluginNames;
458 QVector< int > bindingIDs;
462 for (it=
keys_.begin(); it !=
keys_.end(); ++it){
464 int key = (*it).first.first;
465 Qt::KeyboardModifiers mod = (*it).first.second;
466 QObject* plugin = (*it).second.first;
467 int bindingID = (*it).second.second;
471 if (key != binding.key || mod != binding.modifiers){
482 keys.push_back( key );
483 modifiers.push_back( mod );
484 pluginNames.push_back( name );
485 bindingIDs.push_back( bindingID );
490 _ini.
add_entry(
"KeyBindings",
"KeyCount", keys.count());
492 for (
int i=0; i < keys.count(); i++){
494 _ini.
add_entry(
"KeyBindings",
"Key" + QString::number(i) , keys[i] );
495 _ini.
add_entry(
"KeyBindings",
"KeyModifiers" + QString::number(i), modifiers[i] );
496 _ini.
add_entry(
"KeyBindings",
"KeyTarget" + QString::number(i) , pluginNames[i] );
497 _ini.
add_entry(
"KeyBindings",
"KeyBinding" + QString::number(i) , bindingIDs[i] );
505 connect(
this , SIGNAL(
registerKey(
int, Qt::KeyboardModifiers, QString,
bool) ),
506 this , SLOT(
slotRegisterKey(
int, Qt::KeyboardModifiers, QString,
bool)) );
508 emit
registerKey(Qt::Key_Print , Qt::NoModifier,
"Create Snapshot");
509 emit
registerKey(Qt::Key_Escape , Qt::NoModifier,
"Switch to last action mode ( Move,Picking,Light or Info Mode)");
510 emit
registerKey(Qt::Key_Space , Qt::NoModifier,
"Toggle between multiview and single view");
512 emit
registerKey(Qt::Key_S , Qt::ControlModifier,
"Save Object");
513 emit
registerKey(Qt::Key_O , Qt::ControlModifier,
"Open Object");
514 emit
registerKey(Qt::Key_L , Qt::ControlModifier,
"Show/Hide Logger");
515 emit
registerKey(Qt::Key_T , Qt::ControlModifier,
"Show/Hide Toolbox");
516 emit
registerKey(Qt::Key_F , Qt::ControlModifier,
"Toggle Fullscreen");
517 emit
registerKey(Qt::Key_B , Qt::ControlModifier,
"Show/Hide StatusBar");
518 emit
registerKey(Qt::Key_N , Qt::ControlModifier,
"Show/Hide ToolBar");
519 emit
registerKey(Qt::Key_M , Qt::ControlModifier,
"Show/Hide MenuBar");
522 if ( OpenFlipper::Options::isLinux() ) {
523 emit
registerKey(Qt::Key_Meta , Qt::MetaModifier,
"Use Navigation mode while key is pressed");
524 emit
registerKey(Qt::Key_Meta , Qt::NoModifier,
"Use Navigation mode while key is pressed");
525 emit
registerKey(Qt::Key_Super_L , Qt::NoModifier,
"Use Navigation mode while key is pressed");
526 emit
registerKey(Qt::Key_Super_L , Qt::MetaModifier,
"Use Navigation mode while key is pressed");
527 emit
registerKey(Qt::Key_Super_R , Qt::NoModifier,
"Use Navigation mode while key is pressed");
528 emit
registerKey(Qt::Key_Super_R , Qt::MetaModifier,
"Use Navigation mode while key is pressed");
530 emit
registerKey(Qt::Key_Alt , Qt::AltModifier,
"Use Navigation mode while key is pressed");
531 emit
registerKey(Qt::Key_Alt , Qt::NoModifier,
"Use Navigation mode while key is pressed");
534 emit
registerKey(Qt::Key_Shift , Qt::ShiftModifier,
"Apply context menu action to all Viewers",
true);
535 emit
registerKey(Qt::Key_Shift , Qt::NoModifier,
"Apply context menu action to all Viewers",
true);
538 emit
registerKey(Qt::Key_A , Qt::NoModifier,
"First Person view strafe left");
539 emit
registerKey(Qt::Key_D , Qt::NoModifier,
"First Person view strafe right");
540 emit
registerKey(Qt::Key_W , Qt::NoModifier,
"First Person view move forward");
541 emit
registerKey(Qt::Key_S , Qt::NoModifier,
"First Person view move back");
548 if ( (( _e->key() == Qt::Key_Meta ) || (_e->key() == Qt::Key_Super_L) || (_e->key() == Qt::Key_Super_R))
549 && OpenFlipper::Options::isLinux() ) {
561 if ( ( _e->key() == Qt::Key_Alt ) && ! OpenFlipper::Options::isLinux() ) {
574 if (_e->modifiers() & Qt::ControlModifier ) {
619 std::cerr <<
"Todo : On Print Screen, create a snapshot for all viewers" << std::endl;
655 if ( (( _e->key() == Qt::Key_Meta ) || (_e->key() == Qt::Key_Super_L) || (_e->key() == Qt::Key_Super_R))
656 && OpenFlipper::Options::isLinux() ) {
662 if ( ( _e->key() == Qt::Key_Alt ) && !OpenFlipper::Options::isLinux() ) {
virtual void slotKeyReleaseEvent(QKeyEvent *_event)
Key Release Event from Main App.
void add_entry(const QString &_section, const QString &_key, const QString &_value)
Addition / modification of a string entry.
bool get_entry(QString &_val, const QString &_section, const QString &_key) const
Access to a string entry.
void log(Logtype _type, QString _message)
Logg with OUT,WARN or ERR as type.
virtual QString name()=0
Return a name for the plugin.
QList< KeyBinding > keys
List of registered keys with description.
Keyboard Event Interface.
Class for the handling of simple configuration files.
virtual void slotKeyEvent(QKeyEvent *_event)
Key Event from Main App.
QObject * plugin
Pointer to the loaded plugin (Already casted when loading it)
bool section_exists(const QString &_section) const
Check if given section exists in the current INI file.
Interface class from which all plugins have to be created.