diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2009-10-04 22:53:42 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2009-10-04 22:53:42 (GMT) |
commit | 276857a52db4640095ede5e7840fabb451b97b85 (patch) | |
tree | dd8f26f85583a99b411bbcd6e5ceb4d280ff4af9 /src/gui/widgets/qabstractslider.cpp | |
parent | c76bb1dcda7b0339d9de427d155b593b3779bea7 (diff) | |
parent | 34a1438c4184afecc237fe0177ed4a536b2d5e43 (diff) | |
download | Qt-276857a52db4640095ede5e7840fabb451b97b85.zip Qt-276857a52db4640095ede5e7840fabb451b97b85.tar.gz Qt-276857a52db4640095ede5e7840fabb451b97b85.tar.bz2 |
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/qt into kinetic-declarativeui
Conflicts:
configure
Diffstat (limited to 'src/gui/widgets/qabstractslider.cpp')
-rw-r--r-- | src/gui/widgets/qabstractslider.cpp | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/src/gui/widgets/qabstractslider.cpp b/src/gui/widgets/qabstractslider.cpp index c3289b4..19a8b63 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; - d->offset_accumulated += d->invertedControls ? -currentOffset : currentOffset; - + qreal currentOffset = qreal(e->delta()) / 120; + d->offset_accumulated += 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,27 @@ void QAbstractSlider::wheelEvent(QWheelEvent * e) return; } + int stepsToScroll; + if ((e->modifiers() & Qt::ControlModifier) || (e->modifiers() & Qt::ShiftModifier)) { + stepsToScroll = currentOffset > 0 ? d->pageStep : -d->pageStep; + } else { + // 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: + stepsToScroll = int(d->offset_accumulated); +#else + stepsToScroll = int(d->offset_accumulated) * QApplication::wheelScrollLines() * d->singleStep; +#endif + if (qAbs(stepsToScroll) > d->pageStep) + stepsToScroll = currentOffset > 0 ? d->pageStep : -d->pageStep; + } + + if (d->invertedControls) + stepsToScroll = -stepsToScroll; + 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) { |