┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/middleclickactioneventfilter.cpp
diff options
context:
space:
mode:
authorDavid Hallas <[email protected]>2019-04-11 19:21:41 +0200
committerDavid Hallas <[email protected]>2019-09-29 14:16:11 +0200
commiteec49bc38f4e256b66bf16ee5428c5f5d7e97e25 (patch)
tree54d193497a3ede2cd131fdfd652541f2560d1f6f /src/middleclickactioneventfilter.cpp
parenta2730fad4323c3af0b5198a31021eed9c9a336e7 (diff)
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
Diffstat (limited to 'src/middleclickactioneventfilter.cpp')
-rw-r--r--src/middleclickactioneventfilter.cpp35
1 files changed, 26 insertions, 9 deletions
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 <QAction>
#include <QEvent>
+#include <QMenu>
#include <QMouseEvent>
#include <QToolBar>
@@ -39,16 +40,32 @@ bool MiddleClickActionEventFilter::eventFilter(QObject *watched, QEvent *event)
if (me->button() == Qt::MiddleButton) {
QToolBar *toolBar = qobject_cast<QToolBar *>(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<QMenu *>(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;
}
}
}