diff options
| author | Friso Smit <[email protected]> | 2023-02-06 14:17:29 +0100 |
|---|---|---|
| committer | Méven Car <[email protected]> | 2023-02-09 16:28:29 +0000 |
| commit | b168f9a98bbe00643e15a49075ed80ac6c82fa74 (patch) | |
| tree | 0ae31b48a18a010264f26c220888a44429eb1fec | |
| parent | c57c5384fcab92a1ba0d8fd87321ce7cb148ca02 (diff) | |
Fix zooming for high resolution scroll wheels
BUG: 432671
| -rw-r--r-- | src/views/dolphinview.cpp | 17 | ||||
| -rw-r--r-- | src/views/dolphinview.h | 4 |
2 files changed, 18 insertions, 3 deletions
diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index 250fe4cc7..1f61bcbf2 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -931,6 +931,11 @@ bool DolphinView::eventFilter(QObject *watched, QEvent *event) } } break; + case QEvent::KeyRelease: + if (static_cast<QKeyEvent *>(event)->key() == Qt::Key_Control) { + m_controlWheelAccumulatedDelta = 0; + } + break; case QEvent::FocusIn: if (watched == m_container) { setActive(true); @@ -969,10 +974,16 @@ bool DolphinView::eventFilter(QObject *watched, QEvent *event) void DolphinView::wheelEvent(QWheelEvent *event) { if (event->modifiers().testFlag(Qt::ControlModifier)) { - const QPoint numDegrees = event->angleDelta() / 8; - const QPoint numSteps = numDegrees / 15; + m_controlWheelAccumulatedDelta += event->angleDelta().y(); + + if (m_controlWheelAccumulatedDelta <= -QWheelEvent::DefaultDeltasPerStep) { + slotDecreaseZoom(); + m_controlWheelAccumulatedDelta += QWheelEvent::DefaultDeltasPerStep; + } else if (m_controlWheelAccumulatedDelta >= QWheelEvent::DefaultDeltasPerStep) { + slotIncreaseZoom(); + m_controlWheelAccumulatedDelta -= QWheelEvent::DefaultDeltasPerStep; + } - setZoomLevel(zoomLevel() + numSteps.y()); event->accept(); } else { event->ignore(); diff --git a/src/views/dolphinview.h b/src/views/dolphinview.h index cadf3e754..fc5fd52ff 100644 --- a/src/views/dolphinview.h +++ b/src/views/dolphinview.h @@ -924,6 +924,10 @@ private: bool m_scrollToCurrentItem; // Used for marking we need to scroll to current item or not QPoint m_restoredContentsPosition; + // Used for tracking the accumulated scroll amount (for zooming with high + // resolution scroll wheels) + int m_controlWheelAccumulatedDelta; + QList<QUrl> m_selectedUrls; // Used for making the view to remember selections after F5 bool m_clearSelectionBeforeSelectingNewItems; bool m_markFirstNewlySelectedItemAsCurrent; |
