OpenTwin 0.1
OpenTwin
 
Loading...
Searching...
No Matches
ShortcutManager.h
Go to the documentation of this file.
1#pragma once
2
3// openTwin header
4#include "OTGui/GuiTypes.h"
5
6// uiCore header
7#include <akCore/aObject.h>
9#include <akCore/aNotifier.h>
10
11// Qt header
12#include <qobject.h>
13
14// C++ header
15#include <map>
16#include <list>
17#include <exception>
18
19class AppBase;
21
22class QShortcut;
23
24namespace ot { class ServiceBase; }
25
27public:
29 virtual ~ShortcutManager();
30
31 void addHandler(KeyboardCommandHandler * _handler);
32
33 void creatorDestroyed(ot::ServiceBase * _creator);
34
35 bool shortcutIsRegistered(const QString& _keySequence);
36
37 KeyboardCommandHandler * handlerFromKeySequence(const QString& _keySequence);
38
39 void clearViewerHandler(void);
40
41private:
42
43
44 std::map<ot::ServiceBase *, std::vector<KeyboardCommandHandler *> *> m_handler;
45
47 ShortcutManager& operator = (ShortcutManager&) = delete;
48};
49
50// ##########################################################################################################################
51
52// ##########################################################################################################################
53
54// ##########################################################################################################################
55
56class KeyboardCommandHandler : public QObject, public ak::aObject {
57 Q_OBJECT
58public:
59 KeyboardCommandHandler(ot::ServiceBase * _creator, AppBase * _app, const QString& _keySequence);
61
62 // #################################################################################################
63
64 // Getter
65
66 static Qt::Key keyFromOpenTwin(ot::BasicKey _key);
67
68 bool isEnabled(void) const { return m_isEnabled; }
69
70 bool isViewerHandler(void) const { return m_isViewerHandler; }
71
72 ot::ServiceBase * creator(void) const { return m_creator; }
73
74 ak::UID attatchedSender(void) const { return m_eventSender; }
75
76 ak::eventType eventType(void) const { return m_eventType; }
77
78 const QString& keySequence(void) const { return m_sequence; }
79
80 // #################################################################################################
81
82 // Setter
83
84 void enable(void) { m_isEnabled = true; }
85
86 void disable(void) { m_isEnabled = false; }
87
88 void setAsViewerHandler(bool _isViewerHandler) { m_isViewerHandler = _isViewerHandler; }
89
90 void attachToEvent(ak::UID _sender, ak::eventType _event, int _info1 = 0, int _info2 = 0);
91
92private Q_SLOTS:
93 void slotActivated(void);
94
95private:
96
97 void ini(const QString& _keySequence);
98
99 AppBase * m_app;
100 ot::ServiceBase * m_creator;
101 bool m_isViewerHandler;
102
103 QShortcut * m_shortcut;
104 QString m_sequence;
105 bool m_isEnabled;
106 ak::UID m_eventSender;
107 ak::eventType m_eventType;
108 int m_eventInfo1;
109 int m_eventInfo2;
110
111 KeyboardCommandHandler() = delete;
113 KeyboardCommandHandler& operator = (KeyboardCommandHandler&) = delete;
114};
115
116class InvalidKeyCombinationException : public std::exception {
117public:
119};
The API manager is used to manage the global objects required for this API to work.
Definition AppBase.h:21
Definition ShortcutManager.h:116
InvalidKeyCombinationException()
Definition ShortcutManager.cpp:235
Definition ShortcutManager.h:56
ak::UID attatchedSender(void) const
Definition ShortcutManager.h:74
const QString & keySequence(void) const
Definition ShortcutManager.h:78
virtual ~KeyboardCommandHandler()
Definition ShortcutManager.cpp:106
static Qt::Key keyFromOpenTwin(ot::BasicKey _key)
Definition ShortcutManager.cpp:114
void setAsViewerHandler(bool _isViewerHandler)
Definition ShortcutManager.h:88
ot::ServiceBase * creator(void) const
Definition ShortcutManager.h:72
void enable(void)
Definition ShortcutManager.h:84
bool isEnabled(void) const
Definition ShortcutManager.h:68
void disable(void)
Definition ShortcutManager.h:86
void attachToEvent(ak::UID _sender, ak::eventType _event, int _info1=0, int _info2=0)
Definition ShortcutManager.cpp:187
ak::eventType eventType(void) const
Definition ShortcutManager.h:76
bool isViewerHandler(void) const
Definition ShortcutManager.h:70
Definition ServiceBase.h:28
Definition ShortcutManager.h:26
KeyboardCommandHandler * handlerFromKeySequence(const QString &_keySequence)
Definition ShortcutManager.cpp:61
bool shortcutIsRegistered(const QString &_keySequence)
Definition ShortcutManager.cpp:49
void clearViewerHandler(void)
Definition ShortcutManager.cpp:73
ShortcutManager()
Definition ShortcutManager.cpp:17
void addHandler(KeyboardCommandHandler *_handler)
Definition ShortcutManager.cpp:29
virtual ~ShortcutManager()
Definition ShortcutManager.cpp:19
void creatorDestroyed(ot::ServiceBase *_creator)
Definition ShortcutManager.cpp:40
This class is used to store the main information of any object used Information contained is the UID ...
Definition aObject.h:34
General service information. The ServiceBase class is used to store the general service information.
Definition ServiceBase.h:24
unsigned long long UID
The UID datatype used for objects.
Definition globalDataTypes.h:65
eventType
Describes the type of an event.
Definition akCore.h:86
Definition Connector.h:8
BasicKey
Definition GuiTypes.h:83