chore: stop using QWheelEvent::delta()

This commit is contained in:
Gary Wang 2020-07-12 23:45:49 +08:00
parent fb24e54579
commit c271fde194

View File

@ -349,10 +349,23 @@ void MainWindow::mouseDoubleClickEvent(QMouseEvent *event)
void MainWindow::wheelEvent(QWheelEvent *event) void MainWindow::wheelEvent(QWheelEvent *event)
{ {
if (event->delta() > 0) { QPoint numDegrees = event->angleDelta() / 8;
m_graphicsView->zoomView(1.25); bool needZoom = false, zoomIn = false;
// NOTE: Only checking angleDelta since the QWheelEvent::pixelDelta() doc says
// pixelDelta() value is driver specific and unreliable on X11...
// We are not scrolling the canvas, just zoom in or out, so it probably
// doesn't matter here.
if (!numDegrees.isNull() && numDegrees.y() != 0) {
needZoom = true;
zoomIn = numDegrees.y() > 0;
}
if (needZoom) {
m_graphicsView->zoomView(zoomIn ? 1.25 : 0.8);
event->accept();
} else { } else {
m_graphicsView->zoomView(0.8); QMainWindow::wheelEvent(event);
} }
} }