diff --git a/src/qvgraphicsview.cpp b/src/qvgraphicsview.cpp index f984647f..23e668ec 100644 --- a/src/qvgraphicsview.cpp +++ b/src/qvgraphicsview.cpp @@ -359,7 +359,7 @@ void QVGraphicsView::executeScrollAction(const Qv::ViewportScrollAction action, else if (action == Qv::ViewportScrollAction::Navigate) { SwipeData swipeData = scrollAxisLocker.getCustomData().value(); - if (swipeData.triggeredAction) + if (swipeData.triggeredAction && scrollActionCooldown) return; swipeData.totalDelta += getUniAxisDelta(); if (qAbs(swipeData.totalDelta) >= deltaPerWheelStep) @@ -369,6 +369,7 @@ void QVGraphicsView::executeScrollAction(const Qv::ViewportScrollAction action, else goToFile(GoToFileMode::previous); swipeData.triggeredAction = true; + swipeData.totalDelta %= deltaPerWheelStep; } scrollAxisLocker.setCustomData(QVariant::fromValue(swipeData)); } @@ -1001,6 +1002,7 @@ void QVGraphicsView::settingsUpdated() horizontalScrollAction = settingsManager.getEnum("viewporthorizontalscrollaction"); altVerticalScrollAction = settingsManager.getEnum("viewportaltverticalscrollaction"); altHorizontalScrollAction = settingsManager.getEnum("viewportalthorizontalscrollaction"); + scrollActionCooldown = settingsManager.getBoolean("scrollactioncooldown"); // End of settings variables diff --git a/src/qvgraphicsview.h b/src/qvgraphicsview.h index 9e229747..6757c93d 100644 --- a/src/qvgraphicsview.h +++ b/src/qvgraphicsview.h @@ -189,6 +189,7 @@ private slots: Qv::ViewportScrollAction horizontalScrollAction {Qv::ViewportScrollAction::None}; Qv::ViewportScrollAction altVerticalScrollAction {Qv::ViewportScrollAction::None}; Qv::ViewportScrollAction altHorizontalScrollAction {Qv::ViewportScrollAction::None}; + bool scrollActionCooldown {false}; std::optional calculatedZoomMode {Qv::CalculatedZoomMode::ZoomToFit}; bool navigationResetsZoom {true}; diff --git a/src/qvoptionsdialog.cpp b/src/qvoptionsdialog.cpp index a78ca275..3d875cb9 100644 --- a/src/qvoptionsdialog.cpp +++ b/src/qvoptionsdialog.cpp @@ -254,6 +254,7 @@ void QVOptionsDialog::syncSettings(bool defaults, bool makeConnections) syncComboBox(ui->horizontalScrollComboBox, "viewporthorizontalscrollaction", defaults, makeConnections); syncComboBox(ui->altVerticalScrollComboBox, "viewportaltverticalscrollaction", defaults, makeConnections); syncComboBox(ui->altHorizontalScrollComboBox, "viewportalthorizontalscrollaction", defaults, makeConnections); + syncCheckbox(ui->scrollActionCooldownCheckbox, "scrollactioncooldown", defaults, makeConnections); } void QVOptionsDialog::syncCheckbox(QCheckBox *checkbox, const QString &key, bool defaults, bool makeConnection) diff --git a/src/qvoptionsdialog.ui b/src/qvoptionsdialog.ui index bb4489d0..55895b0b 100644 --- a/src/qvoptionsdialog.ui +++ b/src/qvoptionsdialog.ui @@ -10,7 +10,7 @@ 0 0 508 - 616 + 639 @@ -980,6 +980,16 @@ + + + + Useful for touchpads, to prevent a single swipe from triggering multiple navigations, for example + + + Cooldown for discrete actions + + + diff --git a/src/settingsmanager.cpp b/src/settingsmanager.cpp index bc4af0c3..f2a2072e 100644 --- a/src/settingsmanager.cpp +++ b/src/settingsmanager.cpp @@ -230,4 +230,10 @@ void SettingsManager::initializeSettingsLibrary() settingsLibrary.insert("viewporthorizontalscrollaction", {static_cast(Qv::ViewportScrollAction::Navigate), {}}); settingsLibrary.insert("viewportaltverticalscrollaction", {static_cast(Qv::ViewportScrollAction::Pan), {}}); settingsLibrary.insert("viewportalthorizontalscrollaction", {static_cast(Qv::ViewportScrollAction::Pan), {}}); +#ifdef Q_OS_MACOS + // Works best with touchpads that accurately report ScrollPhase (macOS only currently) + settingsLibrary.insert("scrollactioncooldown", {true, {}}); +#else + settingsLibrary.insert("scrollactioncooldown", {false, {}}); +#endif }