summaryrefslogtreecommitdiffstats
path: root/src/gui/widgets
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-10-29 08:10:27 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-10-29 08:10:41 (GMT)
commitdf37b2e9023bc2cebe00c77be6040019cfdc24b6 (patch)
tree06739d09b63dd673b510a5af31de7c30407bed6e /src/gui/widgets
parentf32abd2b9febdeadeb5536d0318f77be4180f142 (diff)
parentcabfa68f3e37e79a18775a9970f6d166e75ece07 (diff)
downloadQt-df37b2e9023bc2cebe00c77be6040019cfdc24b6.zip
Qt-df37b2e9023bc2cebe00c77be6040019cfdc24b6.tar.gz
Qt-df37b2e9023bc2cebe00c77be6040019cfdc24b6.tar.bz2
Merge commit origin/4.6 into team-widgets/4.6
Diffstat (limited to 'src/gui/widgets')
-rw-r--r--src/gui/widgets/qabstractslider.cpp44
-rw-r--r--src/gui/widgets/qcombobox.cpp20
2 files changed, 30 insertions, 34 deletions
diff --git a/src/gui/widgets/qabstractslider.cpp b/src/gui/widgets/qabstractslider.cpp
index 588a48e..fec9fab 100644
--- a/src/gui/widgets/qabstractslider.cpp
+++ b/src/gui/widgets/qabstractslider.cpp
@@ -693,29 +693,27 @@ void QAbstractSlider::wheelEvent(QWheelEvent * e)
if (e->orientation() != d->orientation && !rect().contains(e->pos()))
return;
- 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
- // wheel events (this means that the wheel resolution is higher than
- // 15 degrees, e.g. when using mac mighty mouse/trackpad):
- return;
- }
+ int stepsToScroll = 0;
+ qreal offset = qreal(e->delta()) / 120;
- int stepsToScroll;
if ((e->modifiers() & Qt::ControlModifier) || (e->modifiers() & Qt::ShiftModifier)) {
- stepsToScroll = currentOffset > 0 ? d->pageStep : -d->pageStep;
+ // Scroll one page regardless of delta:
+ stepsToScroll = qBound(-d->pageStep, int(offset * d->pageStep), d->pageStep);
+ d->offset_accumulated = 0;
} 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
- stepsToScroll = qBound(-d->pageStep, stepsToScroll, d->pageStep);
+ // Calculate how many lines to scroll. Depending on what delta is (and
+ // offset), we might end up with a fraction (e.g. scroll 1.3 lines). We can
+ // only scroll whole lines, so we keep the reminder until next event.
+ qreal stepsToScrollF = offset * QApplication::wheelScrollLines() * d->singleStep;
+ // Check if wheel changed direction since last event:
+ if (d->offset_accumulated != 0 && (offset / d->offset_accumulated) < 0)
+ d->offset_accumulated = 0;
+
+ d->offset_accumulated += stepsToScrollF;
+ stepsToScroll = qBound(-d->pageStep, int(d->offset_accumulated), d->pageStep);
+ d->offset_accumulated -= int(d->offset_accumulated);
+ if (stepsToScroll == 0)
+ return;
}
if (d->invertedControls)
@@ -725,12 +723,10 @@ void QAbstractSlider::wheelEvent(QWheelEvent * e)
d->position = d->overflowSafeAdd(stepsToScroll); // value will be updated by triggerAction()
triggerAction(SliderMove);
- if (prevValue == d->value) {
+ if (prevValue == d->value)
d->offset_accumulated = 0;
- } else {
- d->offset_accumulated -= int(d->offset_accumulated);
+ else
e->accept();
- }
}
#endif
#ifdef QT_KEYPAD_NAVIGATION
diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp
index 6fd8706..6dbf15a 100644
--- a/src/gui/widgets/qcombobox.cpp
+++ b/src/gui/widgets/qcombobox.cpp
@@ -404,13 +404,6 @@ QComboBoxPrivateContainer::QComboBoxPrivateContainer(QAbstractItemView *itemView
layout->setSpacing(0);
layout->setMargin(0);
-#ifdef QT_SOFTKEYS_ENABLED
- selectAction = QSoftKeyManager::createKeyedAction(QSoftKeyManager::SelectSoftKey, Qt::Key_Select, this);
- cancelAction = QSoftKeyManager::createKeyedAction(QSoftKeyManager::CancelSoftKey, Qt::Key_Escape, this);
- addAction(selectAction);
- addAction(cancelAction);
-#endif
-
// set item view
setItemView(itemView);
@@ -574,6 +567,13 @@ void QComboBoxPrivateContainer::setItemView(QAbstractItemView *itemView)
this, SLOT(setCurrentIndex(QModelIndex)));
connect(view, SIGNAL(destroyed()),
this, SLOT(viewDestroyed()));
+
+#ifdef QT_SOFTKEYS_ENABLED
+ selectAction = QSoftKeyManager::createKeyedAction(QSoftKeyManager::SelectSoftKey, Qt::Key_Select, itemView);
+ cancelAction = QSoftKeyManager::createKeyedAction(QSoftKeyManager::CancelSoftKey, Qt::Key_Escape, itemView);
+ addAction(selectAction);
+ addAction(cancelAction);
+#endif
}
/*!
@@ -2447,15 +2447,15 @@ void QComboBox::showPopup()
#if defined(Q_WS_WIN) && !defined(QT_NO_EFFECTS)
bool scrollDown = (listRect.topLeft() == below);
- if (QApplication::isEffectEnabled(Qt::UI_AnimateCombo)
+ if (QApplication::isEffectEnabled(Qt::UI_AnimateCombo)
&& !style->styleHint(QStyle::SH_ComboBox_Popup, &opt, this) && !window()->testAttribute(Qt::WA_DontShowOnScreen))
qScrollEffect(container, scrollDown ? QEffects::DownScroll : QEffects::UpScroll, 150);
#endif
// Don't disable updates on Mac OS X. Windows are displayed immediately on this platform,
// which means that the window will be visible before the call to container->show() returns.
-// If updates are disabled at this point we'll miss our chance at painting the popup
-// menu before it's shown, causing flicker since the window then displays the standard gray
+// If updates are disabled at this point we'll miss our chance at painting the popup
+// menu before it's shown, causing flicker since the window then displays the standard gray
// background.
#ifndef Q_WS_MAC
container->setUpdatesEnabled(false);