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 QQUICKSLIDER_P_H |
38 | #define QQUICKSLIDER_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 | |
53 | QT_BEGIN_NAMESPACE |
54 | |
55 | class QQuickSliderPrivate; |
56 | |
57 | class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickSlider : public QQuickControl |
58 | { |
59 | Q_OBJECT |
60 | Q_PROPERTY(qreal from READ from WRITE setFrom NOTIFY fromChanged FINAL) |
61 | Q_PROPERTY(qreal to READ to WRITE setTo NOTIFY toChanged FINAL) |
62 | Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged FINAL) |
63 | Q_PROPERTY(qreal position READ position NOTIFY positionChanged FINAL) |
64 | Q_PROPERTY(qreal visualPosition READ visualPosition NOTIFY visualPositionChanged FINAL) |
65 | Q_PROPERTY(qreal stepSize READ stepSize WRITE setStepSize NOTIFY stepSizeChanged FINAL) |
66 | Q_PROPERTY(SnapMode snapMode READ snapMode WRITE setSnapMode NOTIFY snapModeChanged FINAL) |
67 | Q_PROPERTY(bool pressed READ isPressed WRITE setPressed NOTIFY pressedChanged FINAL) |
68 | Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged FINAL) |
69 | Q_PROPERTY(QQuickItem *handle READ handle WRITE setHandle NOTIFY handleChanged FINAL) |
70 | Q_PROPERTY(bool live READ live WRITE setLive NOTIFY liveChanged FINAL REVISION 2) |
71 | // 2.3 (Qt 5.10) |
72 | Q_PROPERTY(bool horizontal READ isHorizontal NOTIFY orientationChanged FINAL REVISION 3) |
73 | Q_PROPERTY(bool vertical READ isVertical NOTIFY orientationChanged FINAL REVISION 3) |
74 | // 2.5 (Qt 5.12) |
75 | Q_PROPERTY(qreal touchDragThreshold READ touchDragThreshold WRITE setTouchDragThreshold RESET resetTouchDragThreshold NOTIFY touchDragThresholdChanged FINAL REVISION 5) |
76 | Q_PROPERTY(qreal implicitHandleWidth READ implicitHandleWidth NOTIFY implicitHandleWidthChanged FINAL REVISION 5) |
77 | Q_PROPERTY(qreal implicitHandleHeight READ implicitHandleHeight NOTIFY implicitHandleHeightChanged FINAL REVISION 5) |
78 | Q_CLASSINFO("DeferredPropertyNames" , "background,handle" ) |
79 | |
80 | public: |
81 | explicit QQuickSlider(QQuickItem *parent = nullptr); |
82 | ~QQuickSlider(); |
83 | |
84 | qreal from() const; |
85 | void setFrom(qreal from); |
86 | |
87 | qreal to() const; |
88 | void setTo(qreal to); |
89 | |
90 | qreal value() const; |
91 | void setValue(qreal value); |
92 | |
93 | qreal position() const; |
94 | qreal visualPosition() const; |
95 | |
96 | qreal stepSize() const; |
97 | void setStepSize(qreal step); |
98 | |
99 | enum SnapMode { |
100 | NoSnap, |
101 | SnapAlways, |
102 | SnapOnRelease |
103 | }; |
104 | Q_ENUM(SnapMode) |
105 | |
106 | SnapMode snapMode() const; |
107 | void setSnapMode(SnapMode mode); |
108 | |
109 | bool isPressed() const; |
110 | void setPressed(bool pressed); |
111 | |
112 | Qt::Orientation orientation() const; |
113 | void setOrientation(Qt::Orientation orientation); |
114 | |
115 | QQuickItem *handle() const; |
116 | void setHandle(QQuickItem *handle); |
117 | |
118 | // 2.1 (Qt 5.8) |
119 | Q_REVISION(1) Q_INVOKABLE qreal valueAt(qreal position) const; |
120 | |
121 | // 2.2 (Qt 5.9) |
122 | bool live() const; |
123 | void setLive(bool live); |
124 | |
125 | // 2.3 (Qt 5.10) |
126 | bool isHorizontal() const; |
127 | bool isVertical() const; |
128 | |
129 | // 2.5 (Qt 5.12) |
130 | qreal touchDragThreshold() const; |
131 | void setTouchDragThreshold(qreal touchDragThreshold); |
132 | void resetTouchDragThreshold(); |
133 | |
134 | qreal implicitHandleWidth() const; |
135 | qreal implicitHandleHeight() const; |
136 | |
137 | public Q_SLOTS: |
138 | void increase(); |
139 | void decrease(); |
140 | |
141 | Q_SIGNALS: |
142 | void fromChanged(); |
143 | void toChanged(); |
144 | void valueChanged(); |
145 | void positionChanged(); |
146 | void visualPositionChanged(); |
147 | void stepSizeChanged(); |
148 | void snapModeChanged(); |
149 | void pressedChanged(); |
150 | void orientationChanged(); |
151 | void handleChanged(); |
152 | // 2.2 (Qt 5.9) |
153 | Q_REVISION(2) void moved(); |
154 | Q_REVISION(2) void liveChanged(); |
155 | // 2.5 (Qt 5.12) |
156 | Q_REVISION(5) void touchDragThresholdChanged(); |
157 | Q_REVISION(5) void implicitHandleWidthChanged(); |
158 | Q_REVISION(5) void implicitHandleHeightChanged(); |
159 | |
160 | protected: |
161 | void keyPressEvent(QKeyEvent *event) override; |
162 | void keyReleaseEvent(QKeyEvent *event) override; |
163 | void mousePressEvent(QMouseEvent *event) override; |
164 | #if QT_CONFIG(quicktemplates2_multitouch) |
165 | void touchEvent(QTouchEvent *event) override; |
166 | #endif |
167 | #if QT_CONFIG(wheelevent) |
168 | void wheelEvent(QWheelEvent *event) override; |
169 | #endif |
170 | |
171 | void mirrorChange() override; |
172 | void componentComplete() override; |
173 | |
174 | #if QT_CONFIG(accessibility) |
175 | void accessibilityActiveChanged(bool active) override; |
176 | QAccessible::Role accessibleRole() const override; |
177 | #endif |
178 | |
179 | private: |
180 | Q_DISABLE_COPY(QQuickSlider) |
181 | Q_DECLARE_PRIVATE(QQuickSlider) |
182 | }; |
183 | |
184 | QT_END_NAMESPACE |
185 | |
186 | QML_DECLARE_TYPE(QQuickSlider) |
187 | |
188 | #endif // QQUICKSLIDER_P_H |
189 | |