Developer Documentation
Loading...
Searching...
No Matches
keyHandling.cc
1/*===========================================================================*\
2* *
3* OpenFlipper *
4 * Copyright (c) 2001-2015, RWTH-Aachen University *
5 * Department of Computer Graphics and Multimedia *
6 * All rights reserved. *
7 * www.openflipper.org *
8 * *
9 *---------------------------------------------------------------------------*
10 * This file is part of OpenFlipper. *
11 *---------------------------------------------------------------------------*
12 * *
13 * Redistribution and use in source and binary forms, with or without *
14 * modification, are permitted provided that the following conditions *
15 * are met: *
16 * *
17 * 1. Redistributions of source code must retain the above copyright notice, *
18 * this list of conditions and the following disclaimer. *
19 * *
20 * 2. Redistributions in binary form must reproduce the above copyright *
21 * notice, this list of conditions and the following disclaimer in the *
22 * documentation and/or other materials provided with the distribution. *
23 * *
24 * 3. Neither the name of the copyright holder nor the names of its *
25 * contributors may be used to endorse or promote products derived from *
26 * this software without specific prior written permission. *
27 * *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39* *
40\*===========================================================================*/
41
42
43
44#include "CoreWidget.hh"
45
47
48//-----------------------------------------------------------------------------
49
50KeyBinding CoreWidget::getKeyBinding(QObject* _plugin, int _keyIndex ){
51 if (_plugin == 0)
52 return coreKeys_[_keyIndex];
53
54 for (uint i=0; i < plugins().size(); i++){
55 if (plugins()[i].plugin == _plugin)
56 return plugins()[i].keys[_keyIndex];
57 }
58
59 emit log(LOGERR,tr("ERROR: could not get KeyBinding"));
60 return KeyBinding();
61}
62
63QString CoreWidget::getRPCName(QObject* _plugin ){
64 if (_plugin == 0)
65 return "";
66
67 for (uint i=0; i < plugins().size(); i++){
68 if (plugins()[i].plugin == _plugin)
69 return plugins()[i].rpcName;
70 }
71
72 emit log(LOGERR,tr("ERROR: could not get rpcname"));
73 return "";
74}
75
77void CoreWidget::keyPressEvent(QKeyEvent* _e)
78{
79 std::pair< int,Qt::KeyboardModifiers > key = std::make_pair(_e->key(), _e->modifiers() );
80
81 //iterate over all assigned keys
82 KeyRange range = keys_.equal_range(key);
83
84 KeyMap::iterator it;
85 for (it=range.first; it != range.second; ++it){
86
87 QObject* plugin = (*it).second.first;
88 KeyBinding binding = getKeyBinding( plugin, (*it).second.second );
89
90 //check if its a core Key
91 if (plugin == 0){
92
93 //the key belongs to a slot
94 if (binding.slot){
95 bool ok;
96 emit call("core." + binding.description, ok);
97 return;
98 }
99
100 // =================================================================================
101 // Map event to the cores key and modifier.
102 // Call the core key handler with the mapped event.
103 // =================================================================================
104 QKeyEvent mappedEvent (_e->type(),binding.key, binding.modifiers,
105 _e->text(), _e->isAutoRepeat(), _e->count() );
106
107 coreKeyPressEvent(&mappedEvent);
108
109 //if the key is multiUse also check other assigned keys
110 if (binding.multiUse)
111 continue;
112 else
113 return;
114 }
115
116 //it's a plugin key
117
118 //the key belongs to a slot
119 if (binding.slot){
120 bool ok;
121 emit call(getRPCName(plugin) +"."+ binding.description, ok);
122 return;
123 }
124
125 //the key was specified through keyInterface
126 KeyInterface* keyPlugin = qobject_cast< KeyInterface * >(plugin);
127
128 if (keyPlugin){
129
130 // =================================================================================
131 // Map event to the plugins key and modifier.
132 // Call it with the mapped event.
133 // =================================================================================
134 QKeyEvent mappedEvent(_e->type(),binding.key, binding.modifiers,
135 _e->text(), _e->isAutoRepeat(), _e->count() );
136
137 keyPlugin->slotKeyEvent(&mappedEvent);
138 }
139
140 //if its not a multiUse key we are ready
141 if (!binding.multiUse)
142 return;
143 }
144}
145
146//-----------------------------------------------------------------------------
147
149void CoreWidget::keyReleaseEvent(QKeyEvent* _e) {
150
151 if (_e->isAutoRepeat()) return; //consider only "real" release events
152
153 std::pair< int,Qt::KeyboardModifiers > key = std::make_pair(_e->key(), _e->modifiers() );
154
155 //iterate over all assigned keys
156 KeyRange range = keys_.equal_range(key);
157
158 KeyMap::iterator it;
159 for (it=range.first; it != range.second; ++it){
160
161 QObject* plugin = (*it).second.first;
162 KeyBinding binding = getKeyBinding( plugin, (*it).second.second );
163
164 if (plugin == 0){
165
166 // =================================================================================
167 // Map event to the cores key and modifier.
168 // Call the core key handler with the mapped event.
169 // =================================================================================
170 QKeyEvent mappedEvent (_e->type(),binding.key, binding.modifiers,
171 _e->text(), _e->isAutoRepeat(), _e->count() );
172 coreKeyReleaseEvent(&mappedEvent);
173
174 //if the key is multiUse also check other assigned keys
175 if (binding.multiUse)
176 continue;
177 else
178 return;
179 }
180
181 //it's a plugin key
182 KeyInterface* keyPlugin = qobject_cast< KeyInterface * >(plugin);
183
184 if (keyPlugin){
185
186 // =================================================================================
187 // Map event to the plugins key and modifier.
188 // Call the plugin with the mapped event.
189 // =================================================================================
190
191 QKeyEvent mappedEvent (_e->type(),binding.key, binding.modifiers,
192 _e->text(), _e->isAutoRepeat(), _e->count() );
193
194 keyPlugin->slotKeyReleaseEvent(&mappedEvent);
195 }
196
197 //if its not a multiUse key we are ready
198 if (!binding.multiUse)
199 return;
200 }
201}
202
203//-----------------------------------------------------------------------------
204
206void CoreWidget::slotRegisterKey(int _key, Qt::KeyboardModifiers _modifiers, const QString& _description, bool _multiUse){
207
208 //first check if the key is already registered by the coreWidget
209 bool found = false;
210 bool multi = false;
211 QString name;
212 for (uint i=0; i < coreKeys_.size(); i++)
213 if (coreKeys_[i].key == _key && coreKeys_[i].modifiers == _modifiers){
214 found = true;
215 multi = coreKeys_[i].multiUse;
216 name = "Core";
217 break;
218 }
219
220 //then check if the key is already registered by a different plugin
221 if (!found)
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){
226 found = true;
227 multi = plugins()[i].keys[k].multiUse;
228 name = plugins()[i].name;
229 break;
230 }
231
232 if (found && !multi)
233 emit log(LOGERR, tr("Key already registered by '%1'").arg( name ) );
234
235 //check if its a key for the core
236 if (sender() == this){
237 KeyBinding kb;
238 kb.key = _key;
239 kb.modifiers = _modifiers;
240 kb.description = _description;
241 kb.multiUse = multi || _multiUse;
242 kb.slot = false;
243
244 if (multi && !_multiUse)
245 emit log(LOGERR, tr("Key already registered by '%1'. Forced registration as multiUse key.").arg( name ));
246
247 coreKeys_.push_back( kb );
248
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) ) );
251 return;
252 }
253
254 //find plugin
255 PluginInfo* pluginInfo = 0;
256
257 for (uint i=0; i < plugins().size(); i++)
258 if (plugins()[i].plugin == sender())
259 pluginInfo = &plugins()[i];
260
261 if (pluginInfo == 0){
262 emit log(LOGERR, tr("Unable to register key. Plugin not found!"));
263 return;
264 }
265
266 KeyBinding kb;
267 kb.key = _key;
268 kb.modifiers = _modifiers;
269 kb.description = _description;
270 kb.multiUse = multi || _multiUse;
271 kb.slot = false;
272
273 if (multi && !_multiUse)
274 emit log(LOGERR, tr("Key already registered by '%1'. Forced registration as multiUse key.").arg( name ));
275
276 pluginInfo->keys.append( kb );
277
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) ) );
280}
281
284
285 //check the core slots
286 for (int i=0; i < coreSlots_.count(); i++){
287
288 //only consider functions without arguments
289 if ( !coreSlots_.at(i).slotName.contains( "()" ) )
290 continue;
291
292 KeyBinding kb;
293 kb.key = -1;
294 #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
295 kb.modifiers = 0;
296 #else
297 kb.modifiers = Qt::KeyboardModifier(0);
298 #endif
299 kb.description = coreSlots_.at(i).slotName;
300 kb.multiUse = true;
301 kb.slot = true;
302
303 coreKeys_.push_back( kb );
304
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) ) );
308 #else
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) ) ));
311 #endif
312 }
313
314 //check all plugins
315 for (uint i=0; i < plugins().size(); i++)
316
317 for (int j=0; j < plugins()[i].rpcFunctions.count(); j++){
318
319 //only consider functions without arguments
320 if ( !plugins()[i].rpcFunctions[j].contains( "()" )
321 || plugins()[i].rpcFunctions[j] == "version()")
322 continue;
323
324 KeyBinding kb;
325 kb.key = -1;
326 #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
327 kb.modifiers = 0;
328 #else
329 kb.modifiers = Qt::KeyboardModifier(0);
330 #endif
331 kb.description = plugins()[i].rpcFunctions[j];
332 kb.multiUse = true;
333 kb.slot = true;
334
335 plugins()[i].keys.append( kb );
336
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) ) );
340 #else
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)) ) );
343 #endif
344 }
345}
346
348void CoreWidget::slotAddKeyMapping(int _key, Qt::KeyboardModifiers _modifiers, QObject* _plugin, int _keyBindingID){
349
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;
353
354 bool replace = false;
355
356 //and check if the key is already assigned without multiUse
357 KeyMap::iterator it;
358 for (it=keys_.begin(); it != keys_.end(); ++it){
359
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;
364 KeyBinding binding = getKeyBinding(plugin, bindingID);
365
366 //check if its the keyBinding we want to map/replace
367 if (plugin == _plugin && bindingID == _keyBindingID){
368 replace = true;
369 oldCombi = (*it).first;
370 oldTarget = (*it).second;
371 continue;
372 }
373
374 //check if the mapping is conflicting with other mappings
375 if (_key == key && _modifiers == modifiers ){
376
377 if (!binding.multiUse){
378 if (plugin == 0)
379 emit log(LOGERR, tr("Could not add key mapping. Key already assigned to the core."));
380 else{
381 BaseInterface* basePlugin = qobject_cast< BaseInterface * >(plugin);
382
383 if (basePlugin)
384 emit log(LOGERR, tr("Could not add key mapping. Key already assigned to %1").arg( basePlugin->name() ) );
385 else
386 emit log(LOGERR, tr("Could not add key mapping. Key already assigned to an unknown plugin."));
387 }
388 return;
389 }
390 }
391 }
392
393 KeyBinding keyBinding = getKeyBinding(_plugin, _keyBindingID);
394
395 //check if new binding doesn't allow multiUse but other assignments for the key exist
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."));
399 return;
400 }
401
402 if (replace){
403 keys_.erase(oldCombi);
404 invKeys_.erase(oldTarget);
405 }
406
407 //now we can add the mapping
408 keys_.insert ( std::make_pair( keyCombi , std::make_pair(_plugin, _keyBindingID) ));
409 invKeys_.insert( std::make_pair( std::make_pair(_plugin, _keyBindingID), keyCombi ));
410
411}
412
415
416 QVector< int > keys;
417 QVector< int > modifiers;
418 QStringList pluginNames;
419 QVector< int > bindingIDs;
420
421 //first load everything from INI file
422 if ( !_ini.section_exists("KeyBindings") )
423 return;
424
425 int keyCount;
426 if (_ini.get_entry(keyCount,"KeyBindings","KeyCount") ){
427
428 int key;
429 int mod;
430 QString name;
431 int binding;
432
433 for (int i=0; i < keyCount; i++){
434
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;
439
440 keys.push_back( key );
441 modifiers.push_back( mod );
442 pluginNames.push_back( name );
443 bindingIDs.push_back( binding );
444 }
445 }
446
447 //add the keyMapping
448 for (int i=0; i < keys.count(); i++){
449
450 //first we need the plugin
451 QObject* plugin = 0;
452
453 if (pluginNames[i] != "Core" ){
454 //search for the plugin
455 for (uint j = 0; j < plugins().size(); j++)
456 if (plugins()[j].rpcName == pluginNames[i]) {
457 plugin = plugins()[j].plugin;
458 break;
459 }
460
461 if (plugin == 0)
462 continue; //because plugin was not found
463 }
464
465 slotAddKeyMapping( keys[i], (Qt::KeyboardModifiers) modifiers[i], plugin, bindingIDs[i] );
466 }
467
468}
469
472
473 QVector< int > keys;
474 QVector< int > modifiers;
475 QStringList pluginNames;
476 QVector< int > bindingIDs;
477
478 //first get all keys with custom assignments
479 KeyMap::iterator it;
480 for (it=keys_.begin(); it != keys_.end(); ++it){
481
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;
486 KeyBinding binding = getKeyBinding(plugin, bindingID);
487
488 //check if current key assignment and original assignment differ
489 if (key != binding.key || mod != binding.modifiers){
490
491 //get the pluginName
492 QString name;
493
494 if (plugin == 0)
495 name = "Core";
496 else
497 name = getRPCName(plugin);
498
499 //store key assignment
500 keys.push_back( key );
501 modifiers.push_back( mod );
502 pluginNames.push_back( name );
503 bindingIDs.push_back( bindingID );
504 }
505 }
506
507 //finally store everything to INI file
508 _ini.add_entry("KeyBindings","KeyCount", (int)keys.count());
509
510 for (int i=0; i < keys.count(); i++){
511
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] );
516 }
517}
518
521
522 //register keys for coreWidget
523 connect(this , SIGNAL( registerKey(int, Qt::KeyboardModifiers, QString, bool) ),
524 this , SLOT(slotRegisterKey(int, Qt::KeyboardModifiers, QString, bool)) );
525
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");
529
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");
538
539
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");
547 } else {
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");
550 }
551
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);
554
555
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");
560
561}
562
564void CoreWidget::coreKeyPressEvent (QKeyEvent* _e){
565 //emit log(LOGERR,"Key Press");
566 if ( (( _e->key() == Qt::Key_Meta ) || (_e->key() == Qt::Key_Super_L) || (_e->key() == Qt::Key_Super_R))
567 && OpenFlipper::Options::isLinux() ) {
568
569 if ( lastActionMode() == actionMode()) {
570 if (actionMode() == Viewer::PickingMode)
571 setActionMode( Viewer::ExamineMode );
572 else
573 setActionMode( Viewer::PickingMode );
574 }
575 else
577 }
578
579 if ( ( _e->key() == Qt::Key_Alt ) && ! OpenFlipper::Options::isLinux() ) {
580 //emit log(LOGERR,"Switch to examine mode");
581 if ( lastActionMode() == actionMode()) {
582 if (actionMode() == Viewer::PickingMode)
583 setActionMode( Viewer::ExamineMode );
584 else
585 setActionMode( Viewer::PickingMode );
586 }
587 else
589 }
590
591
592 if (_e->modifiers() & Qt::ControlModifier ) {
593 switch (_e->key()) {
594 case Qt::Key_B :
596 return;
597
598 case Qt::Key_F :
600 return;
601
602 case Qt::Key_L :
603 toggleLogger();
604 return;
605
606 case Qt::Key_T :
608 return;
609
610 case Qt::Key_M :
612 return;
613
614 case Qt::Key_N:
616 return;
617
618 case Qt::Key_O :
619 loadMenu();
620 return;
621
622 case Qt::Key_S :
623 saveMenu();
624 default:
625 return;
626 }
627
628 }
629
630 switch (_e->key()) {
631
632 case Qt::Key_Escape:
634 break;
635
636 case Qt::Key_Print:
637 std::cerr << "Todo : On Print Screen, create a snapshot for all viewers" << std::endl;
638 break;
639
640 case Qt::Key_Space:
642 break;
643
644 case Qt::Key_A:
645 strafeLeft();
646 break;
647
648 case Qt::Key_D:
649 strafeRight();
650 break;
651
652 case Qt::Key_W:
653 moveForward();
654 break;
655
656 case Qt::Key_S:
657 moveBack();
658 break;
659
660 case Qt::Key_Shift :
661 shiftPressed_ = true;
662 break;
663
664 default:
665 shiftPressed_ = false;
666 return;
667 }
668}
669
672
673 if ( (( _e->key() == Qt::Key_Meta ) || (_e->key() == Qt::Key_Super_L) || (_e->key() == Qt::Key_Super_R))
674 && OpenFlipper::Options::isLinux() ) {
676 }
677
678 //emit log(LOGERR,"Key release");
679
680 if ( ( _e->key() == Qt::Key_Alt ) && !OpenFlipper::Options::isLinux() ) {
682 }
683
684
685 switch (_e->key()) {
686 case Qt::Key_Shift :
687 shiftPressed_ = false;
688 break;
689 default:
690 return;
691 }
692}
@ LOGERR
Interface class from which all plugins have to be created.
virtual QString name()=0
Return a name for the plugin.
void setActionMode(const Viewer::ActionMode _am)
Definition picking.cc:62
void toggleFullscreen()
Set application to Fullscreen and back.
QString getRPCName(QObject *_plugin)
typedefs
void strafeRight()
When using first person mode strafe to the right.
void coreKeyPressEvent()
handle key events for the core
void toggleToolbox()
Hide or show toolbox area.
void slotAddKeyMapping(int _key, Qt::KeyboardModifiers _modifiers, QObject *_plugin, int _keyBindingID)
add a new key Mapping
virtual void keyPressEvent(QKeyEvent *_e)
Handle key events.
void toggleLogger()
Hide or show logging area.
Viewer::ActionMode actionMode()
void call(QString _expression, bool &_success)
call a scripting function
void coreKeyReleaseEvent(QKeyEvent *_e)
if a keyReleaseEvent belongs to the core this functions is called
QList< SlotInfo > & coreSlots_
list of scripting slots from core
void toggleToolBar()
Hide or show current toolbar.
KeyMap keys_
mapping of all keys to registered keys and the corresponding plugins
virtual void keyReleaseEvent(QKeyEvent *_e)
passes keyReleaseEvents to either the Core or a Plugin depending on who has registered the key
void nextViewerLayout()
Switches over to the next view mode.
void slotRegisterKey(int _key, Qt::KeyboardModifiers _modifiers, const QString &_description, bool _multiUse=false)
key registration
std::vector< PluginInfo > & plugins()
Convenient way to access plugin list.
KeyBinding getKeyBinding(QObject *_plugin, int _keyIndex)
typedefs
void strafeLeft()
When using first person mode strafe to the left.
void moveBack()
When using first person mode move backward.
void saveKeyBindings(INIFile &_ini)
Store current key assignments to a given INI file.
void loadKeyBindings(INIFile &_ini)
Load key assignments from a given INI file.
void registerKey(int _key, Qt::KeyboardModifiers _modifiers, QString _description, bool _multiUse=false)
internal signal to register CoreWidget keys
bool shiftPressed_
Store the state of the shift key.
void registerCoreKeys()
Register all events related to the core.
InverseKeyMap invKeys_
mapping of all registered keys and the corresponding plugins to currently assigned keys
std::vector< KeyBinding > coreKeys_
vector of keys registered to the core
void toggleStatusBar()
Change visibility of the Status Bar.
Definition StatusBar.cc:144
void toggleMenuBar()
Hide or show menu bar.
Viewer::ActionMode lastActionMode()
std::pair< KeyMap::iterator, KeyMap::iterator > KeyRange
typedefs
void moveForward()
When using first person mode move forward.
void slotRegisterSlotKeyBindings()
register scripting slots to allow keyBindings
Class for the handling of simple configuration files.
Definition INIFile.hh:100
bool get_entry(QString &_val, const QString &_section, const QString &_key) const
Access to a string entry.
Definition INIFile.cc:433
bool section_exists(const QString &_section) const
Check if given section exists in the current INI file.
Definition INIFile.cc:227
void add_entry(const QString &_section, const QString &_key, const QString &_value)
Addition / modification of a string entry.
Definition INIFile.cc:257
Keyboard Event Interface.
virtual void slotKeyEvent(QKeyEvent *_event)
Key Event from Main App.
virtual void slotKeyReleaseEvent(QKeyEvent *_event)
Key Release Event from Main App.
QObject * plugin
Pointer to the loaded plugin (Already casted when loading it)
Definition PluginInfo.hh:99
QList< KeyBinding > keys
List of registered keys with description.