Use angleDelta

pixelDelta is only provided in systems that support it
This commit is contained in:
Luis Ángel San Martín 2021-10-01 20:23:20 +02:00
parent 052e7ffba0
commit ae43f23c85
3 changed files with 12 additions and 10 deletions

View File

@ -195,7 +195,7 @@ void GoToFlow::updateImageData()
void GoToFlow::wheelEvent(QWheelEvent *event)
{
if (event->pixelDelta().y() < 0)
if (event->angleDelta().y() < 0)
flow->showNext();
else
flow->showPrevious();

View File

@ -144,28 +144,28 @@ void MagnifyingGlass::wheelEvent(QWheelEvent *event)
switch (event->modifiers()) {
// size
case Qt::NoModifier:
if (event->pixelDelta().y() < 0)
if (event->angleDelta().y() < 0)
sizeUp();
else
sizeDown();
break;
// size height
case Qt::ControlModifier:
if (event->pixelDelta().y() < 0)
if (event->angleDelta().y() < 0)
heightUp();
else
heightDown();
break;
// size width
case Qt::AltModifier:
if (event->pixelDelta().y() < 0)
if (event->angleDelta().y() < 0)
widthUp();
else
widthDown();
break;
// zoom level
case Qt::ShiftModifier:
if (event->pixelDelta().y() < 0)
if (event->angleDelta().y() < 0)
zoomIn();
else
zoomOut();

View File

@ -688,13 +688,15 @@ static void animateScroll(QPropertyAnimation &scroller, const QScrollBar &scroll
void Viewer::wheelEvent(QWheelEvent *event)
{
auto delta = event->angleDelta();
if (render->hasLoadedComic()) {
if (event->pixelDelta().x() != 0) {
animateScroll(*horizontalScroller, *horizontalScrollBar(), event->pixelDelta().x());
if (delta.x() != 0) {
animateScroll(*horizontalScroller, *horizontalScrollBar(), delta.x());
return;
}
if ((event->pixelDelta().y() < 0) && (verticalScrollBar()->sliderPosition() == verticalScrollBar()->maximum())) {
if ((delta.y() < 0) && (verticalScrollBar()->sliderPosition() == verticalScrollBar()->maximum())) {
if (wheelStop || verticalScrollBar()->maximum() == verticalScrollBar()->minimum()) {
if (getMovement(event) == Forward) {
next();
@ -706,7 +708,7 @@ void Viewer::wheelEvent(QWheelEvent *event)
} else
wheelStop = true;
} else {
if ((event->pixelDelta().y() > 0) && (verticalScrollBar()->sliderPosition() == verticalScrollBar()->minimum())) {
if ((delta.y() > 0) && (verticalScrollBar()->sliderPosition() == verticalScrollBar()->minimum())) {
if (wheelStop || verticalScrollBar()->maximum() == verticalScrollBar()->minimum()) {
if (getMovement(event) == Backward) {
prev();
@ -720,7 +722,7 @@ void Viewer::wheelEvent(QWheelEvent *event)
}
}
animateScroll(*verticalScroller, *verticalScrollBar(), event->pixelDelta().y());
animateScroll(*verticalScroller, *verticalScrollBar(), delta.y());
}
}