1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2017 The Qt Company Ltd. |
4 | ** Contact: http://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the Qt Quick Templates 2 module of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:LGPL3$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see http://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at http://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU Lesser General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
19 | ** General Public License version 3 as published by the Free Software |
20 | ** Foundation and appearing in the file LICENSE.LGPLv3 included in the |
21 | ** packaging of this file. Please review the following information to |
22 | ** ensure the GNU Lesser General Public License version 3 requirements |
23 | ** will be met: https://www.gnu.org/licenses/lgpl.html. |
24 | ** |
25 | ** GNU General Public License Usage |
26 | ** Alternatively, this file may be used under the terms of the GNU |
27 | ** General Public License version 2.0 or later as published by the Free |
28 | ** Software Foundation and appearing in the file LICENSE.GPL included in |
29 | ** the packaging of this file. Please review the following information to |
30 | ** ensure the GNU General Public License version 2.0 requirements will be |
31 | ** met: http://www.gnu.org/licenses/gpl-2.0.html. |
32 | ** |
33 | ** $QT_END_LICENSE$ |
34 | ** |
35 | ****************************************************************************/ |
36 | |
37 | #ifndef QQUICKABSTRACTBUTTON_P_H |
38 | #define QQUICKABSTRACTBUTTON_P_H |
39 | |
40 | // |
41 | // W A R N I N G |
42 | // ------------- |
43 | // |
44 | // This file is not part of the Qt API. It exists purely as an |
45 | // implementation detail. This header file may change from version to |
46 | // version without notice, or even be removed. |
47 | // |
48 | // We mean it. |
49 | // |
50 | |
51 | #include <QtQuickTemplates2/private/qquickcontrol_p.h> |
52 | #include <QtQuickTemplates2/private/qquickicon_p.h> |
53 | |
54 | QT_BEGIN_NAMESPACE |
55 | |
56 | class QQuickAction; |
57 | class QQuickAbstractButtonPrivate; |
58 | |
59 | class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickAbstractButton : public QQuickControl |
60 | { |
61 | Q_OBJECT |
62 | Q_PROPERTY(QString text READ text WRITE setText RESET resetText NOTIFY textChanged FINAL) |
63 | Q_PROPERTY(bool down READ isDown WRITE setDown NOTIFY downChanged RESET resetDown FINAL) |
64 | Q_PROPERTY(bool pressed READ isPressed NOTIFY pressedChanged FINAL) |
65 | Q_PROPERTY(bool checked READ isChecked WRITE setChecked NOTIFY checkedChanged FINAL) |
66 | Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable NOTIFY checkableChanged FINAL) |
67 | Q_PROPERTY(bool autoExclusive READ autoExclusive WRITE setAutoExclusive NOTIFY autoExclusiveChanged FINAL) |
68 | Q_PROPERTY(bool autoRepeat READ autoRepeat WRITE setAutoRepeat NOTIFY autoRepeatChanged FINAL) |
69 | Q_PROPERTY(QQuickItem *indicator READ indicator WRITE setIndicator NOTIFY indicatorChanged FINAL) |
70 | // 2.3 (Qt 5.10) |
71 | Q_PROPERTY(QQuickIcon icon READ icon WRITE setIcon NOTIFY iconChanged FINAL REVISION 3) |
72 | Q_PROPERTY(Display display READ display WRITE setDisplay NOTIFY displayChanged FINAL REVISION 3) |
73 | Q_PROPERTY(QQuickAction *action READ action WRITE setAction NOTIFY actionChanged FINAL REVISION 3) |
74 | // 2.4 (Qt 5.11) |
75 | Q_PROPERTY(int autoRepeatDelay READ autoRepeatDelay WRITE setAutoRepeatDelay NOTIFY autoRepeatDelayChanged FINAL REVISION 4) |
76 | Q_PROPERTY(int autoRepeatInterval READ autoRepeatInterval WRITE setAutoRepeatInterval NOTIFY autoRepeatIntervalChanged FINAL REVISION 4) |
77 | Q_PROPERTY(qreal pressX READ pressX NOTIFY pressXChanged FINAL REVISION 4) |
78 | Q_PROPERTY(qreal pressY READ pressY NOTIFY pressYChanged FINAL REVISION 4) |
79 | // 2.5 (Qt 5.12) |
80 | Q_PROPERTY(qreal implicitIndicatorWidth READ implicitIndicatorWidth NOTIFY implicitIndicatorWidthChanged FINAL REVISION 5) |
81 | Q_PROPERTY(qreal implicitIndicatorHeight READ implicitIndicatorHeight NOTIFY implicitIndicatorHeightChanged FINAL REVISION 5) |
82 | Q_CLASSINFO("DeferredPropertyNames" , "background,contentItem,indicator" ) |
83 | |
84 | public: |
85 | explicit QQuickAbstractButton(QQuickItem *parent = nullptr); |
86 | ~QQuickAbstractButton(); |
87 | |
88 | QString text() const; |
89 | void setText(const QString &text); |
90 | void resetText(); |
91 | |
92 | bool isDown() const; |
93 | void setDown(bool down); |
94 | void resetDown(); |
95 | |
96 | bool isPressed() const; |
97 | void setPressed(bool pressed); |
98 | |
99 | bool isChecked() const; |
100 | void setChecked(bool checked); |
101 | |
102 | bool isCheckable() const; |
103 | void setCheckable(bool checkable); |
104 | |
105 | bool autoExclusive() const; |
106 | void setAutoExclusive(bool exclusive); |
107 | |
108 | bool autoRepeat() const; |
109 | void setAutoRepeat(bool repeat); |
110 | |
111 | QQuickItem *indicator() const; |
112 | void setIndicator(QQuickItem *indicator); |
113 | |
114 | // 2.3 (Qt 5.10) |
115 | QQuickIcon icon() const; |
116 | void setIcon(const QQuickIcon &icon); |
117 | |
118 | enum Display { |
119 | IconOnly, |
120 | TextOnly, |
121 | TextBesideIcon, |
122 | TextUnderIcon |
123 | }; |
124 | Q_ENUM(Display) |
125 | |
126 | Display display() const; |
127 | void setDisplay(Display display); |
128 | |
129 | QQuickAction *action() const; |
130 | void setAction(QQuickAction *action); |
131 | |
132 | #if QT_CONFIG(shortcut) |
133 | QKeySequence shortcut() const; |
134 | void setShortcut(const QKeySequence &shortcut); |
135 | #endif |
136 | |
137 | // 2.4 (Qt 5.11) |
138 | int autoRepeatDelay() const; |
139 | void setAutoRepeatDelay(int delay); |
140 | |
141 | int autoRepeatInterval() const; |
142 | void setAutoRepeatInterval(int interval); |
143 | |
144 | qreal pressX() const; |
145 | qreal pressY() const; |
146 | |
147 | // 2.5 (Qt 5.12) |
148 | qreal implicitIndicatorWidth() const; |
149 | qreal implicitIndicatorHeight() const; |
150 | |
151 | public Q_SLOTS: |
152 | void toggle(); |
153 | |
154 | Q_SIGNALS: |
155 | void pressed(); |
156 | void released(); |
157 | void canceled(); |
158 | void clicked(); |
159 | void pressAndHold(); |
160 | void doubleClicked(); |
161 | void textChanged(); |
162 | void downChanged(); |
163 | void pressedChanged(); |
164 | void checkedChanged(); |
165 | void checkableChanged(); |
166 | void autoExclusiveChanged(); |
167 | void autoRepeatChanged(); |
168 | void indicatorChanged(); |
169 | // 2.2 (Qt 5.9) |
170 | Q_REVISION(2) void toggled(); |
171 | // 2.3 (Qt 5.10) |
172 | Q_REVISION(3) void iconChanged(); |
173 | Q_REVISION(3) void displayChanged(); |
174 | Q_REVISION(3) void actionChanged(); |
175 | // 2.4 (Qt 5.11) |
176 | Q_REVISION(4) void autoRepeatDelayChanged(); |
177 | Q_REVISION(4) void autoRepeatIntervalChanged(); |
178 | Q_REVISION(4) void pressXChanged(); |
179 | Q_REVISION(4) void pressYChanged(); |
180 | // 2.5 (Qt 5.12) |
181 | Q_REVISION(5) void implicitIndicatorWidthChanged(); |
182 | Q_REVISION(5) void implicitIndicatorHeightChanged(); |
183 | |
184 | protected: |
185 | QQuickAbstractButton(QQuickAbstractButtonPrivate &dd, QQuickItem *parent); |
186 | |
187 | void componentComplete() override; |
188 | |
189 | bool event(QEvent *event) override; |
190 | void focusOutEvent(QFocusEvent *event) override; |
191 | void keyPressEvent(QKeyEvent *event) override; |
192 | void keyReleaseEvent(QKeyEvent *event) override; |
193 | void mousePressEvent(QMouseEvent *event) override; |
194 | void mouseDoubleClickEvent(QMouseEvent *event) override; |
195 | void timerEvent(QTimerEvent *event) override; |
196 | |
197 | void itemChange(ItemChange change, const ItemChangeData &value) override; |
198 | |
199 | enum ButtonChange { |
200 | ButtonCheckedChange, |
201 | ButtonCheckableChange, |
202 | ButtonPressedChanged, |
203 | ButtonTextChange |
204 | }; |
205 | virtual void buttonChange(ButtonChange change); |
206 | |
207 | virtual void nextCheckState(); |
208 | |
209 | #if QT_CONFIG(accessibility) |
210 | void accessibilityActiveChanged(bool active) override; |
211 | QAccessible::Role accessibleRole() const override; |
212 | #endif |
213 | |
214 | private: |
215 | Q_DISABLE_COPY(QQuickAbstractButton) |
216 | Q_DECLARE_PRIVATE(QQuickAbstractButton) |
217 | }; |
218 | |
219 | QT_END_NAMESPACE |
220 | |
221 | QML_DECLARE_TYPE(QQuickAbstractButton) |
222 | |
223 | #endif // QQUICKABSTRACTBUTTON_P_H |
224 | |