PR #1954 improvements.

Inverted the direction of move-by-wheel, so that scrolling down will
move you forward through the photos or documents overview.

Added an accumulation of the scroll amount so that you don't zoom or
skip photos each time a (possibly very frequent) wheel event fires.
This commit is contained in:
John Preston 2016-09-14 19:05:40 +03:00
parent e623d05e37
commit a7b692e8ed
2 changed files with 21 additions and 12 deletions

View File

@ -1890,20 +1890,27 @@ void MediaView::keyPressEvent(QKeyEvent *e) {
} }
void MediaView::wheelEvent(QWheelEvent *e) { void MediaView::wheelEvent(QWheelEvent *e) {
if (e->delta() < 0) { constexpr auto step = static_cast<int>(QWheelEvent::DefaultDeltasPerStep);
_verticalWheelDelta += e->angleDelta().y();
while (qAbs(_verticalWheelDelta) >= step) {
if (_verticalWheelDelta < 0) {
_verticalWheelDelta += step;
if (e->modifiers().testFlag(Qt::ControlModifier)) { if (e->modifiers().testFlag(Qt::ControlModifier)) {
zoomOut(); zoomOut();
} else { } else {
if (e->source() == Qt::MouseEventNotSynthesized) { if (e->source() == Qt::MouseEventNotSynthesized) {
moveToNext(-1); moveToNext(1);
} }
} }
} else { } else {
_verticalWheelDelta -= step;
if (e->modifiers().testFlag(Qt::ControlModifier)) { if (e->modifiers().testFlag(Qt::ControlModifier)) {
zoomIn(); zoomIn();
} else { } else {
if (e->source() == Qt::MouseEventNotSynthesized) { if (e->source() == Qt::MouseEventNotSynthesized) {
moveToNext(1); moveToNext(-1);
}
} }
} }
} }

View File

@ -322,6 +322,8 @@ private:
typedef QMap<OverState, anim::fvalue> ShowingOpacities; typedef QMap<OverState, anim::fvalue> ShowingOpacities;
ShowingOpacities _animOpacities; ShowingOpacities _animOpacities;
int _verticalWheelDelta = 0;
void updateOverRect(OverState state); void updateOverRect(OverState state);
bool updateOverState(OverState newState); bool updateOverState(OverState newState);
float64 overLevel(OverState control) const; float64 overLevel(OverState control) const;