From 4d5417012570f9077b18c7dfabe74f713bbd5b92 Mon Sep 17 00:00:00 2001 From: Thomas Mitterfellner Date: Mon, 26 Aug 2024 21:42:28 +0200 Subject: [PATCH] Introduce scroll delta for CTRL+touchpad-zoom To make zooming the document via touchpad, i.e. CTRL+two-finger-move, usable, a scroll delta was introduced. That way, not every tiny finger movement triggers a zoom event but a certain default delta has to be surpassed before zooming. --- scribus/scribusview.cpp | 7 ++++++- scribus/scribusview.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/scribus/scribusview.cpp b/scribus/scribusview.cpp index 70c93cbd25..3398b5764e 100644 --- a/scribus/scribusview.cpp +++ b/scribus/scribusview.cpp @@ -3158,7 +3158,12 @@ void ScribusView::wheelEvent(QWheelEvent *w) if (w->modifiers() == Qt::ControlModifier) { FPoint mp = m_canvas->globalToCanvas(w->globalPos()); - w->delta() > 0 ? slotZoomIn(mp.x(), mp.y() , true) : slotZoomOut(mp.x(), mp.y(), true); + wheelAccumulatedDelta += w->delta(); + if (abs(wheelAccumulatedDelta) >= QWheelEvent::DefaultDeltasPerStep) + { + wheelAccumulatedDelta > 0 ? slotZoomIn(mp.x(), mp.y() , true) : slotZoomOut(mp.x(), mp.y(), true); + wheelAccumulatedDelta = 0; + } } else { diff --git a/scribus/scribusview.h b/scribus/scribusview.h index a3bbc46ab9..512e06f87f 100644 --- a/scribus/scribusview.h +++ b/scribus/scribusview.h @@ -298,6 +298,7 @@ public slots: // Public slots bool linkAfterDraw { false }; bool ImageAfterDraw { false }; QStack m_viewStates; + int wheelAccumulatedDelta { 0 }; private slots: void setZoom();