Slider: use axis with the largest delta, when sliding via wheelEvent
The slider naively assumed that all wheelEvents would have either angleDelta().x(), or angleDelta().y() set to 0, when in reality those numbers can be any floating point value. Choosing the largest of the two deltas, is a more robust solution. Pick-to: 6.8 Change-Id: I1fb75eb5121c99c9b354e53732ec6981f477e283 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
This commit is contained in:
parent
c8943ea784
commit
92eff047d6
|
@ -837,7 +837,7 @@ void QQuickSlider::wheelEvent(QWheelEvent *event)
|
|||
if (d->wheelEnabled) {
|
||||
const qreal oldValue = d->value;
|
||||
const QPointF angle = event->angleDelta();
|
||||
const qreal delta = (qFuzzyIsNull(angle.y()) ? angle.x() : (event->inverted() ? -angle.y() : angle.y())) / int(QWheelEvent::DefaultDeltasPerStep);
|
||||
const qreal delta = (qAbs(angle.y()) < qAbs(angle.x()) ? angle.x() : (event->inverted() ? -angle.y() : angle.y())) / int(QWheelEvent::DefaultDeltasPerStep);
|
||||
const qreal step = qFuzzyIsNull(d->stepSize) ? 0.1 : d->stepSize;
|
||||
setValue(oldValue + step * delta);
|
||||
const bool wasMoved = !qFuzzyCompare(d->value, oldValue);
|
||||
|
|
|
@ -692,7 +692,9 @@ TestCase {
|
|||
function test_wheel_data() {
|
||||
return [
|
||||
{ tag: "horizontal", orientation: Qt.Horizontal, dx: 120, dy: 0 },
|
||||
{ tag: "vertical", orientation: Qt.Vertical, dx: 0, dy: 120 }
|
||||
{ tag: "vertical", orientation: Qt.Vertical, dx: 0, dy: 120 },
|
||||
{ tag: "mostlyHorizontal", orientation: Qt.Horizontal, dx: 120, dy: 1 },
|
||||
{ tag: "mostlyVertical", orientation: Qt.Vertical, dx: 1, dy: 120 },
|
||||
]
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue