From da0570d1ddf6c786b4bfdd0a1172b36ecc66f2a2 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 29 Nov 2016 13:04:10 +0100 Subject: Dial: add missing wheel handling [ChangeLog][Controls][Dial] Added support for wheel handling when wheelEnabled is set to true. Change-Id: If0bc2f0ea9d7cde7726739cdfdbd795c908981f0 Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquickdial.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/quicktemplates2/qquickdial.cpp') diff --git a/src/quicktemplates2/qquickdial.cpp b/src/quicktemplates2/qquickdial.cpp index 79aff781..2b9f83a4 100644 --- a/src/quicktemplates2/qquickdial.cpp +++ b/src/quicktemplates2/qquickdial.cpp @@ -606,6 +606,20 @@ void QQuickDial::mouseUngrabEvent() setPressed(false); } +void QQuickDial::wheelEvent(QWheelEvent *event) +{ + Q_D(QQuickDial); + QQuickControl::wheelEvent(event); + if (d->wheelEnabled) { + const qreal oldValue = d->value; + const QPointF angle = event->angleDelta(); + const qreal delta = (qFuzzyIsNull(angle.y()) ? angle.x() : angle.y()) / QWheelEvent::DefaultDeltasPerStep; + const qreal step = qFuzzyIsNull(d->stepSize) ? 0.1 : d->stepSize; + setValue(oldValue + step * delta); + event->setAccepted(!qFuzzyCompare(d->value, oldValue)); + } +} + void QQuickDial::mirrorChange() { QQuickControl::mirrorChange(); -- cgit v1.2.3