aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2/qquickrangeslider.cpp
diff options
context:
space:
mode:
authorYulong Bai <yulong.bai@qt.io>2018-03-14 15:06:17 +0100
committerYulong Bai <yulong.bai@qt.io>2018-03-14 15:36:56 +0000
commit365059017722b32a3fe9ae7dec38d29944d6704c (patch)
tree1318668d854425b0bdc4f408974e108df0719161 /src/quicktemplates2/qquickrangeslider.cpp
parent12030ce62ef8fa0451679d19fc419ee0fa02bb6a (diff)
QQuickRangeSlider: add touchDragThreshold property
Add touchDragThreshold property for configuring the threshold to initiate a 'drag', i.e. touch move, of the handle of the slider. The mouse 'drag' won't be affected by the property. This property may be also used to configure the drag events stealing priorities of nested draggable items in the future. [ChangeLog][RangeSlider] Added touchDragThreshold property for configuring the threshold to initiate the touch 'drag' of the handle of the slider. The mouse 'drag' won't be affected by the property. Task-number: QTBUG-62784 Change-Id: I5555deb827de9d1dc7be00970fba15001105e419 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquickrangeslider.cpp')
-rw-r--r--src/quicktemplates2/qquickrangeslider.cpp38
1 files changed, 36 insertions, 2 deletions
diff --git a/src/quicktemplates2/qquickrangeslider.cpp b/src/quicktemplates2/qquickrangeslider.cpp
index 36d8ca02..a33bddc5 100644
--- a/src/quicktemplates2/qquickrangeslider.cpp
+++ b/src/quicktemplates2/qquickrangeslider.cpp
@@ -358,6 +358,7 @@ public:
from(defaultFrom),
to(defaultTo),
stepSize(0),
+ touchDragThreshold(-1),
first(nullptr),
second(nullptr),
orientation(Qt::Horizontal),
@@ -381,6 +382,7 @@ public:
qreal from;
qreal to;
qreal stepSize;
+ qreal touchDragThreshold;
QQuickRangeSliderNode *first;
QQuickRangeSliderNode *second;
QPointF pressPoint;
@@ -647,6 +649,38 @@ void QQuickRangeSlider::setTo(qreal to)
}
/*!
+ \since QtQuick.Controls 2.5 (Qt 5.12)
+ \qmlproperty qreal QtQuick.Controls::RangeSlider::touchDragThreshold
+
+ This property holds the threshold (in logical pixels) at which a touch drag event will be initiated.
+ The mouse drag threshold won't be affected.
+ The default value is \c Qt.styleHints.startDragDistance.
+
+ \sa QStyleHints
+
+*/
+qreal QQuickRangeSlider::touchDragThreshold() const
+{
+ Q_D(const QQuickRangeSlider);
+ return d->touchDragThreshold;
+}
+
+void QQuickRangeSlider::setTouchDragThreshold(qreal touchDragThreshold)
+{
+ Q_D(QQuickRangeSlider);
+ if (d->touchDragThreshold == touchDragThreshold)
+ return;
+
+ d->touchDragThreshold = touchDragThreshold;
+ emit touchDragThresholdChanged();
+}
+
+void QQuickRangeSlider::resetTouchDragThreshold()
+{
+ setTouchDragThreshold(-1);
+}
+
+/*!
\qmlpropertygroup QtQuick.Controls::RangeSlider::first
\qmlproperty real QtQuick.Controls::RangeSlider::first.value
\qmlproperty real QtQuick.Controls::RangeSlider::first.position
@@ -1067,9 +1101,9 @@ void QQuickRangeSlider::touchEvent(QTouchEvent *event)
case Qt::TouchPointMoved:
if (!keepTouchGrab()) {
if (d->orientation == Qt::Horizontal)
- setKeepTouchGrab(QQuickWindowPrivate::dragOverThreshold(point.pos().x() - point.startPos().x(), Qt::XAxis, &point));
+ setKeepTouchGrab(QQuickWindowPrivate::dragOverThreshold(point.pos().x() - point.startPos().x(), Qt::XAxis, &point, qRound(d->touchDragThreshold)));
else
- setKeepTouchGrab(QQuickWindowPrivate::dragOverThreshold(point.pos().y() - point.startPos().y(), Qt::YAxis, &point));
+ setKeepTouchGrab(QQuickWindowPrivate::dragOverThreshold(point.pos().y() - point.startPos().y(), Qt::YAxis, &point, qRound(d->touchDragThreshold)));
}
if (keepTouchGrab())
d->handleMove(point.pos());