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

source code of qtdeclarative/src/quicktemplates/qquickrangeslider_p.h