Diffstat (limited to 'noncore/applets/keyhelper/keyhelperapplet/misc/KeyModifiers.h') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/applets/keyhelper/keyhelperapplet/misc/KeyModifiers.h | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/noncore/applets/keyhelper/keyhelperapplet/misc/KeyModifiers.h b/noncore/applets/keyhelper/keyhelperapplet/misc/KeyModifiers.h new file mode 100644 index 0000000..a99c181 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/misc/KeyModifiers.h | |||
@@ -0,0 +1,80 @@ | |||
1 | #ifndef _KEY_MODIFIERS_H_ | ||
2 | #define _KEY_MODIFIERS_H_ | ||
3 | |||
4 | #include <qmap.h> | ||
5 | #include <qtimer.h> | ||
6 | #include <qvaluelist.h> | ||
7 | #include <qnamespace.h> | ||
8 | |||
9 | #include <qpe/config.h> | ||
10 | #include "ConfigEx.h" | ||
11 | |||
12 | struct ModifierInfo { | ||
13 | public: | ||
14 | ModifierInfo(const QString& tp, int code, int mask, bool mode) | ||
15 | { | ||
16 | type = tp; | ||
17 | keycode = code; | ||
18 | keymask = mask; | ||
19 | pressed = false; | ||
20 | toggled = false; | ||
21 | toggle_mode = mode; | ||
22 | } | ||
23 | QString type; | ||
24 | int keycode; | ||
25 | int keymask; | ||
26 | bool pressed; | ||
27 | bool toggled; | ||
28 | bool toggle_mode; | ||
29 | private: | ||
30 | } ; | ||
31 | |||
32 | class KeyModifiers : public QObject | ||
33 | { | ||
34 | Q_OBJECT | ||
35 | public: | ||
36 | typedef QValueList<ModifierInfo*> ModifierList; | ||
37 | |||
38 | KeyModifiers(); | ||
39 | virtual ~KeyModifiers(); | ||
40 | void addType(const QString& type); | ||
41 | ModifierInfo* assign(const QString& type, int keycode, | ||
42 | int keymask = 0, bool toggle = false); | ||
43 | void assignRelease(int keycode); | ||
44 | void assignRelease(ModifierInfo* info, int keycode); | ||
45 | void setToggle(); | ||
46 | void setToggle(ModifierInfo* info); | ||
47 | |||
48 | bool isToggled(); | ||
49 | void resetStates(); | ||
50 | void keepToggles(); | ||
51 | |||
52 | bool pressKey(int keycode, int modifiers); | ||
53 | void releaseKey(int keycode); | ||
54 | int getState(); | ||
55 | int getState(int modifiers, bool reset = false); | ||
56 | int getMask(const QString& type); | ||
57 | int getModifiers(int modifiers); | ||
58 | |||
59 | bool isModifier(int keycode); | ||
60 | |||
61 | void statistics(); | ||
62 | |||
63 | void reset(); | ||
64 | public slots: | ||
65 | void resetToggles(); | ||
66 | private: | ||
67 | QMap<QString, int> m_types; | ||
68 | int m_bitmask; | ||
69 | ModifierList m_modifiers; | ||
70 | QMap<int, ModifierList*> m_releasekeys; | ||
71 | ModifierList m_togglekeys; | ||
72 | ModifierInfo* m_info; | ||
73 | QTimer* m_pTimer; | ||
74 | int m_timeout; | ||
75 | |||
76 | void clear(); | ||
77 | void init(); | ||
78 | }; | ||
79 | |||
80 | #endif /* _KEY_MODIFIERS_H_ */ | ||