┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/middleclickactioneventfilter.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/middleclickactioneventfilter.cpp b/src/middleclickactioneventfilter.cpp
index 7f98e727e..2d943475a 100644
--- a/src/middleclickactioneventfilter.cpp
+++ b/src/middleclickactioneventfilter.cpp
@@ -7,6 +7,7 @@
#include "middleclickactioneventfilter.h"
#include <QAction>
+#include <QActionEvent>
#include <QEvent>
#include <QMenu>
#include <QMouseEvent>
@@ -55,6 +56,23 @@ bool MiddleClickActionEventFilter::eventFilter(QObject *watched, QEvent *event)
}
}
}
+
+ } else if (event->type() == QEvent::ActionChanged) {
+ // KXmlGui adds delayed popup menu's actions to its own context menu.
+ // In order for middle click to work, we need to somehow detect when the action is added
+ // on this menu and install the event filter on it.
+ // Visibility of the action changes when the menu shows in the menu for the first time,
+ // so we'll receive an ActionChanged event and use that.
+ auto *actionEvent = static_cast<QActionEvent *>(event);
+
+ const auto items = actionEvent->action()->associatedObjects();
+ for (auto *item : items) {
+ if (auto *menu = qobject_cast<QMenu *>(item)) {
+ if (menu != actionEvent->action()->parent()) { // Parent is the regular menu.
+ menu->installEventFilter(this);
+ }
+ }
+ }
}
return QObject::eventFilter(watched, event);