1 | // Copyright (C) 2017 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #ifndef QQUICKDIAL_P_H |
5 | #define QQUICKDIAL_P_H |
6 | |
7 | // |
8 | // W A R N I N G |
9 | // ------------- |
10 | // |
11 | // This file is not part of the Qt API. It exists purely as an |
12 | // implementation detail. This header file may change from version to |
13 | // version without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | |
18 | #include <QtCore/qvariant.h> |
19 | #include <QtQml/qqmlcomponent.h> |
20 | #include <QtQuickTemplates2/private/qquickcontrol_p.h> |
21 | |
22 | QT_BEGIN_NAMESPACE |
23 | |
24 | class QQuickDialAttached; |
25 | class QQuickDialPrivate; |
26 | |
27 | class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickDial : public QQuickControl |
28 | { |
29 | Q_OBJECT |
30 | Q_PROPERTY(qreal from READ from WRITE setFrom NOTIFY fromChanged FINAL) |
31 | Q_PROPERTY(qreal to READ to WRITE setTo NOTIFY toChanged FINAL) |
32 | Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged FINAL) |
33 | Q_PROPERTY(qreal position READ position NOTIFY positionChanged FINAL) |
34 | Q_PROPERTY(qreal angle READ angle NOTIFY angleChanged FINAL) |
35 | Q_PROPERTY(qreal startAngle READ startAngle WRITE setStartAngle NOTIFY startAngleChanged FINAL REVISION(6, 6)) |
36 | Q_PROPERTY(qreal endAngle READ endAngle WRITE setEndAngle NOTIFY endAngleChanged FINAL REVISION(6, 6)) |
37 | Q_PROPERTY(qreal stepSize READ stepSize WRITE setStepSize NOTIFY stepSizeChanged FINAL) |
38 | Q_PROPERTY(SnapMode snapMode READ snapMode WRITE setSnapMode NOTIFY snapModeChanged FINAL) |
39 | Q_PROPERTY(bool wrap READ wrap WRITE setWrap NOTIFY wrapChanged FINAL) |
40 | Q_PROPERTY(bool pressed READ isPressed NOTIFY pressedChanged FINAL) |
41 | Q_PROPERTY(QQuickItem *handle READ handle WRITE setHandle NOTIFY handleChanged FINAL) |
42 | // 2.2 (Qt 5.9) |
43 | Q_PROPERTY(bool live READ live WRITE setLive NOTIFY liveChanged FINAL REVISION(2, 2)) |
44 | // 2.5 (Qt 5.12) |
45 | Q_PROPERTY(InputMode inputMode READ inputMode WRITE setInputMode NOTIFY inputModeChanged FINAL REVISION(2, 5)) |
46 | Q_CLASSINFO("DeferredPropertyNames" , "background,handle" ) |
47 | QML_NAMED_ELEMENT(Dial) |
48 | QML_ADDED_IN_VERSION(2, 0) |
49 | |
50 | public: |
51 | explicit QQuickDial(QQuickItem *parent = nullptr); |
52 | |
53 | qreal from() const; |
54 | void setFrom(qreal from); |
55 | |
56 | qreal to() const; |
57 | void setTo(qreal to); |
58 | |
59 | qreal value() const; |
60 | void setValue(qreal value); |
61 | |
62 | qreal position() const; |
63 | |
64 | qreal angle() const; |
65 | |
66 | qreal stepSize() const; |
67 | void setStepSize(qreal step); |
68 | |
69 | qreal startAngle() const; |
70 | void setStartAngle(qreal startAngle); |
71 | |
72 | qreal endAngle() const; |
73 | void setEndAngle(qreal endAngle); |
74 | |
75 | enum SnapMode { |
76 | NoSnap, |
77 | SnapAlways, |
78 | SnapOnRelease |
79 | }; |
80 | Q_ENUM(SnapMode) |
81 | |
82 | SnapMode snapMode() const; |
83 | void setSnapMode(SnapMode mode); |
84 | |
85 | enum InputMode { |
86 | Circular, |
87 | Horizontal, |
88 | Vertical, |
89 | }; |
90 | Q_ENUM(InputMode) |
91 | |
92 | enum WrapDirection { |
93 | Clockwise, |
94 | CounterClockwise |
95 | }; |
96 | Q_ENUM(WrapDirection) |
97 | |
98 | bool wrap() const; |
99 | void setWrap(bool wrap); |
100 | |
101 | bool isPressed() const; |
102 | void setPressed(bool pressed); |
103 | |
104 | QQuickItem *handle() const; |
105 | void setHandle(QQuickItem *handle); |
106 | |
107 | // 2.2 (Qt 5.9) |
108 | bool live() const; |
109 | void setLive(bool live); |
110 | |
111 | // 2.5 (Qt 5.12) |
112 | InputMode inputMode() const; |
113 | void setInputMode(InputMode mode); |
114 | |
115 | public Q_SLOTS: |
116 | void increase(); |
117 | void decrease(); |
118 | |
119 | Q_SIGNALS: |
120 | void fromChanged(); |
121 | void toChanged(); |
122 | void valueChanged(); |
123 | void positionChanged(); |
124 | void angleChanged(); |
125 | void stepSizeChanged(); |
126 | void snapModeChanged(); |
127 | void wrapChanged(); |
128 | void pressedChanged(); |
129 | void handleChanged(); |
130 | // 2.2 (Qt 5.9) |
131 | Q_REVISION(2, 2) void moved(); |
132 | Q_REVISION(2, 2) void liveChanged(); |
133 | // 2.5 (Qt 5.12) |
134 | Q_REVISION(2, 5) void inputModeChanged(); |
135 | Q_REVISION(6, 6) void startAngleChanged(); |
136 | Q_REVISION(6, 6) void endAngleChanged(); |
137 | Q_REVISION(6, 6) void wrapped(WrapDirection); |
138 | |
139 | protected: |
140 | void keyPressEvent(QKeyEvent *event) override; |
141 | void keyReleaseEvent(QKeyEvent *event) override; |
142 | void mousePressEvent(QMouseEvent *event) override; |
143 | #if QT_CONFIG(quicktemplates2_multitouch) |
144 | void touchEvent(QTouchEvent *event) override; |
145 | #endif |
146 | #if QT_CONFIG(wheelevent) |
147 | void wheelEvent(QWheelEvent *event) override; |
148 | #endif |
149 | |
150 | void mirrorChange() override; |
151 | void componentComplete() override; |
152 | |
153 | #if QT_CONFIG(accessibility) |
154 | void accessibilityActiveChanged(bool active) override; |
155 | QAccessible::Role accessibleRole() const override; |
156 | #endif |
157 | |
158 | private: |
159 | Q_DISABLE_COPY(QQuickDial) |
160 | Q_DECLARE_PRIVATE(QQuickDial) |
161 | }; |
162 | |
163 | QT_END_NAMESPACE |
164 | |
165 | QML_DECLARE_TYPE(QQuickDial) |
166 | |
167 | #endif // QQUICKDIAL_P_H |
168 | |