From eec49bc38f4e256b66bf16ee5428c5f5d7e97e25 Mon Sep 17 00:00:00 2001 From: David Hallas Date: Thu, 11 Apr 2019 19:21:41 +0200 Subject: Add navigation history to forward/back buttons Summary: Adds navigation history to forward/back buttons in the toolbar. This changes the forward/back buttons in the toolbar to use the KToolBarPopupAction class which provides access to a drop down menu. Test Plan: Browse some folders Click the back drop down menu and navigate somewhere Click the forward drop down menu and navigate somewhere FEATURE: 157819 FIXED-IN: 19.12.0 Reviewers: #dolphin, ngraham, elvisangelaccio, #vdg Reviewed By: #dolphin, ngraham, elvisangelaccio, #vdg Subscribers: felixernst, nerdopolist, mart, richardl, ognarb, david.fontanals, abetts, kfm-devel Tags: #dolphin Differential Revision: https://phabricator.kde.org/D19311 --- src/middleclickactioneventfilter.cpp | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) (limited to 'src/middleclickactioneventfilter.cpp') diff --git a/src/middleclickactioneventfilter.cpp b/src/middleclickactioneventfilter.cpp index e0917850a..293e16e0c 100644 --- a/src/middleclickactioneventfilter.cpp +++ b/src/middleclickactioneventfilter.cpp @@ -21,6 +21,7 @@ #include #include +#include #include #include @@ -39,16 +40,32 @@ bool MiddleClickActionEventFilter::eventFilter(QObject *watched, QEvent *event) if (me->button() == Qt::MiddleButton) { QToolBar *toolBar = qobject_cast(watched); - - QAction *action = toolBar->actionAt(me->pos()); - if (action) { - if (event->type() == QEvent::MouseButtonPress) { - m_lastMiddlePressedAction = action; - } else if (event->type() == QEvent::MouseButtonRelease) { - if (m_lastMiddlePressedAction == action) { - emit actionMiddleClicked(action); + if (toolBar) { + QAction *action = toolBar->actionAt(me->pos()); + if (action) { + if (event->type() == QEvent::MouseButtonPress) { + m_lastMiddlePressedAction = action; + } else if (event->type() == QEvent::MouseButtonRelease) { + if (m_lastMiddlePressedAction == action) { + emit actionMiddleClicked(action); + } + m_lastMiddlePressedAction = nullptr; + } + } + } + QMenu *menu = qobject_cast(watched); + if (menu) { + QAction *action = menu->actionAt(me->pos()); + if (action) { + if (event->type() == QEvent::MouseButtonPress) { + m_lastMiddlePressedAction = action; + } else if (event->type() == QEvent::MouseButtonRelease) { + if (m_lastMiddlePressedAction == action) { + emit actionMiddleClicked(action); + return true; + } + m_lastMiddlePressedAction = nullptr; } - m_lastMiddlePressedAction = nullptr; } } } -- cgit v1.3