File size: 2,532 Bytes
a4cf109
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#ifndef BUTTONITEM_H_VNF1QLCU
#define BUTTONITEM_H_VNF1QLCU

#include <QQuickItem>
#include <QStringList>

namespace QuickKeyboard
{

class ButtonItem: public QQuickItem
{
Q_OBJECT
Q_PROPERTY(bool pressed READ isPressed NOTIFY pressedChanged DESIGNABLE false)
Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged DESIGNABLE false)
Q_PROPERTY(bool mouseDown READ isMouseDown WRITE setMouseDown NOTIFY mouseDownChanged DESIGNABLE false)
Q_PROPERTY(bool modifier MEMBER m_modifier READ isModifier NOTIFY modifierChanged DESIGNABLE false)
Q_PROPERTY(QString label MEMBER m_label READ label NOTIFY labelChanged)
Q_PROPERTY(QStringList symbols MEMBER m_symbols READ symbols NOTIFY symbolsChanged)
Q_PROPERTY(int currentSymbolIndex MEMBER m_currentSymbolIndex WRITE setCurrentSymbolIndex NOTIFY currentSymbolIndexChanged)

// position
Q_PROPERTY(int col MEMBER m_col NOTIFY colChanged)
Q_PROPERTY(int row MEMBER m_row NOTIFY rowChanged)
Q_PROPERTY(int colSpan MEMBER m_colSpan NOTIFY colSpanChanged)
Q_PROPERTY(int rowSpan MEMBER m_rowSpan NOTIFY rowSpanChanged)
public:
	explicit ButtonItem(QQuickItem *parent = 0);
	~ButtonItem();

	bool isPressed() const { return m_active || m_mouseDown; };
	bool isActive() const { return m_active; };
	bool isMouseDown() const { return m_mouseDown; };
	bool isModifier() const { return m_modifier; };
	bool isStandard() const { return !m_modifier; };
	QString label() const { return m_label; };
	QStringList symbols() const { return m_symbols; };

	void setActive(bool active);
	void setMouseDown(bool mouseDown);
	void setCurrentSymbolIndex(int currentSymbolIndex);

signals:
	void pressedChanged(bool is_pressed);
	void activeChanged(bool is_active);
	void mouseDownChanged(bool mouseDown);
	void modifierChanged(bool is_modifier);
	void labelChanged(const QString &label);
	void symbolsChanged(const QStringList &symbols);

	void colChanged(int col);
	void rowChanged(int row);
	void colSpanChanged(int colSpan);
	void rowSpanChanged(int rowSpan);

	void currentSymbolIndexChanged(int index);
	void triggered();
	void released();
	void symbolTriggered(const QString &symbol);

private slots:
	void onSymbolsChanged();
	void onTriggered();
	void onReleased();

private:
	bool m_active;
	bool m_mouseDown;
	bool m_modifier;
	QString m_label;
	QStringList m_symbols;
	int m_col;
	int m_row;
	int m_colSpan;
	int m_rowSpan;
	int m_currentSymbolIndex;
}; /* -----  end of class ButtonItem  ----- */

} /* QuickKeyboard */

#endif /* end of include guard: BUTTONITEM_H_VNF1QLCU */