OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
shortcut.hpp
Go to the documentation of this file.
1 #ifndef CSM_PREFS_SHORTCUT_H
2 #define CSM_PREFS_SHORTCUT_H
3 
4 #include <string>
5 
6 #include <QKeySequence>
7 #include <QObject>
8 #include <QString>
9 
10 class QAction;
11 class QWidget;
12 
13 namespace CSMPrefs
14 {
16  class Shortcut : public QObject
17  {
18  Q_OBJECT
19 
20  public:
21 
23  {
27  };
28 
30  {
34  };
35 
36  Shortcut(const std::string& name, QWidget* parent);
37  Shortcut(const std::string& name, const std::string& modName, QWidget* parent);
38  Shortcut(const std::string& name, const std::string& modName, SecondaryMode secMode, QWidget* parent);
39 
40  ~Shortcut();
41 
42  bool isEnabled() const;
43 
44  const std::string& getName() const;
45  const std::string& getModifierName() const;
46 
48 
49  const QKeySequence& getSequence() const;
50  int getModifier() const;
51 
53  int getPosition() const;
55  int getLastPosition() const;
56 
58  bool getModifierStatus() const;
59 
60  void enable(bool state);
61 
62  void setSequence(const QKeySequence& sequence);
63  void setModifier(int modifier);
64 
66  void setPosition(int pos);
67 
69  void setModifierStatus(bool status);
70 
72  void associateAction(QAction* action);
73 
74  // Workaround for Qt4 signals being "protected"
75  void signalActivated(bool state);
76  void signalActivated();
77 
78  void signalSecondary(bool state);
79  void signalSecondary();
80 
81  QString toString() const;
82 
83  private:
84 
85  bool mEnabled;
86 
87  std::string mName;
88  std::string mModName;
90  QKeySequence mSequence;
91  int mModifier;
92 
94  int mLastPos;
95 
98 
100  QString mActionText;
101 
102  private slots:
103 
104  void actionDeleted();
105 
106  signals:
107 
109  void activated(bool state);
110 
112  void activated();
113 
115  void secondary(bool state);
116 
118  void secondary();
119  };
120 }
121 
122 #endif
Definition: shortcut.hpp:25
void actionDeleted()
Definition: shortcut.cpp:210
void activated()
Convenience signal.
QAction * mAction
Definition: shortcut.hpp:99
Definition: shortcut.hpp:26
static const struct @2 signals[]
void setModifierStatus(bool status)
Definition: shortcut.cpp:159
int mLastPos
Definition: shortcut.hpp:94
void signalActivated()
Definition: shortcut.cpp:191
void secondary()
Convenience signal.
The secondary signal is emitted independent of the regular signal, even if not active.
Definition: shortcut.hpp:32
int getLastPosition() const
The position in the sequence.
Definition: shortcut.cpp:112
void setPosition(int pos)
The position in the sequence.
Definition: shortcut.cpp:149
The secondary signal will not ever be emitted.
Definition: shortcut.hpp:33
Shortcut(const std::string &name, QWidget *parent)
Definition: shortcut.cpp:13
const std::string & getName() const
Definition: shortcut.cpp:82
SecondaryMode mSecondaryMode
Definition: shortcut.hpp:89
ActivationStatus
Definition: shortcut.hpp:22
Definition: shortcut.hpp:24
bool mModifierStatus
Definition: shortcut.hpp:97
const std::string & getModifierName() const
Definition: shortcut.cpp:87
bool mEnabled
Definition: shortcut.hpp:85
void associateAction(QAction *action)
Appends the sequence to the QAction text, also keeps it up to date.
Definition: shortcut.cpp:164
int mCurrentPos
Definition: shortcut.hpp:93
std::string mName
Definition: shortcut.hpp:87
const QKeySequence & getSequence() const
Definition: shortcut.cpp:97
~Shortcut()
Definition: shortcut.cpp:72
void setSequence(const QKeySequence &sequence)
Definition: shortcut.cpp:132
int getModifier() const
Definition: shortcut.cpp:102
ActivationStatus getActivationStatus() const
Definition: shortcut.cpp:117
QKeySequence mSequence
Definition: shortcut.hpp:90
int getPosition() const
The position in the sequence.
Definition: shortcut.cpp:107
bool isEnabled() const
Definition: shortcut.cpp:77
SecondaryMode
Definition: shortcut.hpp:29
void signalSecondary()
Definition: shortcut.cpp:200
bool getModifierStatus() const
Definition: shortcut.cpp:122
SecondaryMode getSecondaryMode() const
Definition: shortcut.cpp:92
void setActivationStatus(ActivationStatus status)
Definition: shortcut.cpp:154
int mModifier
Definition: shortcut.hpp:91
void enable(bool state)
Definition: shortcut.cpp:127
ActivationStatus mActivationStatus
Definition: shortcut.hpp:96
QString toString() const
Definition: shortcut.cpp:205
The secondary signal replaces the regular signal when the modifier is active.
Definition: shortcut.hpp:31
std::string mModName
Definition: shortcut.hpp:88
QString mActionText
Definition: shortcut.hpp:100
A class similar in purpose to QShortcut, but with the ability to use mouse buttons.
Definition: shortcut.hpp:16
void setModifier(int modifier)
Definition: shortcut.cpp:144
const char * name
Definition: crashcatcher.cpp:59