summaryrefslogtreecommitdiff
path: root/noncore/applets/keyhelper/keyhelperapplet/misc/KeyAction.h
blob: 4eb5eb6c2e63821e44caee4f6b8c81041b2988a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#ifndef _KEY_ACTION_H_
#define _KEY_ACTION_H_

#include <qobject.h>
#include <qwindowsystem_qws.h>
#include <qtimer.h>
#include <qpe/power.h>
#include "KeyMappings.h"
#include "KeyModifiers.h"
#include "KeyExtensions.h"
#include "KeyRepeater.h"
#include "ConfigEx.h"

class KeyAction : public QObject
{
	Q_OBJECT
public:
	KeyAction();
	virtual ~KeyAction();

	void setKeyMappings(KeyMappings* map)
	{
		m_pMappings = map;
	}
	void setKeyModifiers(KeyModifiers* mod)
	{
		m_pModifiers = mod;
	}
	void setKeyExtensions(KeyExtensions* ext)
	{
		m_pExtensions = ext;
	}
	void setKeyRepeater(KeyRepeater* rep)
	{
		m_pRepeater = rep;
		connect(m_pRepeater, SIGNAL(keyEvent(int,int,int,bool,bool)),
			this, SLOT(sendKeyEvent(int,int,int,bool,bool)));
	}
	void setAction(int unicode, int keycode, int modifiers,
		bool isPress, bool autoRepeat);
	bool doAction();

	void enable(){
		init();
		m_enable = true;
	};
	void disable(){
		m_enable = false;
	};
	void setCapture(bool enable){
		m_capture = enable;
	}

	void setHook(const QCString& s){
		m_hookChannel = s;
	}
private:
	int m_unicode;
	int m_keycode;
	int m_modifiers;
	bool m_isPress;
	bool m_autoRepeat;

	bool m_capture;
	bool m_enable;
	int m_presscnt;

	int m_keep_toggle_code;
	bool m_keepToggle;
	bool m_check;
	QValueList<int> m_excludeKeys;

	QCString m_hookChannel;

	KeyMappings* m_pMappings;
	KeyModifiers* m_pModifiers;
	KeyExtensions* m_pExtensions;
	KeyRepeater* m_pRepeater;

	void init();
	bool checkState();
private slots:
	void sendKeyEvent(int unicode, int keycode, int modifiers,
		bool isPress, bool autoRepeat);
};

#endif /* _KEY_ACTION_H_ */