mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 14:38:15 +00:00
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:
@@ -1890,20 +1890,27 @@ void MediaView::keyPressEvent(QKeyEvent *e) {
|
||||
}
|
||||
|
||||
void MediaView::wheelEvent(QWheelEvent *e) {
|
||||
if (e->delta() < 0) {
|
||||
if (e->modifiers().testFlag(Qt::ControlModifier)) {
|
||||
zoomOut();
|
||||
} else {
|
||||
if (e->source() == Qt::MouseEventNotSynthesized) {
|
||||
moveToNext(-1);
|
||||
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)) {
|
||||
zoomOut();
|
||||
} else {
|
||||
if (e->source() == Qt::MouseEventNotSynthesized) {
|
||||
moveToNext(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (e->modifiers().testFlag(Qt::ControlModifier)) {
|
||||
zoomIn();
|
||||
} else {
|
||||
if (e->source() == Qt::MouseEventNotSynthesized) {
|
||||
moveToNext(1);
|
||||
_verticalWheelDelta -= step;
|
||||
if (e->modifiers().testFlag(Qt::ControlModifier)) {
|
||||
zoomIn();
|
||||
} else {
|
||||
if (e->source() == Qt::MouseEventNotSynthesized) {
|
||||
moveToNext(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user