ShortcutController.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2012-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5  *
6  * ArmarX is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * ArmarX is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * @package MemoryX::gui-plugins::SceneEditor
19  * @date 2015
20  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
21  * GNU General Public License
22  */
23 
24 #include <exception>
25 
26 // QT
27 #include <QString>
28 #include <QPointer>
29 #include <QHash>
30 #include <QKeySequence>
31 #include <QAction>
32 
33 #ifndef __Gui__ShortcutController_h__
34 #define __Gui__ShortcutController_h__
35 
36 namespace gui
37 {
38  class ShortcutController;
39 }
40 
41 namespace gui
42 {
43  /**
44  * The class ShortcutController manages all shortcuts that can be set in the widget.
45  * Each QAction registers its shortcut (if desired) over the ShortcutController.
46  *
47  * QApplication must be initialized for this class to work!
48  *
49  */
50  class ShortcutController // QApplication muss initialisiert sein -> KOMMENTAR
51  {
52  public:
53  /**
54  * A constructor.
55  * Creates a new Instance of this class.
56  *
57  */
59 
60  /**
61  * A constructor.
62  * Creates a new Instance of this class with already defined initial Shortcuts.
63  *
64  * @param initialShortcuts List of already defined Shortcuts
65  */
66  ShortcutController(const QHash<QString, QKeySequence>& initialShortcuts);
67 
68  /**
69  * A destructor.
70  *
71  */
73 
74  /**
75  * Registers a QAction, so this action can be given a shortcut.
76  *
77  * @param name Name of the registered QAction
78  * @param action QAction to be registered
79  */
80  void registerAction(const QString& name, const QPointer<QAction>& action);
81  /**
82  * Sets the given QKeySequence as Shortcut for the QAction specified by name.
83  *
84  * @param name Specifies the QAction edited
85  * @param keysequence The QKeySequence that is added to the QAction
86  */
87  void updateShortcut(const QString& name, const QKeySequence& keysequence);
88  /**
89  * Returns a Hashtable with all existing Shortcuts.
90  *
91  * @return QHash with all Shortcuts
92  */
93  QHash<QString, QKeySequence> getAllShortcuts();
94  /**
95  * Returns a Hashtable with all registered Shortcuts.
96  *
97  * @return QHash with all registered Shortcuts
98  */
99  QHash<QString, QKeySequence> getAllRegisteredShortcuts();
100  /**
101  * Returns a Hashtable with all Actions saved.
102  *
103  * @return QHash with all Actions
104  */
105  QHash<QString, QPointer<QAction> > getAllActions();
106 
107  private:
108  QHash<QString, QPointer<QAction> > registeredActions;
109  QHash<QString, QKeySequence> shortcuts;
110 
111  };
112 }
113 
114 #endif
gui::ShortcutController::getAllShortcuts
QHash< QString, QKeySequence > getAllShortcuts()
Returns a Hashtable with all existing Shortcuts.
Definition: ShortcutController.cpp:94
gui::ShortcutController
The class ShortcutController manages all shortcuts that can be set in the widget.
Definition: ShortcutController.h:50
gui::ShortcutController::ShortcutController
ShortcutController()
A constructor.
Definition: ShortcutController.cpp:34
gui::ShortcutController::updateShortcut
void updateShortcut(const QString &name, const QKeySequence &keysequence)
Sets the given QKeySequence as Shortcut for the QAction specified by name.
Definition: ShortcutController.cpp:67
gui::ShortcutController::getAllRegisteredShortcuts
QHash< QString, QKeySequence > getAllRegisteredShortcuts()
Returns a Hashtable with all registered Shortcuts.
Definition: ShortcutController.cpp:99
gui::ShortcutController::registerAction
void registerAction(const QString &name, const QPointer< QAction > &action)
Registers a QAction, so this action can be given a shortcut.
Definition: ShortcutController.cpp:50
gui::ShortcutController::getAllActions
QHash< QString, QPointer< QAction > > getAllActions()
Returns a Hashtable with all Actions saved.
Definition: ShortcutController.cpp:115
gui::ShortcutController::~ShortcutController
~ShortcutController()
A destructor.
Definition: ShortcutController.cpp:46