From 790cf8d3b4078dc1bbc1afb338f1bf197598c4d0 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 4 Apr 2017 17:44:58 +0200 Subject: Dial: react immediately when using a mouse The initial drag threshold is a necessary evil on touch to avoid conflicting with flickables, but leads to bad experience (QTBUG-47081) when using a mouse. Now that we have separate mouse and touch handling, we can apply immediate moves when using a mouse, but keep the old behavior on touch. Task-number: QTBUG-59920 Change-Id: I097cbdaed4933c0d907097b75f15ba16dcf615b1 Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquickdial.cpp | 6 +++--- tests/auto/controls/data/tst_dial.qml | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/quicktemplates2/qquickdial.cpp b/src/quicktemplates2/qquickdial.cpp index c7fbdc80..5b98992b 100644 --- a/src/quicktemplates2/qquickdial.cpp +++ b/src/quicktemplates2/qquickdial.cpp @@ -207,8 +207,6 @@ void QQuickDialPrivate::handlePress(const QPointF &point) void QQuickDialPrivate::handleMove(const QPointF &point) { Q_Q(QQuickDial); - if (!q->keepMouseGrab() && !q->keepTouchGrab()) - return; const qreal oldPos = position; qreal pos = positionAt(point); if (snapMode == QQuickDial::SnapAlways) @@ -651,6 +649,7 @@ void QQuickDial::mousePressEvent(QMouseEvent *event) Q_D(QQuickDial); QQuickControl::mousePressEvent(event); d->handlePress(event->localPos()); + d->handleMove(event->localPos()); } void QQuickDial::mouseMoveEvent(QMouseEvent *event) @@ -711,7 +710,8 @@ void QQuickDial::touchEvent(QTouchEvent *event) setKeepTouchGrab(overYDragThreshold); } } - d->handleMove(point.pos()); + if (keepTouchGrab()) + d->handleMove(point.pos()); } break; diff --git a/tests/auto/controls/data/tst_dial.qml b/tests/auto/controls/data/tst_dial.qml index 98c3a002..3b20e91d 100644 --- a/tests/auto/controls/data/tst_dial.qml +++ b/tests/auto/controls/data/tst_dial.qml @@ -465,7 +465,7 @@ TestCase { compare(dial.value, dial.to); } - function test_snapMode_data() { + function test_snapMode_data(immediate) { return [ { tag: "NoSnap", snapMode: Slider.NoSnap, from: 0, to: 2, values: [0, 0, 1], positions: [0, 0.5, 0.5] }, { tag: "SnapAlways (0..2)", snapMode: Slider.SnapAlways, from: 0, to: 2, values: [0.0, 0.0, 1.0], positions: [0.0, 0.5, 0.5] }, @@ -474,13 +474,13 @@ TestCase { { tag: "SnapAlways (1..-1)", snapMode: Slider.SnapAlways, from: 1, to: -1, values: [1.0, 1.0, 0.0], positions: [0.0, 0.5, 0.5] }, { tag: "SnapOnRelease (0..2)", snapMode: Slider.SnapOnRelease, from: 0, to: 2, values: [0.0, 0.0, 1.0], positions: [0.0, 0.5, 0.5] }, { tag: "SnapOnRelease (1..3)", snapMode: Slider.SnapOnRelease, from: 1, to: 3, values: [1.0, 1.0, 2.0], positions: [0.0, 0.5, 0.5] }, - { tag: "SnapOnRelease (-1..1)", snapMode: Slider.SnapOnRelease, from: -1, to: 1, values: [0.0, 0.0, 0.0], positions: [0.5, 0.5, 0.5] }, + { tag: "SnapOnRelease (-1..1)", snapMode: Slider.SnapOnRelease, from: -1, to: 1, values: [0.0, 0.0, 0.0], positions: [immediate ? 0.0 : 0.5, 0.5, 0.5] }, { tag: "SnapOnRelease (1..-1)", snapMode: Slider.SnapOnRelease, from: 1, to: -1, values: [1.0, 1.0, 0.0], positions: [0.0, 0.5, 0.5] } ] } function test_snapMode_mouse_data() { - return test_snapMode_data() + return test_snapMode_data(true) } function test_snapMode_mouse(data) { @@ -492,11 +492,11 @@ TestCase { dial.to = data.to; dial.stepSize = 0.2; - var fuzz = 0.05; + var fuzz = 0.055; mousePress(dial, dial.width * 0.25, dial.height * 0.75); - compare(dial.value, data.values[0]); - compare(dial.position, data.positions[0]); + fuzzyCompare(dial.value, data.values[0], fuzz); + fuzzyCompare(dial.position, data.positions[0], fuzz); mouseMove(dial, dial.width * 0.5, dial.height * 0.25); fuzzyCompare(dial.value, data.values[1], fuzz); @@ -508,7 +508,7 @@ TestCase { } function test_snapMode_touch_data() { - return test_snapMode_data() + return test_snapMode_data(false) } function test_snapMode_touch(data) { -- cgit v1.2.3