aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2/qquickrangeslider.cpp
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-10-05 15:36:31 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2016-10-06 08:40:05 +0000
commit405ef2c0524e6b9b0236bc5d7c0e6e5ed5c82fe8 (patch)
tree6567e68b8eba596418d2aebf4917541eed1130b6 /src/quicktemplates2/qquickrangeslider.cpp
parent47736b3510696ad3fdff1e9460938f29435261f2 (diff)
Add QQuickRangeSlider::live
[ChangeLog][Controls][RangeSlider] Added a live-property that determines whether the range slider provides live updates for the first.value and second.value properties while the respective handle is dragged. Change-Id: I44d1924078969a5e22aca55625967dd8b5a4abac Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquickrangeslider.cpp')
-rw-r--r--src/quicktemplates2/qquickrangeslider.cpp46
1 files changed, 41 insertions, 5 deletions
diff --git a/src/quicktemplates2/qquickrangeslider.cpp b/src/quicktemplates2/qquickrangeslider.cpp
index 34654fe1..fb518b69 100644
--- a/src/quicktemplates2/qquickrangeslider.cpp
+++ b/src/quicktemplates2/qquickrangeslider.cpp
@@ -313,6 +313,7 @@ class QQuickRangeSliderPrivate : public QQuickControlPrivate
public:
QQuickRangeSliderPrivate() :
+ live(false),
from(defaultFrom),
to(defaultTo),
stepSize(0),
@@ -325,6 +326,7 @@ public:
void updateHover(const QPointF &pos);
+ bool live;
qreal from;
qreal to;
qreal stepSize;
@@ -471,8 +473,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
@@ -533,8 +537,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
@@ -651,6 +657,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.
@@ -868,7 +901,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);
}
}
}