diff options
Diffstat (limited to 'src/quicktemplates2/qquickrangeslider.cpp')
-rw-r--r-- | src/quicktemplates2/qquickrangeslider.cpp | 46 |
1 files changed, 41 insertions, 5 deletions
diff --git a/src/quicktemplates2/qquickrangeslider.cpp b/src/quicktemplates2/qquickrangeslider.cpp index 2f2b621c..cd6395bd 100644 --- a/src/quicktemplates2/qquickrangeslider.cpp +++ b/src/quicktemplates2/qquickrangeslider.cpp @@ -316,6 +316,7 @@ class QQuickRangeSliderPrivate : public QQuickControlPrivate public: QQuickRangeSliderPrivate() : + live(false), from(defaultFrom), to(defaultTo), stepSize(0), @@ -328,6 +329,7 @@ public: void updateHover(const QPointF &pos); + bool live; qreal from; qreal to; qreal stepSize; @@ -474,8 +476,10 @@ void QQuickRangeSlider::setTo(qreal to) If \l to is greater than \l from, the value of the first handle must be greater than the second, and vice versa. - Unlike \l {first.position}{position}, value is not updated while the - handle is dragged, but rather when it has been released. + Unlike \l {first.position}{position}, value is not updated by default + while the handle is dragged, but rather when it has been released. The + \l live property can be used to make the slider provide live updates + for value. The default value is \c 0.0. \row @@ -536,8 +540,10 @@ QQuickRangeSliderNode *QQuickRangeSlider::first() const If \l to is greater than \l from, the value of the first handle must be greater than the second, and vice versa. - Unlike \l {second.position}{position}, value is not updated while the - handle is dragged, but rather when it has been released. + Unlike \l {second.position}{position}, value is not updated by default + while the handle is dragged, but rather when it has been released. The + \l live property can be used to make the slider provide live updates + for value. The default value is \c 0.0. \row @@ -657,6 +663,33 @@ void QQuickRangeSlider::setOrientation(Qt::Orientation orientation) } /*! + \since QtQuick.Controls 2.2 + \qmlproperty bool QtQuick.Controls::RangeSlider::live + + This property holds whether the slider provides live updates for the \l first.value + and \l second.value properties while the respective handles are dragged. + + The default value is \c false. + + \sa first.value, second.value +*/ +bool QQuickRangeSlider::live() const +{ + Q_D(const QQuickRangeSlider); + return d->live; +} + +void QQuickRangeSlider::setLive(bool live) +{ + Q_D(QQuickRangeSlider); + if (d->live == live) + return; + + d->live = live; + emit liveChanged(); +} + +/*! \qmlmethod void QtQuick.Controls::RangeSlider::setValues(real firstValue, real secondValue) Sets \l first.value and \l second.value with the given arguments. @@ -874,7 +907,10 @@ void QQuickRangeSlider::mouseMoveEvent(QMouseEvent *event) qreal pos = positionAt(this, pressedNode->handle(), event->pos()); if (d->snapMode == SnapAlways) pos = snapPosition(this, pos); - QQuickRangeSliderNodePrivate::get(pressedNode)->setPosition(pos); + if (d->live) + pressedNode->setValue(valueAt(this, pos)); + else + QQuickRangeSliderNodePrivate::get(pressedNode)->setPosition(pos); } } } |