swift
hotkeydialog.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) 2014 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
5 
6 #ifndef SWIFT_GUI_COMPONENTS_HOTKEYDIALOG_H
7 #define SWIFT_GUI_COMPONENTS_HOTKEYDIALOG_H
8 
9 #include <QComboBox>
10 #include <QDialog>
11 #include <QObject>
12 #include <QScopedPointer>
13 
14 #include "gui/models/actionmodel.h"
15 #include "gui/swiftguiexport.h"
16 #include "misc/identifierlist.h"
18 
19 class QItemSelection;
20 
21 namespace Ui
22 {
23  class CHotkeyDialog;
24 }
25 namespace swift::core
26 {
27  class CInputManager;
28 }
29 namespace swift::misc::input
30 {
31  class CHotkeyCombination;
32  class CKeyboardKeyList;
33 } // namespace swift::misc::input
34 namespace swift::gui::components
35 {
40  {
41  Q_OBJECT
42 
43  public:
45  CKeySelectionBox(QWidget *parent = nullptr);
46 
48  void setSelectedIndex(int index);
49 
50  signals:
52  void keySelectionChanged(int oldIndex, int newIndex);
53 
54  private:
55  void updateSelectedIndex(int index);
56 
57  int m_oldIndex;
58  };
59 
64  {
65  Q_OBJECT
66 
67  public:
70  const swift::misc::CIdentifierList &identifiers, QWidget *parent = nullptr);
71 
73  ~CHotkeyDialog() override;
74 
77 
79  void initStyleSheet();
80 
82  void accept() override;
83 
85  static swift::misc::input::CActionHotkey getActionHotkey(const swift::misc::input::CActionHotkey &initial,
86  const swift::misc::CIdentifierList &identifiers,
87  QWidget *parent = nullptr);
88 
89  private:
90  void advancedModeChanged();
91  void captureHotkey();
92  void combinationSelectionChanged(const swift::misc::input::CHotkeyCombination &combination);
93  void combinationSelectionFinished(const swift::misc::input::CHotkeyCombination &combination);
94  void changeSelectedAction(const QItemSelection &selected, const QItemSelection &deselected);
95  CKeySelectionBox *addSelectionBox(const swift::misc::input::CKeyboardKeyList &allSupportedKeys,
96  const swift::misc::input::CKeyboardKey &keyboardKey = {});
97  CKeySelectionBox *addSelectionBox(const swift::misc::input::CJoystickButtonList &allAvailableButtons,
98  const swift::misc::input::CJoystickButton &joystickButton = {});
99 
100  void changeApplicableMachine(int index);
101  void synchronize();
102  void synchronizeSimpleSelection();
103  void synchronizeAdvancedSelection();
104  void setupAdvancedFrame();
105  void clearAdvancedFrame();
106  void advancedKeyChanged(int oldIndex, int newIndex);
107  void selectAction();
108 
110  swift::misc::input::CActionHotkey m_actionHotkey;
111  swift::gui::models::CActionModel m_actionModel;
112 
114  static const QString &noKeyButton();
115  };
116 } // namespace swift::gui::components
117 
118 #endif // SWIFT_GUI_COMPONENTS_HOTKEYDIALOG_H
swift::misc::input::CActionHotkey getSelectedActionHotkey() const
Get hotkey selected by user.
Definition: hotkeydialog.h:76
ComboBox for selecting keyboard keys.
Definition: hotkeydialog.h:40
void keySelectionChanged(int oldIndex, int newIndex)
User has changed the selection.
Action tree model, used with hotkey actions.
Definition: actionmodel.h:28
Value object encapsulating a list of object identifiers.
Value object encapsulating a action hotkey.
Definition: actionhotkey.h:25
Value object representing hotkey sequence.
Value object representing a joystick button.
Value object encapsulating a list of joystick buttons.
Value object representing a keyboard key.
Definition: keyboardkey.h:25
Value object encapsulating a list of keyboard keys.
Backend services of the swift project, like dealing with the network or the simulators.
Definition: actionbind.cpp:7
High level reusable GUI components.
Definition: aboutdialog.cpp:14
#define SWIFT_GUI_EXPORT
Export a class or function from the library.