2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

added photo switch by scroll gestures for os x in mediaview

This commit is contained in:
John Preston
2014-12-17 20:55:32 +03:00
parent dec5db074c
commit 7c20e4773d
3 changed files with 19 additions and 1 deletions

View File

@@ -1194,6 +1194,23 @@ bool MediaView::event(QEvent *e) {
return true;
}
}
} else if (e->type() == QEvent::Wheel) {
QWheelEvent *ev = static_cast<QWheelEvent*>(e);
if (ev->phase() == Qt::ScrollBegin) {
_accumScroll = ev->angleDelta();
LOG(("Scrolling begin: %1 sum %2").arg(ev->angleDelta().x()).arg(_accumScroll.x()));
} else {
_accumScroll += ev->angleDelta();
if (ev->phase() == Qt::ScrollEnd) {
LOG(("Scrolling end: %1 sum %2").arg(ev->angleDelta().x()).arg(_accumScroll.x()));
if (ev->orientation() == Qt::Horizontal) {
if (_accumScroll.x() * _accumScroll.x() > _accumScroll.y() * _accumScroll.y() && _accumScroll.x() != 0) {
moveToPhoto(_accumScroll.x() > 0 ? -1 : 1);
}
_accumScroll = QPoint();
}
}
}
}
return QWidget::event(e);
}