From 499e8723f4b82ed1e9abbee91594ab8170421e11 Mon Sep 17 00:00:00 2001 From: Frank Reininghaus Date: Sun, 25 Oct 2009 10:41:15 +0000 Subject: Do not zoom the icons if the user presses Control and the left mouse button while using the mouse wheel. The user is probably trying to scroll the view during a rubberband selection in that case. Also simplify the code a bit by handling the icon zooming in DolphinView::eventFilter(). BUG: 190703 svn path=/trunk/KDE/kdebase/apps/; revision=1040021 --- src/dolphinview.cpp | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'src/dolphinview.cpp') diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp index a49aabdd9..034b81d3f 100644 --- a/src/dolphinview.cpp +++ b/src/dolphinview.cpp @@ -831,20 +831,6 @@ void DolphinView::mouseReleaseEvent(QMouseEvent* event) setActive(true); } -void DolphinView::wheelEvent(QWheelEvent* event) -{ - if (event->modifiers() & Qt::ControlModifier) { - const int delta = event->delta(); - const int level = zoomLevel(); - if (delta > 0) { - setZoomLevel(level + 1); - } else if (delta < 0) { - setZoomLevel(level - 1); - } - event->accept(); - } -} - bool DolphinView::eventFilter(QObject* watched, QEvent* event) { switch (event->type()) { @@ -870,6 +856,24 @@ bool DolphinView::eventFilter(QObject* watched, QEvent* event) } break; + case QEvent::Wheel: + if (watched == m_viewAccessor.itemView()->viewport()) { + // Ctrl+wheel events should cause icon zooming, but not if the left mouse button is pressed + // (the user is probably trying to scroll during a selection in that case) + QWheelEvent* wheelEvent = static_cast(event); + if (wheelEvent->modifiers() & Qt::ControlModifier && !(wheelEvent->buttons() & Qt::LeftButton)) { + const int delta = wheelEvent->delta(); + const int level = zoomLevel(); + if (delta > 0) { + setZoomLevel(level + 1); + } else if (delta < 0) { + setZoomLevel(level - 1); + } + return true; + } + } + break; + default: break; } -- cgit v1.3