swift
actionhotkey.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_ACTIONHOTKEY_H
7 #define SWIFT_MISC_INPUT_ACTIONHOTKEY_H
8 
9 #include <QMetaType>
10 #include <QString>
11 
12 #include "misc/identifier.h"
14 #include "misc/metaclass.h"
15 #include "misc/propertyindexref.h"
16 #include "misc/swiftmiscexport.h"
17 #include "misc/valueobject.h"
18 
19 SWIFT_DECLARE_VALUEOBJECT_MIXINS(swift::misc::input, CActionHotkey)
20 
21 namespace swift::misc::input
22 {
24  class SWIFT_MISC_EXPORT CActionHotkey : public CValueObject<CActionHotkey>
25  {
26  public:
29  {
30  IndexIdentifier = CPropertyIndexRef::GlobalIndexCSettingKeyboardHotkey,
31  IndexIdentifierAsString,
32  IndexCombination,
33  IndexCombinationAsString,
34  IndexAction,
35  IndexActionAsString,
36  IndexObject, // just for updates
37  };
38 
40  CActionHotkey() = default;
41 
43  CActionHotkey(const QString &action);
44 
46  CActionHotkey(const CIdentifier &identifier, const CHotkeyCombination &combination, const QString &action);
47 
49  const CHotkeyCombination &getCombination() const { return m_combination; }
50 
52  void setCombination(const CHotkeyCombination &combination);
53 
55  const QString &getAction() const { return m_action; }
56 
58  void setAction(const QString &action) { m_action = action; }
59 
61  const CIdentifier &getIdentifier() const { return m_identifier; }
62 
64  void setApplicableMachine(const CIdentifier &identifier) { m_identifier = identifier; }
65 
67  const CIdentifier &getApplicableMachine() const { return m_identifier; }
68 
70  bool isForSameMachineId(const CActionHotkey &key) const;
71 
73  bool isForSameMachineName(const CActionHotkey &key) const;
74 
76  bool isForSameMachine(const CActionHotkey &key) const;
77 
79  void updateToCurrentMachine();
80 
82  void setObject(const CActionHotkey &obj);
83 
85  bool isValid() const
86  {
87  return !m_identifier.getMachineName().isEmpty() && !m_combination.isEmpty() && !m_action.isEmpty();
88  }
89 
91  void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant);
92 
94  QVariant propertyByIndex(CPropertyIndexRef index) const;
95 
97  QString convertToQString(bool i18n = false) const;
98 
99  private:
100  CIdentifier m_identifier;
101  CHotkeyCombination m_combination;
102  QString m_action;
103 
106  SWIFT_METAMEMBER(identifier),
107  SWIFT_METAMEMBER(combination),
108  SWIFT_METAMEMBER(action));
109  };
110 } // namespace swift::misc::input
111 
112 Q_DECLARE_METATYPE(swift::misc::input::CActionHotkey)
113 
114 #endif // SWIFT_MISC_INPUT_ACTIONHOTKEY_H
Value object encapsulating information identifying a component of a modular distributed swift process...
Definition: identifier.h:29
Non-owning reference to a CPropertyIndex with a subset of its features.
Mix of the most commonly used mixin classes.
Definition: valueobject.h:114
Value object encapsulating a action hotkey.
Definition: actionhotkey.h:25
void setApplicableMachine(const CIdentifier &identifier)
Set applicable machine.
Definition: actionhotkey.h:64
CActionHotkey()=default
Default constructor.
const CIdentifier & getApplicableMachine() const
Get applicable machine.
Definition: actionhotkey.h:67
const CIdentifier & getIdentifier() const
The identifier.
Definition: actionhotkey.h:61
ColumnIndex
Properties by index.
Definition: actionhotkey.h:29
void setAction(const QString &action)
Set function.
Definition: actionhotkey.h:58
const QString & getAction() const
Action.
Definition: actionhotkey.h:55
bool isValid() const
Is hotkey valid?
Definition: actionhotkey.h:85
const CHotkeyCombination & getCombination() const
Get hotkey combination.
Definition: actionhotkey.h:49
Value object representing hotkey sequence.
#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