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 <QDialog>
10 #include <QObject>
11 #include <QScopedPointer>
12 
13 #include "gui/models/actionmodel.h"
14 #include "gui/swiftguiexport.h"
15 #include "misc/identifierlist.h"
17 
18 class QItemSelection;
19 
20 namespace Ui
21 {
22  class CHotkeyDialog;
23 }
24 namespace swift::core
25 {
26  class CInputManager;
27 }
28 namespace swift::misc::input
29 {
30  class CHotkeyCombination;
31  class CKeyboardKeyList;
32 } // namespace swift::misc::input
33 namespace swift::gui::components
34 {
38  class SWIFT_GUI_EXPORT CKeySelectionBox : public QComboBox
39  {
40  Q_OBJECT
41 
42  public:
44  CKeySelectionBox(QWidget *parent = nullptr);
45 
47  void setSelectedIndex(int index);
48 
49  signals:
51  void keySelectionChanged(int oldIndex, int newIndex);
52 
53  private:
54  void updateSelectedIndex(int index);
55 
56  int m_oldIndex;
57  };
58 
62  class SWIFT_GUI_EXPORT CHotkeyDialog : public QDialog
63  {
64  Q_OBJECT
65 
66  public:
69  const swift::misc::CIdentifierList &identifiers, QWidget *parent = nullptr);
70 
72  virtual ~CHotkeyDialog() override;
73 
76 
78  void initStyleSheet();
79 
81  virtual void accept() override;
82 
84  static swift::misc::input::CActionHotkey getActionHotkey(const swift::misc::input::CActionHotkey &initial,
85  const swift::misc::CIdentifierList &identifiers,
86  QWidget *parent = nullptr);
87 
88  private:
89  void advancedModeChanged();
90  void captureHotkey();
91  void combinationSelectionChanged(const swift::misc::input::CHotkeyCombination &combination);
92  void combinationSelectionFinished(const swift::misc::input::CHotkeyCombination &combination);
93  void changeSelectedAction(const QItemSelection &selected, const QItemSelection &deselected);
94  CKeySelectionBox *addSelectionBox(const swift::misc::input::CKeyboardKeyList &allSupportedKeys,
95  const swift::misc::input::CKeyboardKey &keyboardKey = {});
96  CKeySelectionBox *addSelectionBox(const swift::misc::input::CJoystickButtonList &allAvailableButtons,
97  const swift::misc::input::CJoystickButton &joystickButton = {});
98 
99  void changeApplicableMachine(int index);
100  void synchronize();
101  void synchronizeSimpleSelection();
102  void synchronizeAdvancedSelection();
103  void setupAdvancedFrame();
104  void clearAdvancedFrame();
105  void advancedKeyChanged(int oldIndex, int newIndex);
106  void selectAction();
107 
108  QScopedPointer<Ui::CHotkeyDialog> ui;
109  swift::misc::input::CActionHotkey m_actionHotkey;
110  swift::gui::models::CActionModel m_actionModel;
111 
113  static const QString &noKeyButton();
114  };
115 } // namespace swift::gui::components
116 
117 #endif // SWIFT_GUI_COMPONENTS_HOTKEYDIALOG_H
swift::misc::input::CActionHotkey getSelectedActionHotkey() const
Get hotkey selected by user.
Definition: hotkeydialog.h:75
ComboBox for selecting keyboard keys.
Definition: hotkeydialog.h:39
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:13
#define SWIFT_GUI_EXPORT
Export a class or function from the library.