diff options
author | Allan Sandfeld Jensen <allan.jensen@digia.com> | 2014-09-08 16:22:29 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@digia.com> | 2014-09-23 11:35:30 +0200 |
commit | dfb4af1fd34a163495790a7896acafa56b86a8f1 (patch) | |
tree | 81d6d9a5b941aaa2f69d2fb0c178abcaf51d222f /src/widgets/widgets | |
parent | e8ef241d0f35704433ba331dee9578190a5c98a6 (diff) |
Fix spin box with fine grained wheel events
Only step the value in the spin box when we have accumulated one wheel
tick worth of wheel delta.
Also fixes the obsolete contructors of QWheelEvent so they set the non
obsolete properties.
Change-Id: Ic6ea4b37afa8eec85a6ca7bdc0d919bf8fb02608
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Diffstat (limited to 'src/widgets/widgets')
-rw-r--r-- | src/widgets/widgets/qabstractspinbox.cpp | 7 | ||||
-rw-r--r-- | src/widgets/widgets/qabstractspinbox_p.h | 1 |
2 files changed, 6 insertions, 2 deletions
diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp index 4aed153932..0d8c7957e2 100644 --- a/src/widgets/widgets/qabstractspinbox.cpp +++ b/src/widgets/widgets/qabstractspinbox.cpp @@ -1100,7 +1100,10 @@ void QAbstractSpinBox::keyReleaseEvent(QKeyEvent *event) #ifndef QT_NO_WHEELEVENT void QAbstractSpinBox::wheelEvent(QWheelEvent *event) { - const int steps = (event->delta() > 0 ? 1 : -1); + Q_D(QAbstractSpinBox); + d->wheelDeltaRemainder += event->angleDelta().y(); + const int steps = d->wheelDeltaRemainder / 120; + d->wheelDeltaRemainder -= steps * 120; if (stepEnabled() & (steps > 0 ? StepUpEnabled : StepDownEnabled)) stepBy(event->modifiers() & Qt::ControlModifier ? steps * 10 : steps); event->accept(); @@ -1344,7 +1347,7 @@ QAbstractSpinBoxPrivate::QAbstractSpinBoxPrivate() ignoreCursorPositionChanged(false), frame(true), accelerate(false), keyboardTracking(true), cleared(false), ignoreUpdateEdit(false), correctionMode(QAbstractSpinBox::CorrectToPreviousValue), acceleration(0), hoverControl(QStyle::SC_None), buttonSymbols(QAbstractSpinBox::UpDownArrows), validator(0), - showGroupSeparator(0) + showGroupSeparator(0), wheelDeltaRemainder(0) { } diff --git a/src/widgets/widgets/qabstractspinbox_p.h b/src/widgets/widgets/qabstractspinbox_p.h index da9f1d9757..055fe92591 100644 --- a/src/widgets/widgets/qabstractspinbox_p.h +++ b/src/widgets/widgets/qabstractspinbox_p.h @@ -151,6 +151,7 @@ public: QAbstractSpinBox::ButtonSymbols buttonSymbols; QSpinBoxValidator *validator; uint showGroupSeparator : 1; + int wheelDeltaRemainder; }; class QSpinBoxValidator : public QValidator |