summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@nokia.com>2009-10-02 11:54:29 (GMT)
committerRichard Moe Gustavsen <richard.gustavsen@nokia.com>2009-10-02 11:59:40 (GMT)
commit1f4e378ca0f9c63bb99a92f3e98b104a0baa408a (patch)
treef95d655380713c504958ed9bdf5e41196d185f95
parentfb85af439715ff5ec141473b5c1d8f9744aca19d (diff)
downloadQt-1f4e378ca0f9c63bb99a92f3e98b104a0baa408a.zip
Qt-1f4e378ca0f9c63bb99a92f3e98b104a0baa408a.tar.gz
Qt-1f4e378ca0f9c63bb99a92f3e98b104a0baa408a.tar.bz2
Mac: update/small fix to 45f095b8970dc3c1b6f6e97fa2323654ba848288
It turns out that we need to let singleStep keep its value in qtextedit so that pushing the up/down buttons on the slider works as they should. Moreover, overriding the behaviour in abstract slider also makes QGraphicsView work out of the box. Also added in the test fix suggested by Olivier.
-rw-r--r--src/gui/widgets/qabstractslider.cpp21
-rw-r--r--src/gui/widgets/qtextedit.cpp5
-rw-r--r--tests/auto/qtableview/tst_qtableview.cpp9
3 files changed, 22 insertions, 13 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) {
diff --git a/src/gui/widgets/qtextedit.cpp b/src/gui/widgets/qtextedit.cpp
index 3fe9bb4..dc78fd5 100644
--- a/src/gui/widgets/qtextedit.cpp
+++ b/src/gui/widgets/qtextedit.cpp
@@ -174,13 +174,8 @@ void QTextEditPrivate::init(const QString &html)
if (!html.isEmpty())
control->setHtml(html);
-#ifdef Q_OS_MAC
- hbar->setSingleStep(1);
- vbar->setSingleStep(1);
-#else
hbar->setSingleStep(20);
vbar->setSingleStep(20);
-#endif
viewport->setBackgroundRole(QPalette::Base);
q->setAcceptDrops(true);
diff --git a/tests/auto/qtableview/tst_qtableview.cpp b/tests/auto/qtableview/tst_qtableview.cpp
index 03f4966..09e1e87 100644
--- a/tests/auto/qtableview/tst_qtableview.cpp
+++ b/tests/auto/qtableview/tst_qtableview.cpp
@@ -3201,9 +3201,17 @@ void tst_QTableView::mouseWheel_data()
QTest::newRow("scroll down per item")
<< int(QAbstractItemView::ScrollPerItem) << -120
<< 10 + qApp->wheelScrollLines() << 10 + qApp->wheelScrollLines();
+#ifdef Q_WS_MAC
+ // On Mac, we always scroll one pixel per 120 delta (rather than multiplying with
+ // singleStep) since wheel events are accelerated by the OS.
+ QTest::newRow("scroll down per pixel")
+ << int(QAbstractItemView::ScrollPerPixel) << -120
+ << 10 + qApp->wheelScrollLines() << 10 + qApp->wheelScrollLines();
+#else
QTest::newRow("scroll down per pixel")
<< int(QAbstractItemView::ScrollPerPixel) << -120
<< 10 + qApp->wheelScrollLines() * 89 << 10 + qApp->wheelScrollLines() * 28;
+#endif
}
void tst_QTableView::mouseWheel()
@@ -3230,7 +3238,6 @@ void tst_QTableView::mouseWheel()
view.horizontalScrollBar()->setValue(10);
view.verticalScrollBar()->setValue(10);
- qDebug() << "delta" << delta << view.viewport()->geometry();
QPoint pos = view.viewport()->geometry().center();
QWheelEvent verticalEvent(pos, delta, 0, 0, Qt::Vertical);
QWheelEvent horizontalEvent(pos, delta, 0, 0, Qt::Horizontal);