From fb1716c91f80baf482a51b86a9a92cb1df2819b0 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 12 Mar 2024 17:05:17 +0400 Subject: [PATCH] Add fast Ctrl/Shift scroll to ElasticScroll. --- ui/widgets/elastic_scroll.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ui/widgets/elastic_scroll.cpp b/ui/widgets/elastic_scroll.cpp index 506b200..ec5c2a0 100644 --- a/ui/widgets/elastic_scroll.cpp +++ b/ui/widgets/elastic_scroll.cpp @@ -660,7 +660,14 @@ bool ElasticScroll::handleWheelEvent(not_null e, bool touch) { const auto guard = gsl::finally([&] { _lastScroll = now; }); - const auto pixels = ScrollDelta(e, touch); + const auto unmultiplied = ScrollDelta(e, touch); + const auto multiply = e->modifiers() + & (Qt::ControlModifier | Qt::ShiftModifier); + const auto pixels = multiply + ? QPoint( + (unmultiplied.x() * std::max(width(), 120) / 120.), + (unmultiplied.y() * std::max(height(), 120) / 120.)) + : unmultiplied; auto delta = _vertical ? -pixels.y() : pixels.x(); if (std::abs(_vertical ? pixels.x() : pixels.y()) >= std::abs(delta)) { delta = 0; @@ -1030,7 +1037,7 @@ void ElasticScroll::sendWheelEvent(Qt::ScrollPhase phase, QPoint delta) { delta, delta, Qt::NoButton, - QGuiApplication::keyboardModifiers(), + Qt::KeyboardModifiers(), // Ignore Ctrl/Shift fast scroll on touch. phase, false, Qt::MouseEventSynthesizedByApplication);