forked from xiaoyanLG/Soft-keyboard
-
Notifications
You must be signed in to change notification settings - Fork 1
/
xypushbutton.h
67 lines (55 loc) · 1.73 KB
/
xypushbutton.h
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
#ifndef XYPUSHBUTTON_H
#define XYPUSHBUTTON_H
#include <QLabel>
#include <QTimer>
class XYPushButton : public QLabel
{
Q_OBJECT
public:
explicit XYPushButton(const QString &text, int generalKey, int shiftKey = -1, bool small = false, QWidget *parent=0);
~XYPushButton();
bool isChecked();
static bool isChinese();
static void resizeAllPerfect(const QSize &size);
static QString EnText();
static QString zhongText();
QSize sizeHint() const;
signals:
void mousePressed(XYPushButton *btn);
void mouseReleaseed(XYPushButton *btn);
void clicked();
void clicked(int unicode, int key, Qt::KeyboardModifiers modifiers, bool press);
void checkedChanged(bool checked = false);
public slots:
void resizePerfect(const QSize &size);
void setChecked(bool checked);
void setCheckable(bool checkable);
void startRepeatTimer();
protected:
void paintEvent(QPaintEvent *event);
void timerEvent(QTimerEvent *event);
void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
private:
void mousePressedOP();
void mouseReleaseedOP(bool alwaysEmit, bool contansMouse);
public:
static void drawIconWithKey(QPainterPath &path, int key, const QRect &rect);
private:
bool checkable;
bool checked;
bool pressed;
bool isSmallAreaKey; // 记录是否是小键盘区域的按键
int repeatEmitTimer;
QTimer timer;
int shiftKey;
int generalKey;
static QList<XYPushButton *> allKeyBtns;
static bool capsLocked;
static bool numLocked;
static bool chinese;
static Qt::KeyboardModifiers modifiers;
friend class XYVirtualKeyboard;
};
#endif // XYPUSHBUTTON_H