swift
hotkeycombination.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) 2015 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
5 
6 #ifndef SWIFT_MISC_INPUT_HOTKEYCOMBINATION_H
7 #define SWIFT_MISC_INPUT_HOTKEYCOMBINATION_H
8 
9 #include <QMetaType>
10 #include <QStringList>
11 
14 #include "misc/input/keyboardkey.h"
16 #include "misc/metaclass.h"
17 #include "misc/swiftmiscexport.h"
18 #include "misc/valueobject.h"
19 
20 SWIFT_DECLARE_VALUEOBJECT_MIXINS(swift::misc::input, CHotkeyCombination)
21 
22 namespace swift::misc::input
23 {
25  class SWIFT_MISC_EXPORT CHotkeyCombination : public CValueObject<CHotkeyCombination>
26  {
27  public:
29  CHotkeyCombination() = default;
30 
33 
36 
38  void setKeyboardKeys(const CKeyboardKeyList &keys) { m_keyboardKeys = keys; }
39 
41  CKeyboardKeyList getKeyboardKeys() const { return m_keyboardKeys; }
42 
44  QStringList getKeyStrings() const { return m_keyboardKeys.getKeyStrings(); }
45 
47  void setJoystickButtons(const CJoystickButtonList &list) { m_joystickButtons = list; }
48 
50  CJoystickButtonList getJoystickButtons() const { return m_joystickButtons; }
51 
53  void addKeyboardKey(const CKeyboardKey &key);
54 
56  void addJoystickButton(const CJoystickButton &button);
57 
59  bool containsKeyboardKey(const CKeyboardKey &key) const;
60 
62  bool containsJoystickButton(const CJoystickButton &button) const;
63 
65  void replaceKey(CKeyboardKey oldKey, CKeyboardKey newKey);
66 
68  void replaceButton(CJoystickButton oldButton, CJoystickButton newButton);
69 
71  void removeKeyboardKey(CKeyboardKey key);
72 
74  void removeJoystickButton(CJoystickButton button);
75 
77  bool isEmpty() const { return m_keyboardKeys.isEmpty() && m_joystickButtons.isEmpty(); }
78 
80  int size() const { return m_keyboardKeys.size() + m_joystickButtons.size(); }
81 
84  bool isSubsetOf(const CHotkeyCombination &other) const;
85 
87  CHotkeyCombination getDeltaComparedTo(const CHotkeyCombination &other) const;
88 
90  QString convertToQString(bool i18n = false) const;
91 
93  QString asStringWithDeviceNames() const;
94 
95  private:
96  CKeyboardKeyList m_keyboardKeys;
97  CJoystickButtonList m_joystickButtons;
98 
101  SWIFT_METAMEMBER(keyboardKeys),
102  SWIFT_METAMEMBER(joystickButtons));
103  };
104 } // namespace swift::misc::input
105 
106 Q_DECLARE_METATYPE(swift::misc::input::CHotkeyCombination)
107 
108 #endif // SWIFT_MISC_INPUT_HOTKEYCOMBINATION_H
Mix of the most commonly used mixin classes.
Definition: valueobject.h:114
Value object representing hotkey sequence.
QStringList getKeyStrings() const
As keyboard key strings.
int size() const
Get size of sequence.
CHotkeyCombination()=default
Default constructor.
CJoystickButtonList getJoystickButtons() const
Get joystick buttons.
void setKeyboardKeys(const CKeyboardKeyList &keys)
Set keyboard keys.
void setJoystickButtons(const CJoystickButtonList &list)
Set joystick buttons.
CKeyboardKeyList getKeyboardKeys() const
Get keyboard keys.
bool isEmpty() const
Is sequence empty?
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.
#define SWIFT_METAMEMBER(MEMBER,...)
Macro to define an element within a metaclass.
Definition: metaclass.h:73
#define SWIFT_METACLASS(CLASS,...)
Macro to define a nested metaclass that describes the attributes of its enclosing class.
Definition: metaclass.h:53
#define SWIFT_MISC_EXPORT
Export a class or function from the library.
#define SWIFT_DECLARE_VALUEOBJECT_MIXINS(Namespace, Class)
Explicit template declaration of mixins for a CValueObject subclass to be placed near the top of the ...
Definition: valueobject.h:65