gepetto-viewer 6.0.0
An user-friendly Graphical Interface
Loading...
Searching...
No Matches
shortcut-factory.hh
Go to the documentation of this file.
1// Copyright (c) 2015-2018, LAAS-CNRS
2// Authors: Joseph Mirabel (joseph.mirabel@laas.fr)
3//
4// This file is part of gepetto-viewer.
5// gepetto-viewer is free software: you can redistribute it
6// and/or modify it under the terms of the GNU Lesser General Public
7// License as published by the Free Software Foundation, either version
8// 3 of the License, or (at your option) any later version.
9//
10// gepetto-viewer is distributed in the hope that it will be
11// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
12// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13// General Lesser Public License for more details. You should have
14// received a copy of the GNU Lesser General Public License along with
15// gepetto-viewer. If not, see <http://www.gnu.org/licenses/>.
16
17#ifndef GEPETTO_GUI_SHORTCUT_FACTORY_HH_
18#define GEPETTO_GUI_SHORTCUT_FACTORY_HH_
19
20#include <QAction>
21#include <QKeyEvent>
22#include <QMouseEvent>
23#include <QPushButton>
24#include <map>
25#include <utility>
26
27namespace gepetto {
28namespace gui {
29class ShortcutFactory : public QObject {
30 Q_OBJECT
31 public:
34
35 public:
42 void addBinding(QString widgetName, QString actionName, QAction* action);
43
44 public slots:
46 void open();
47
48 private:
49 void writeShortcutsFile();
50 void readShortcutsFile();
51
52 typedef std::pair<QString, QAction*> Binding;
53 typedef std::list<Binding> BindingList;
54 typedef std::map<QString, BindingList> MapBindings;
55
56 class ShortcutButton : public QPushButton {
57 public:
58 ShortcutButton(QAction* action, QWidget* parent = 0);
59 ~ShortcutButton();
60
61 protected:
62 virtual void mouseDoubleClickEvent(QMouseEvent* event);
63 virtual void keyPressEvent(QKeyEvent* event);
64
65 bool hasFocus_;
66 QList<int> modifiers_;
67 QAction* action_;
68 };
69
70 MapBindings widgetsBindings_;
71 std::map<QString, QKeySequence> saved_;
72};
73} // namespace gui
74} // namespace gepetto
75
76#endif /* GEPETTO_GUI_SHORTCUT_FACTORY_HH_ */
Definition shortcut-factory.hh:29
void open()
Open the widget that allows to change the different shortcut.
void addBinding(QString widgetName, QString actionName, QAction *action)
Definition action-search-bar.hh:27