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 QQUICKSLIDER_P_H
5#define QQUICKSLIDER_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 QQuickSliderPrivate;
23
24class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickSlider : public QQuickControl
25{
26 Q_OBJECT
27 Q_PROPERTY(qreal from READ from WRITE setFrom NOTIFY fromChanged FINAL)
28 Q_PROPERTY(qreal to READ to WRITE setTo NOTIFY toChanged FINAL)
29 Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged FINAL)
30 Q_PROPERTY(qreal position READ position NOTIFY positionChanged FINAL)
31 Q_PROPERTY(qreal visualPosition READ visualPosition NOTIFY visualPositionChanged 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(bool pressed READ isPressed WRITE setPressed NOTIFY pressedChanged FINAL)
35 Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged FINAL)
36 Q_PROPERTY(QQuickItem *handle READ handle WRITE setHandle NOTIFY handleChanged FINAL)
37 Q_PROPERTY(bool live READ live WRITE setLive NOTIFY liveChanged FINAL REVISION(2, 2))
38 // 2.3 (Qt 5.10)
39 Q_PROPERTY(bool horizontal READ isHorizontal NOTIFY orientationChanged FINAL REVISION(2, 3))
40 Q_PROPERTY(bool vertical READ isVertical NOTIFY orientationChanged FINAL REVISION(2, 3))
41 // 2.5 (Qt 5.12)
42 Q_PROPERTY(qreal touchDragThreshold READ touchDragThreshold WRITE setTouchDragThreshold RESET resetTouchDragThreshold NOTIFY touchDragThresholdChanged FINAL REVISION(2, 5))
43 Q_PROPERTY(qreal implicitHandleWidth READ implicitHandleWidth NOTIFY implicitHandleWidthChanged FINAL REVISION(2, 5))
44 Q_PROPERTY(qreal implicitHandleHeight READ implicitHandleHeight NOTIFY implicitHandleHeightChanged FINAL REVISION(2, 5))
45 Q_CLASSINFO("DeferredPropertyNames", "background,handle")
46 QML_NAMED_ELEMENT(Slider)
47 QML_ADDED_IN_VERSION(2, 0)
48
49public:
50 explicit QQuickSlider(QQuickItem *parent = nullptr);
51 ~QQuickSlider();
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 qreal visualPosition() const;
64
65 qreal stepSize() const;
66 void setStepSize(qreal step);
67
68 enum SnapMode {
69 NoSnap,
70 SnapAlways,
71 SnapOnRelease
72 };
73 Q_ENUM(SnapMode)
74
75 SnapMode snapMode() const;
76 void setSnapMode(SnapMode mode);
77
78 bool isPressed() const;
79 void setPressed(bool pressed);
80
81 Qt::Orientation orientation() const;
82 void setOrientation(Qt::Orientation orientation);
83
84 QQuickItem *handle() const;
85 void setHandle(QQuickItem *handle);
86
87 // 2.1 (Qt 5.8)
88 Q_REVISION(2, 1) Q_INVOKABLE qreal valueAt(qreal position) const;
89
90 // 2.2 (Qt 5.9)
91 bool live() const;
92 void setLive(bool live);
93
94 // 2.3 (Qt 5.10)
95 bool isHorizontal() const;
96 bool isVertical() const;
97
98 // 2.5 (Qt 5.12)
99 qreal touchDragThreshold() const;
100 void setTouchDragThreshold(qreal touchDragThreshold);
101 void resetTouchDragThreshold();
102
103 qreal implicitHandleWidth() const;
104 qreal implicitHandleHeight() const;
105
106public Q_SLOTS:
107 void increase();
108 void decrease();
109
110Q_SIGNALS:
111 void fromChanged();
112 void toChanged();
113 void valueChanged();
114 void positionChanged();
115 void visualPositionChanged();
116 void stepSizeChanged();
117 void snapModeChanged();
118 void pressedChanged();
119 void orientationChanged();
120 void handleChanged();
121 // 2.2 (Qt 5.9)
122 Q_REVISION(2, 2) void moved();
123 Q_REVISION(2, 2) void liveChanged();
124 // 2.5 (Qt 5.12)
125 Q_REVISION(2, 5) void touchDragThresholdChanged();
126 Q_REVISION(2, 5) void implicitHandleWidthChanged();
127 Q_REVISION(2, 5) void implicitHandleHeightChanged();
128
129protected:
130 void keyPressEvent(QKeyEvent *event) override;
131 void keyReleaseEvent(QKeyEvent *event) override;
132 void mousePressEvent(QMouseEvent *event) override;
133#if QT_CONFIG(quicktemplates2_multitouch)
134 void touchEvent(QTouchEvent *event) override;
135#endif
136#if QT_CONFIG(wheelevent)
137 void wheelEvent(QWheelEvent *event) override;
138#endif
139
140 void mirrorChange() override;
141 void componentComplete() override;
142
143#if QT_CONFIG(accessibility)
144 void accessibilityActiveChanged(bool active) override;
145 QAccessible::Role accessibleRole() const override;
146#endif
147
148private:
149 Q_DISABLE_COPY(QQuickSlider)
150 Q_DECLARE_PRIVATE(QQuickSlider)
151};
152
153QT_END_NAMESPACE
154
155QML_DECLARE_TYPE(QQuickSlider)
156
157#endif // QQUICKSLIDER_P_H
158

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