aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2/qquickslider.cpp
diff options
context:
space:
mode:
authorYulong Bai <yulong.bai@qt.io>2018-03-02 14:31:36 +0100
committerYulong Bai <yulong.bai@qt.io>2018-03-12 12:08:24 +0000
commitb6dbfe623ab6df58ccb7bf8a922eb853fc10155a (patch)
tree0b50cbc8f30246fa96b0ee7b49273172cfd0d826 /src/quicktemplates2/qquickslider.cpp
parent41dd1405d5c5bfac05f9c42a4c4017de5075f5cc (diff)
QQuickSlider: 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][Slider] 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: Ifaeea4653b48c44efbe7e1cb09d399a91359c16a Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquickslider.cpp')
-rw-r--r--src/quicktemplates2/qquickslider.cpp37
1 files changed, 35 insertions, 2 deletions
diff --git a/src/quicktemplates2/qquickslider.cpp b/src/quicktemplates2/qquickslider.cpp
index ef2077af..9b922215 100644
--- a/src/quicktemplates2/qquickslider.cpp
+++ b/src/quicktemplates2/qquickslider.cpp
@@ -95,6 +95,7 @@ public:
value(0),
position(0),
stepSize(0),
+ touchDragThreshold(-1), // in QQuickWindowPrivate::dragOverThreshold, '-1' implies using styleHints::startDragDistance()
live(true),
pressed(false),
orientation(Qt::Horizontal),
@@ -121,6 +122,7 @@ public:
qreal value;
qreal position;
qreal stepSize;
+ qreal touchDragThreshold;
bool live;
bool pressed;
QPointF pressPoint;
@@ -636,6 +638,37 @@ void QQuickSlider::decrease()
setValue(d->value - step);
}
+/*!
+ \since QtQuick.Controls 2.5 (Qt 5.12)
+ \qmlproperty qreal QtQuick.Controls::Slider::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 QQuickSlider::touchDragThreshold() const
+{
+ Q_D(const QQuickSlider);
+ return d->touchDragThreshold;
+}
+
+void QQuickSlider::setTouchDragThreshold(qreal touchDragThreshold)
+{
+ Q_D(QQuickSlider);
+ if (d->touchDragThreshold == touchDragThreshold)
+ return;
+
+ d->touchDragThreshold = touchDragThreshold;
+ emit touchDragThresholdChanged();
+}
+
+void QQuickSlider::resetTouchDragThreshold()
+{
+ setTouchDragThreshold(-1);
+}
+
void QQuickSlider::keyPressEvent(QKeyEvent *event)
{
Q_D(QQuickSlider);
@@ -715,9 +748,9 @@ void QQuickSlider::touchEvent(QTouchEvent *event)
case Qt::TouchPointMoved:
if (!keepTouchGrab()) {
if (d->orientation == Qt::Horizontal)
- setKeepTouchGrab(QQuickWindowPrivate::dragOverThreshold(point.pos().x() - d->pressPoint.x(), Qt::XAxis, &point));
+ setKeepTouchGrab(QQuickWindowPrivate::dragOverThreshold(point.pos().x() - d->pressPoint.x(), Qt::XAxis, &point, qRound(d->touchDragThreshold)));
else
- setKeepTouchGrab(QQuickWindowPrivate::dragOverThreshold(point.pos().y() - d->pressPoint.y(), Qt::YAxis, &point));
+ setKeepTouchGrab(QQuickWindowPrivate::dragOverThreshold(point.pos().y() - d->pressPoint.y(), Qt::YAxis, &point, qRound(d->touchDragThreshold)));
}
if (keepTouchGrab())
d->handleMove(point.pos());