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(
"()" ) )
294 #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) 297 kb.modifiers = Qt::KeyboardModifier(0);
305 #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) 306 keys_.insert( std::make_pair( std::make_pair(-1, (QFlags<Qt::KeyboardModifier>)0) , std::make_pair ((QObject*)0,
int(
coreKeys_.size()-1) ) )) ;
307 invKeys_.insert( std::make_pair( std::make_pair ((QObject*)0,
int(
coreKeys_.size()-1) ) , std::make_pair(-1, (QFlags<Qt::KeyboardModifier>)0) ) );
309 keys_.insert( std::make_pair( std::make_pair(-1, Qt::KeyboardModifier(0)) , std::make_pair ((QObject*)
nullptr,
int(
coreKeys_.size()-1) ) )) ;
310 invKeys_.insert( std::make_pair( std::make_pair ((QObject*)0,
int(
coreKeys_.size()-1) ) , std::make_pair(-1, Qt::KeyboardModifier(0) ) ));
315 for (uint i=0; i <
plugins().size(); i++)
317 for (
int j=0; j <
plugins()[i].rpcFunctions.count(); j++){
320 if ( !
plugins()[i].rpcFunctions[j].contains(
"()" )
321 ||
plugins()[i].rpcFunctions[j] ==
"version()")
326 #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) 329 kb.modifiers = Qt::KeyboardModifier(0);
331 kb.description =
plugins()[i].rpcFunctions[j];
335 plugins()[i].keys.append( kb );
337 #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) 338 keys_.insert( std::make_pair( std::make_pair(-1, (QFlags<Qt::KeyboardModifier>)0) , std::make_pair(
plugins()[i].plugin,
plugins()[i].keys.size()-1) ) );
339 invKeys_.insert( std::make_pair( std::make_pair(
plugins()[i].plugin,
plugins()[i].keys.size()-1) , std::make_pair(-1, (QFlags<Qt::KeyboardModifier>)0) ) );
341 keys_.insert( std::make_pair( std::make_pair(-1, Qt::KeyboardModifier(0)) , std::make_pair(
plugins()[i].plugin,
plugins()[i].keys.size()-1) ) );
342 invKeys_.insert( std::make_pair( std::make_pair(
plugins()[i].plugin,
plugins()[i].keys.size()-1) , std::make_pair(-1, Qt::KeyboardModifier(0)) ) );
350 std::pair< int,Qt::KeyboardModifiers > keyCombi = std::make_pair(_key, _modifiers );
351 std::pair< int,Qt::KeyboardModifiers > oldCombi;
352 std::pair< QObject*, int > oldTarget;
354 bool replace =
false;
358 for (it=
keys_.begin(); it !=
keys_.end(); ++it){
360 int key = (*it).first.first;
361 Qt::KeyboardModifiers modifiers = (*it).first.second;
362 QObject* plugin = (*it).second.first;
363 int bindingID = (*it).second.second;
367 if (plugin == _plugin && bindingID == _keyBindingID){
369 oldCombi = (*it).first;
370 oldTarget = (*it).second;
375 if (_key == key && _modifiers == modifiers ){
377 if (!binding.multiUse){
379 emit
log(
LOGERR, tr(
"Could not add key mapping. Key already assigned to the core."));
384 emit
log(
LOGERR, tr(
"Could not add key mapping. Key already assigned to %1").arg( basePlugin->
name() ) );
386 emit
log(
LOGERR, tr(
"Could not add key mapping. Key already assigned to an unknown plugin."));
396 if (!keyBinding.multiUse)
397 if ( (replace &&
keys_.count(keyCombi) > 1) || (!replace &&
keys_.count(keyCombi) > 0) ){
398 emit
log(
LOGERR, tr(
"Could not add (single usage) key mapping. Key already assigned."));
403 keys_.erase(oldCombi);
408 keys_.insert ( std::make_pair( keyCombi , std::make_pair(_plugin, _keyBindingID) ));
409 invKeys_.insert( std::make_pair( std::make_pair(_plugin, _keyBindingID), keyCombi ));
417 QVector< int > modifiers;
418 QStringList pluginNames;
419 QVector< int > bindingIDs;
426 if (_ini.
get_entry(keyCount,
"KeyBindings",
"KeyCount") ){
433 for (
int i=0; i < keyCount; i++){
435 if (!_ini.
get_entry(key,
"KeyBindings",
"Key" + QString::number(i) ) )
continue;
436 if (!_ini.
get_entry(mod,
"KeyBindings",
"KeyModifiers" + QString::number(i) ) )
continue;
437 if (!_ini.
get_entry(name,
"KeyBindings",
"KeyTarget" + QString::number(i) ) )
continue;
438 if (!_ini.
get_entry(binding,
"KeyBindings",
"KeyBinding" + QString::number(i) ) )
continue;
440 keys.push_back( key );
441 modifiers.push_back( mod );
442 pluginNames.push_back( name );
443 bindingIDs.push_back( binding );
448 for (
int i=0; i < keys.count(); i++){
453 if (pluginNames[i] !=
"Core" ){
455 for (uint i=0; i <
plugins().size(); i++)
456 if (
plugins()[i].rpcName == pluginNames[i] ){
465 slotAddKeyMapping( keys[i], (Qt::KeyboardModifiers) modifiers[i], plugin, bindingIDs[i] );
474 QVector< int > modifiers;
475 QStringList pluginNames;
476 QVector< int > bindingIDs;
480 for (it=
keys_.begin(); it !=
keys_.end(); ++it){
482 int key = (*it).first.first;
483 Qt::KeyboardModifiers mod = (*it).first.second;
484 QObject* plugin = (*it).second.first;
485 int bindingID = (*it).second.second;
489 if (key != binding.key || mod != binding.modifiers){
500 keys.push_back( key );
501 modifiers.push_back( mod );
502 pluginNames.push_back( name );
503 bindingIDs.push_back( bindingID );
508 _ini.
add_entry(
"KeyBindings",
"KeyCount", keys.count());
510 for (
int i=0; i < keys.count(); i++){
512 _ini.
add_entry(
"KeyBindings",
"Key" + QString::number(i) , keys[i] );
513 _ini.
add_entry(
"KeyBindings",
"KeyModifiers" + QString::number(i), modifiers[i] );
514 _ini.
add_entry(
"KeyBindings",
"KeyTarget" + QString::number(i) , pluginNames[i] );
515 _ini.
add_entry(
"KeyBindings",
"KeyBinding" + QString::number(i) , bindingIDs[i] );
523 connect(
this , SIGNAL(
registerKey(
int, Qt::KeyboardModifiers, QString,
bool) ),
524 this , SLOT(
slotRegisterKey(
int, Qt::KeyboardModifiers, QString,
bool)) );
526 emit
registerKey(Qt::Key_Print , Qt::NoModifier,
"Create Snapshot");
527 emit
registerKey(Qt::Key_Escape , Qt::NoModifier,
"Switch to last action mode ( Move,Picking,Light or Info Mode)");
528 emit
registerKey(Qt::Key_Space , Qt::NoModifier,
"Toggle between multiview and single view");
530 emit
registerKey(Qt::Key_S , Qt::ControlModifier,
"Save Object");
531 emit
registerKey(Qt::Key_O , Qt::ControlModifier,
"Open Object");
532 emit
registerKey(Qt::Key_L , Qt::ControlModifier,
"Show/Hide Logger");
533 emit
registerKey(Qt::Key_T , Qt::ControlModifier,
"Show/Hide Toolbox");
534 emit
registerKey(Qt::Key_F , Qt::ControlModifier,
"Toggle Fullscreen");
535 emit
registerKey(Qt::Key_B , Qt::ControlModifier,
"Show/Hide StatusBar");
536 emit
registerKey(Qt::Key_N , Qt::ControlModifier,
"Show/Hide ToolBar");
537 emit
registerKey(Qt::Key_M , Qt::ControlModifier,
"Show/Hide MenuBar");
540 if ( OpenFlipper::Options::isLinux() ) {
541 emit
registerKey(Qt::Key_Meta , Qt::MetaModifier,
"Use Navigation mode while key is pressed");
542 emit
registerKey(Qt::Key_Meta , Qt::NoModifier,
"Use Navigation mode while key is pressed");
543 emit
registerKey(Qt::Key_Super_L , Qt::NoModifier,
"Use Navigation mode while key is pressed");
544 emit
registerKey(Qt::Key_Super_L , Qt::MetaModifier,
"Use Navigation mode while key is pressed");
545 emit
registerKey(Qt::Key_Super_R , Qt::NoModifier,
"Use Navigation mode while key is pressed");
546 emit
registerKey(Qt::Key_Super_R , Qt::MetaModifier,
"Use Navigation mode while key is pressed");
548 emit
registerKey(Qt::Key_Alt , Qt::AltModifier,
"Use Navigation mode while key is pressed");
549 emit
registerKey(Qt::Key_Alt , Qt::NoModifier,
"Use Navigation mode while key is pressed");
552 emit
registerKey(Qt::Key_Shift , Qt::ShiftModifier,
"Apply context menu action to all Viewers",
true);
553 emit
registerKey(Qt::Key_Shift , Qt::NoModifier,
"Apply context menu action to all Viewers",
true);
556 emit
registerKey(Qt::Key_A , Qt::NoModifier,
"First Person view strafe left");
557 emit
registerKey(Qt::Key_D , Qt::NoModifier,
"First Person view strafe right");
558 emit
registerKey(Qt::Key_W , Qt::NoModifier,
"First Person view move forward");
559 emit
registerKey(Qt::Key_S , Qt::NoModifier,
"First Person view move back");
566 if ( (( _e->key() == Qt::Key_Meta ) || (_e->key() == Qt::Key_Super_L) || (_e->key() == Qt::Key_Super_R))
567 && OpenFlipper::Options::isLinux() ) {
579 if ( ( _e->key() == Qt::Key_Alt ) && ! OpenFlipper::Options::isLinux() ) {
592 if (_e->modifiers() & Qt::ControlModifier ) {
637 std::cerr <<
"Todo : On Print Screen, create a snapshot for all viewers" << std::endl;
673 if ( (( _e->key() == Qt::Key_Meta ) || (_e->key() == Qt::Key_Super_L) || (_e->key() == Qt::Key_Super_R))
674 && OpenFlipper::Options::isLinux() ) {
680 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.