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 QQUICKRANGESLIDER_P_H
38#define QQUICKRANGESLIDER_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
53QT_BEGIN_NAMESPACE
54
55class QQuickRangeSliderPrivate;
56class QQuickRangeSliderNode;
57
58class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickRangeSlider : public QQuickControl
59{
60 Q_OBJECT
61 Q_PROPERTY(qreal from READ from WRITE setFrom NOTIFY fromChanged FINAL)
62 Q_PROPERTY(qreal to READ to WRITE setTo NOTIFY toChanged FINAL)
63 Q_PROPERTY(QQuickRangeSliderNode *first READ first CONSTANT FINAL)
64 Q_PROPERTY(QQuickRangeSliderNode *second READ second CONSTANT 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(Qt::Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged FINAL)
68 // 2.2 (Qt 5.9)
69 Q_PROPERTY(bool live READ live WRITE setLive NOTIFY liveChanged FINAL REVISION 2)
70 Q_PROPERTY(bool horizontal READ isHorizontal NOTIFY orientationChanged FINAL REVISION 3)
71 // 2.3 (Qt 5.10)
72 Q_PROPERTY(bool vertical READ isVertical NOTIFY orientationChanged FINAL REVISION 3)
73 // 2.5 (Qt 5.12)
74 Q_PROPERTY(qreal touchDragThreshold READ touchDragThreshold WRITE setTouchDragThreshold RESET resetTouchDragThreshold NOTIFY touchDragThresholdChanged FINAL REVISION 5)
75
76public:
77 explicit QQuickRangeSlider(QQuickItem *parent = nullptr);
78 ~QQuickRangeSlider();
79
80 qreal from() const;
81 void setFrom(qreal from);
82
83 qreal to() const;
84 void setTo(qreal to);
85
86 QQuickRangeSliderNode *first() const;
87 QQuickRangeSliderNode *second() const;
88
89 qreal stepSize() const;
90 void setStepSize(qreal step);
91
92 enum SnapMode {
93 NoSnap,
94 SnapAlways,
95 SnapOnRelease
96 };
97 Q_ENUM(SnapMode)
98
99 SnapMode snapMode() const;
100 void setSnapMode(SnapMode mode);
101
102 Qt::Orientation orientation() const;
103 void setOrientation(Qt::Orientation orientation);
104
105 Q_INVOKABLE void setValues(qreal firstValue, qreal secondValue);
106
107 // 2.2 (Qt 5.9)
108 bool live() const;
109 void setLive(bool live);
110
111 // 2.3 (Qt 5.10)
112 bool isHorizontal() const;
113 bool isVertical() const;
114
115 // 2.5 (Qt 5.12)
116 qreal touchDragThreshold() const;
117 void setTouchDragThreshold(qreal touchDragThreshold);
118 void resetTouchDragThreshold();
119 Q_REVISION(5) Q_INVOKABLE qreal valueAt(qreal position) const;
120
121Q_SIGNALS:
122 void fromChanged();
123 void toChanged();
124 void stepSizeChanged();
125 void snapModeChanged();
126 void orientationChanged();
127 // 2.2 (Qt 5.9)
128 Q_REVISION(2) void liveChanged();
129 // 2.5 (Qt 5.12)
130 Q_REVISION(5) void touchDragThresholdChanged();
131
132protected:
133 void focusInEvent(QFocusEvent *event) override;
134 void hoverEnterEvent(QHoverEvent *event) override;
135 void hoverMoveEvent(QHoverEvent *event) override;
136 void hoverLeaveEvent(QHoverEvent *event) override;
137 void keyPressEvent(QKeyEvent *event) override;
138 void keyReleaseEvent(QKeyEvent *event) override;
139 void mousePressEvent(QMouseEvent *event) override;
140#if QT_CONFIG(quicktemplates2_multitouch)
141 void touchEvent(QTouchEvent *event) override;
142#endif
143 void mirrorChange() override;
144 void classBegin() override;
145 void componentComplete() override;
146
147#if QT_CONFIG(accessibility)
148 QAccessible::Role accessibleRole() const override;
149#endif
150
151private:
152 friend class QQuickRangeSliderNode;
153
154 Q_DISABLE_COPY(QQuickRangeSlider)
155 Q_DECLARE_PRIVATE(QQuickRangeSlider)
156};
157
158class QQuickRangeSliderNodePrivate;
159
160class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickRangeSliderNode : public QObject
161{
162 Q_OBJECT
163 Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged FINAL)
164 Q_PROPERTY(qreal position READ position NOTIFY positionChanged FINAL)
165 Q_PROPERTY(qreal visualPosition READ visualPosition NOTIFY visualPositionChanged FINAL)
166 Q_PROPERTY(QQuickItem *handle READ handle WRITE setHandle NOTIFY handleChanged FINAL)
167 Q_PROPERTY(bool pressed READ isPressed WRITE setPressed NOTIFY pressedChanged FINAL)
168 // 2.1 (Qt 5.8)
169 Q_PROPERTY(bool hovered READ isHovered WRITE setHovered NOTIFY hoveredChanged FINAL REVISION 1)
170 // 2.5 (Qt 5.12)
171 Q_PROPERTY(qreal implicitHandleWidth READ implicitHandleWidth NOTIFY implicitHandleWidthChanged FINAL REVISION 5)
172 Q_PROPERTY(qreal implicitHandleHeight READ implicitHandleHeight NOTIFY implicitHandleHeightChanged FINAL REVISION 5)
173 Q_CLASSINFO("DeferredPropertyNames", "handle")
174
175public:
176 explicit QQuickRangeSliderNode(qreal value, QQuickRangeSlider *slider);
177 ~QQuickRangeSliderNode();
178
179 qreal value() const;
180 void setValue(qreal value);
181
182 qreal position() const;
183 qreal visualPosition() const;
184
185 QQuickItem *handle() const;
186 void setHandle(QQuickItem *handle);
187
188 bool isPressed() const;
189 void setPressed(bool pressed);
190
191 // 2.1 (Qt 5.8)
192 bool isHovered() const;
193 void setHovered(bool hovered);
194
195 // 2.5 (Qt 5.12)
196 qreal implicitHandleWidth() const;
197 qreal implicitHandleHeight() const;
198
199public Q_SLOTS:
200 void increase();
201 void decrease();
202
203Q_SIGNALS:
204 void valueChanged();
205 void positionChanged();
206 void visualPositionChanged();
207 void handleChanged();
208 void pressedChanged();
209 // 2.1 (Qt 5.8)
210 Q_REVISION(1) void hoveredChanged();
211 // 2.5 (Qt 5.12)
212 /*Q_REVISION(5)*/ void moved();
213 /*Q_REVISION(5)*/ void implicitHandleWidthChanged();
214 /*Q_REVISION(5)*/ void implicitHandleHeightChanged();
215
216private:
217 Q_DISABLE_COPY(QQuickRangeSliderNode)
218 Q_DECLARE_PRIVATE(QQuickRangeSliderNode)
219};
220
221QT_END_NAMESPACE
222
223QML_DECLARE_TYPE(QQuickRangeSlider)
224
225#endif // QQUICKRANGESLIDER_P_H
226

source code of qtquickcontrols2/src/quicktemplates2/qquickrangeslider_p.h