Fix scroll regression near scroll-view ends
Fix regression in a7b0cb467ca5c4a9447d049910c9e3f0abc5897c which caused it to be hard to start scrolling at the ends of a scroll-view if using fine grained scrolling events. Change-Id: I55f3210150b993281545c3ad5a7356d892fa30b5 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
This commit is contained in:
parent
c55bdc271f
commit
002112e805
@ -723,9 +723,10 @@ bool QAbstractSliderPrivate::scrollByDelta(Qt::Orientation orientation, Qt::Keyb
|
||||
if (stepsToScroll == 0) {
|
||||
// We moved less than a line, but might still have accumulated partial scroll,
|
||||
// unless we already are at one of the ends.
|
||||
if (offset_accumulated > 0.f && value < maximum)
|
||||
const float effective_offset = invertedControls ? -offset_accumulated : offset_accumulated;
|
||||
if (effective_offset > 0.f && value < maximum)
|
||||
return true;
|
||||
if (offset_accumulated < 0.f && value > minimum)
|
||||
if (effective_offset < 0.f && value > minimum)
|
||||
return true;
|
||||
offset_accumulated = 0;
|
||||
return false;
|
||||
|
@ -82,6 +82,8 @@ private slots:
|
||||
#ifndef QT_NO_WHEELEVENT
|
||||
void wheelEvent_data();
|
||||
void wheelEvent();
|
||||
void fineGrainedWheelEvent_data();
|
||||
void fineGrainedWheelEvent();
|
||||
#endif
|
||||
void sliderPressedReleased_data();
|
||||
void sliderPressedReleased();
|
||||
@ -897,6 +899,55 @@ void tst_QAbstractSlider::wheelEvent()
|
||||
if (expectedSignalCount)
|
||||
QVERIFY(actionTriggeredTimeStamp < valueChangedTimeStamp);
|
||||
}
|
||||
|
||||
void tst_QAbstractSlider::fineGrainedWheelEvent_data()
|
||||
{
|
||||
QTest::addColumn<bool>("invertedControls");
|
||||
QTest::newRow("invertedControls=false") << false;
|
||||
QTest::newRow("invertedControls=true") << true;
|
||||
}
|
||||
|
||||
void tst_QAbstractSlider::fineGrainedWheelEvent()
|
||||
{
|
||||
QFETCH(bool, invertedControls);
|
||||
|
||||
QCoreApplication *applicationInstance = QCoreApplication::instance();
|
||||
QVERIFY(applicationInstance != 0);
|
||||
QApplication::setWheelScrollLines(3);
|
||||
|
||||
slider->setRange(0, 10);
|
||||
slider->setSingleStep(1);
|
||||
slider->setPageStep(10);
|
||||
slider->setInvertedControls(invertedControls);
|
||||
slider->setOrientation(Qt::Vertical);
|
||||
slider->setSliderPosition(0);
|
||||
|
||||
const int singleStepDelta = invertedControls ? (-WHEEL_DELTA / 3) : (WHEEL_DELTA / 3);
|
||||
|
||||
QWheelEvent eventDown(slider->rect().bottomRight(), singleStepDelta / 2,
|
||||
Qt::NoButton, Qt::NoModifier, Qt::Vertical);
|
||||
QVERIFY(applicationInstance->sendEvent(slider,&eventDown));
|
||||
QCOMPARE(slider->sliderPosition(), 0);
|
||||
QVERIFY(applicationInstance->sendEvent(slider,&eventDown));
|
||||
QCOMPARE(slider->sliderPosition(), 1);
|
||||
|
||||
QWheelEvent eventUp(slider->rect().bottomRight(), -singleStepDelta / 2,
|
||||
Qt::NoButton, Qt::NoModifier, Qt::Vertical);
|
||||
QVERIFY(applicationInstance->sendEvent(slider,&eventUp));
|
||||
QCOMPARE(slider->sliderPosition(), 1);
|
||||
QVERIFY(applicationInstance->sendEvent(slider,&eventUp));
|
||||
QCOMPARE(slider->sliderPosition(), 0);
|
||||
QVERIFY(applicationInstance->sendEvent(slider,&eventUp));
|
||||
QCOMPARE(slider->sliderPosition(), 0);
|
||||
QVERIFY(applicationInstance->sendEvent(slider,&eventUp));
|
||||
QCOMPARE(slider->sliderPosition(), 0);
|
||||
|
||||
QVERIFY(applicationInstance->sendEvent(slider,&eventDown));
|
||||
QCOMPARE(slider->sliderPosition(), 0);
|
||||
QVERIFY(applicationInstance->sendEvent(slider,&eventDown));
|
||||
QCOMPARE(slider->sliderPosition(), 1);
|
||||
}
|
||||
|
||||
#endif // !QT_NO_WHEELEVENT
|
||||
|
||||
void tst_QAbstractSlider::sliderPressedReleased_data()
|
||||
|
Loading…
x
Reference in New Issue
Block a user