-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathkey.h
More file actions
109 lines (90 loc) · 2.37 KB
/
Copy pathkey.h
File metadata and controls
109 lines (90 loc) · 2.37 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#pragma once
#include <QPushButton>
#include <QJsonArray>
extern int fd;
/* Use Q_OBJECT if signal+button handler is used */
class Key : public QPushButton
{
#ifdef MOUSE_EVENT
Q_OBJECT
#endif
public:
explicit Key(int x, int y, int w, int h,
QString label, QString stylesheet, QWidget *parent);
QString label;
#ifdef MOUSE_EVENT
public slots:
void mousePressed();
void mouseReleased();
#endif
protected:
bool event(QEvent *event) override;
void emitKey(int fd, int type, int code, int val);
// Use vitual so that event() call the overriden methods
virtual void pressed(QEvent *event);
virtual void updated(QEvent *event);
virtual void released(QEvent *event);
};
class RegularKey : public Key
{
#ifdef MOUSE_EVENT
Q_OBJECT
#endif
public:
explicit RegularKey(int x, int y, int w, int h,
int code, QString label, QString stylesheet, QWidget *parent);
int code;
protected:
void pressed(QEvent *event) override;
void released(QEvent *event) override;
};
class MouseKey : public Key
{
#ifdef MOUSE_EVENT
Q_OBJECT
#endif
public:
explicit MouseKey(int x, int y, int w, int h, QString mouseType, int mouseX, int mouseY,
QString label, QString stylesheet, QWidget *parent);
int mouseType, mouseX, mouseY;
protected:
void released(QEvent *event) override;
};
#define SPECIAL_EXIT 0
class ExitKey : public Key
{
#ifdef MOUSE_EVENT
Q_OBJECT
#endif
public:
explicit ExitKey(int x, int y, int w, int h,
QString label, QString stylesheet, QWidget *parent);
protected:
void released(QEvent *event) override;
};
#define SPECIAL_REPOSITION 1
class RepositionKey : public Key
{
public:
explicit RepositionKey(int x, int y, int w, int h,
QString label, QString stylesheet, QWidget *parent);
protected:
qreal prevTouchX;
qreal prevTouchY;
void pressed(QEvent *event) override;
void updated(QEvent *event) override;
};
#define SPECIAL_PLACEHOLDER 2
class MacroKey : public Key
{
#ifdef MOUSE_EVENT
Q_OBJECT
#endif
public:
explicit MacroKey(int x, int y, int w, int h, QJsonArray macro,
QString label, QString stylesheet, QWidget *parent);
QJsonArray macro;
protected:
void released(QEvent *event) override;
void processMacro(const QJsonArray &p, int start, int n);
};