Add fast Ctrl/Shift scroll to ElasticScroll.

This commit is contained in:
John Preston 2024-03-12 17:05:17 +04:00
parent edfcac751d
commit fb1716c91f

View file

@ -660,7 +660,14 @@ bool ElasticScroll::handleWheelEvent(not_null<QWheelEvent*> e, bool touch) {
const auto guard = gsl::finally([&] { const auto guard = gsl::finally([&] {
_lastScroll = now; _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(); auto delta = _vertical ? -pixels.y() : pixels.x();
if (std::abs(_vertical ? pixels.x() : pixels.y()) >= std::abs(delta)) { if (std::abs(_vertical ? pixels.x() : pixels.y()) >= std::abs(delta)) {
delta = 0; delta = 0;
@ -1030,7 +1037,7 @@ void ElasticScroll::sendWheelEvent(Qt::ScrollPhase phase, QPoint delta) {
delta, delta,
delta, delta,
Qt::NoButton, Qt::NoButton,
QGuiApplication::keyboardModifiers(), Qt::KeyboardModifiers(), // Ignore Ctrl/Shift fast scroll on touch.
phase, phase,
false, false,
Qt::MouseEventSynthesizedByApplication); Qt::MouseEventSynthesizedByApplication);