3#include "qml_material/control/control.hpp"
9class QML_MATERIAL_API Slider :
public Control {
11 QML_NAMED_ELEMENT(SliderBase)
12 Q_PROPERTY(qreal from READ from WRITE setFrom NOTIFY fromChanged FINAL)
13 Q_PROPERTY(qreal to READ to WRITE setTo NOTIFY toChanged FINAL)
14 Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged FINAL)
15 Q_PROPERTY(qreal position READ position NOTIFY positionChanged FINAL)
16 Q_PROPERTY(qreal visualPosition READ visualPosition NOTIFY visualPositionChanged FINAL)
17 Q_PROPERTY(qreal stepSize READ stepSize WRITE setStepSize NOTIFY stepSizeChanged FINAL)
18 Q_PROPERTY(SnapMode snapMode READ snapMode WRITE setSnapMode NOTIFY snapModeChanged FINAL)
19 Q_PROPERTY(
bool pressed READ pressed WRITE setPressed NOTIFY pressedChanged FINAL)
20 Q_PROPERTY(
bool live READ live WRITE setLive NOTIFY liveChanged FINAL)
22 bool wheelEnabled READ wheelEnabled WRITE setWheelEnabled NOTIFY wheelEnabledChanged FINAL)
23 Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation NOTIFY
24 orientationChanged FINAL)
25 Q_PROPERTY(
bool horizontal READ horizontal NOTIFY orientationChanged FINAL)
26 Q_PROPERTY(
bool vertical READ vertical NOTIFY orientationChanged FINAL)
27 Q_PROPERTY(QQuickItem* handle READ handle WRITE setHandle NOTIFY handleChanged FINAL)
29 qreal implicitHandleWidth READ implicitHandleWidth NOTIFY implicitHandleWidthChanged FINAL)
30 Q_PROPERTY(qreal implicitHandleHeight READ implicitHandleHeight NOTIFY
31 implicitHandleHeightChanged FINAL)
32 Q_PROPERTY(qreal touchDragThreshold READ touchDragThreshold WRITE setTouchDragThreshold RESET
33 resetTouchDragThreshold NOTIFY touchDragThresholdChanged FINAL)
42 explicit Slider(QQuickItem* parent =
nullptr);
44 qreal from()
const {
return m_from; }
45 qreal to()
const {
return m_to; }
46 qreal value()
const {
return m_value; }
47 qreal position()
const {
return m_position; }
48 qreal visualPosition()
const {
return vertical() || mirrored() ? 1 - m_position : m_position; }
49 qreal stepSize()
const {
return m_step; }
50 SnapMode snapMode()
const {
return m_snap; }
51 bool pressed()
const {
return m_pressed; }
52 QBindable<bool> bindablePressed() {
return QBindable<bool>(&m_pressed); }
53 bool live()
const {
return m_live; }
54 bool wheelEnabled()
const {
return m_wheel_enabled; }
55 Qt::Orientation orientation()
const {
return m_orientation; }
56 bool horizontal()
const {
return m_orientation == Qt::Horizontal; }
57 bool vertical()
const {
return m_orientation == Qt::Vertical; }
58 QQuickItem* handle()
const {
return m_handle; }
59 qreal implicitHandleWidth()
const;
60 qreal implicitHandleHeight()
const;
61 qreal touchDragThreshold()
const {
return m_touch_threshold; }
65 void setStepSize(qreal);
66 void setSnapMode(SnapMode);
67 void setPressed(
bool);
69 void setWheelEnabled(
bool);
70 void setOrientation(Qt::Orientation);
71 void setHandle(QQuickItem*);
72 void setTouchDragThreshold(qreal);
73 void resetTouchDragThreshold();
74 Q_INVOKABLE qreal valueAt(qreal position)
const;
75 Q_INVOKABLE
void increase();
76 Q_INVOKABLE
void decrease();
77 Q_SIGNAL
void fromChanged();
78 Q_SIGNAL
void toChanged();
79 Q_SIGNAL
void valueChanged();
80 Q_SIGNAL
void positionChanged();
81 Q_SIGNAL
void visualPositionChanged();
82 Q_SIGNAL
void stepSizeChanged();
83 Q_SIGNAL
void snapModeChanged();
84 Q_SIGNAL
void pressedChanged();
85 Q_SIGNAL
void liveChanged();
86 Q_SIGNAL
void wheelEnabledChanged();
87 Q_SIGNAL
void orientationChanged();
88 Q_SIGNAL
void handleChanged();
89 Q_SIGNAL
void implicitHandleWidthChanged();
90 Q_SIGNAL
void implicitHandleHeightChanged();
91 Q_SIGNAL
void touchDragThresholdChanged();
92 Q_SIGNAL
void moved();
95 void componentComplete()
override;
96 void mousePressEvent(QMouseEvent*)
override;
97 void mouseMoveEvent(QMouseEvent*)
override;
98 void mouseReleaseEvent(QMouseEvent*)
override;
99 void mouseUngrabEvent()
override;
100 void touchEvent(QTouchEvent*)
override;
101 void touchUngrabEvent()
override;
102 void keyPressEvent(QKeyEvent*)
override;
103 void keyReleaseEvent(QKeyEvent*)
override;
104 void wheelEvent(QWheelEvent*)
override;
105 void focusOutEvent(QFocusEvent*)
override;
106 void itemChange(ItemChange,
const ItemChangeData&)
override;
116 void setPosition(qreal);
117 void updatePressed(
bool);
118 void updatePosition();
119 qreal positionAt(
const QPointF&)
const;
120 qreal snapPosition(qreal)
const;
121 void moveTo(
const QPointF&,
bool release);
123 void observeWindow();
124 qreal m_from = 0, m_to = 1, m_value = 0, m_position = 0, m_step = 0;
125 qreal m_touch_threshold = -1;
126 Qt::Orientation m_orientation = Qt::Horizontal;
127 SnapMode m_snap = NoSnap;
128 Q_OBJECT_BINDABLE_PROPERTY_WITH_ARGS(Slider,
bool, m_pressed,
false)
129 QPropertyNotifier m_pressedNotifier;
130 bool m_live = true, m_wheel_enabled = false;
131 Input m_input = Input::None;
132 int m_touch_id = -1, m_key = 0;
133 QPointF m_press_point;
134 QPointer<QQuickItem> m_handle;
135 QList<QMetaObject::Connection> m_handle_connections;
136 QMetaObject::Connection m_window_connection;
137 quint64 m_sequence = 0;