diff options
Diffstat (limited to 'src/gui/widgets/qabstractslider.cpp')
-rw-r--r-- | src/gui/widgets/qabstractslider.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/gui/widgets/qabstractslider.cpp b/src/gui/widgets/qabstractslider.cpp index c3289b4..28f3be3 100644 --- a/src/gui/widgets/qabstractslider.cpp +++ b/src/gui/widgets/qabstractslider.cpp @@ -693,13 +693,8 @@ void QAbstractSlider::wheelEvent(QWheelEvent * e) if (e->orientation() != d->orientation && !rect().contains(e->pos())) return; - int step = qMin(QApplication::wheelScrollLines() * d->singleStep, d->pageStep); - if ((e->modifiers() & Qt::ControlModifier) || (e->modifiers() & Qt::ShiftModifier)) - step = d->pageStep; - - qreal currentOffset = qreal(e->delta()) * step / 120; + qreal currentOffset = qreal(e->delta()) / 120; d->offset_accumulated += d->invertedControls ? -currentOffset : currentOffset; - if (int(d->offset_accumulated) == 0) { // QAbstractSlider works on integer values. So if the accumulated // offset is less than +/- 1, we need to wait until we get more @@ -708,8 +703,20 @@ void QAbstractSlider::wheelEvent(QWheelEvent * e) return; } + // Calculate the number of steps to scroll (per 15 degrees of rotate): +#ifdef Q_OS_MAC + // On mac, since mouse wheel scrolling is accelerated and + // fine tuned by the OS, we skip applying acceleration: + int stepsToScroll = int(d->offset_accumulated); +#else + int step = qMin(QApplication::wheelScrollLines() * d->singleStep, d->pageStep); + if ((e->modifiers() & Qt::ControlModifier) || (e->modifiers() & Qt::ShiftModifier)) + step = d->pageStep; + int stepsToScroll = step * int(d->offset_accumulated); +#endif + int prevValue = d->value; - d->position = d->overflowSafeAdd(int(d->offset_accumulated)); // value will be updated by triggerAction() + d->position = d->overflowSafeAdd(stepsToScroll); // value will be updated by triggerAction() triggerAction(SliderMove); if (prevValue == d->value) { |