mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-12 12:54:29 +00:00
Fix zooming for high resolution scroll wheels
BUG: 432671
This commit is contained in:
parent
c57c5384fc
commit
b168f9a98b
|
@ -931,6 +931,11 @@ bool DolphinView::eventFilter(QObject *watched, QEvent *event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case QEvent::KeyRelease:
|
||||||
|
if (static_cast<QKeyEvent *>(event)->key() == Qt::Key_Control) {
|
||||||
|
m_controlWheelAccumulatedDelta = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case QEvent::FocusIn:
|
case QEvent::FocusIn:
|
||||||
if (watched == m_container) {
|
if (watched == m_container) {
|
||||||
setActive(true);
|
setActive(true);
|
||||||
|
@ -969,10 +974,16 @@ bool DolphinView::eventFilter(QObject *watched, QEvent *event)
|
||||||
void DolphinView::wheelEvent(QWheelEvent *event)
|
void DolphinView::wheelEvent(QWheelEvent *event)
|
||||||
{
|
{
|
||||||
if (event->modifiers().testFlag(Qt::ControlModifier)) {
|
if (event->modifiers().testFlag(Qt::ControlModifier)) {
|
||||||
const QPoint numDegrees = event->angleDelta() / 8;
|
m_controlWheelAccumulatedDelta += event->angleDelta().y();
|
||||||
const QPoint numSteps = numDegrees / 15;
|
|
||||||
|
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();
|
event->accept();
|
||||||
} else {
|
} else {
|
||||||
event->ignore();
|
event->ignore();
|
||||||
|
|
|
@ -924,6 +924,10 @@ private:
|
||||||
bool m_scrollToCurrentItem; // Used for marking we need to scroll to current item or not
|
bool m_scrollToCurrentItem; // Used for marking we need to scroll to current item or not
|
||||||
QPoint m_restoredContentsPosition;
|
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
|
QList<QUrl> m_selectedUrls; // Used for making the view to remember selections after F5
|
||||||
bool m_clearSelectionBeforeSelectingNewItems;
|
bool m_clearSelectionBeforeSelectingNewItems;
|
||||||
bool m_markFirstNewlySelectedItemAsCurrent;
|
bool m_markFirstNewlySelectedItemAsCurrent;
|
||||||
|
|
Loading…
Reference in a new issue