From 7476decf2987e3f6f1a1c5840fad37d12090facc Mon Sep 17 00:00:00 2001 From: Kai Uwe Broulik Date: Sun, 11 Jan 2015 17:50:52 +0100 Subject: [PATCH] Fix errorneously opening a broken context menu when middle clicking Plasma popup BUG: 342702 --- .../qml/plasmoid/appletinterface.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/scriptengines/qml/plasmoid/appletinterface.cpp b/src/scriptengines/qml/plasmoid/appletinterface.cpp index ec9622424..a27258b14 100644 --- a/src/scriptengines/qml/plasmoid/appletinterface.cpp +++ b/src/scriptengines/qml/plasmoid/appletinterface.cpp @@ -602,6 +602,8 @@ void AppletInterface::executeAction(const QString &name) bool AppletInterface::eventFilter(QObject *watched, QEvent *event) { if (event->type() == QEvent::MouseButtonPress) { + QMouseEvent *e = static_cast(event); + //pass it up to the applet //well, actually we have to pass it to the *containment* //because all the code for showing an applet's contextmenu is actually in Containment. @@ -612,13 +614,24 @@ bool AppletInterface::eventFilter(QObject *watched, QEvent *event) if (!plugin) { return false; } + + //the plugin can be a single action or a context menu + //Don't have an action list? execute as single action + //and set the event position as action data + if (plugin->contextualActions().length() == 1) { + QAction *action = plugin->contextualActions().first(); + action->setData(e->globalPos()); + action->trigger(); + return true; + } + ContainmentInterface *ci = c->property("_plasma_graphicObject").value(); QMenu desktopMenu; ci->addAppletActions(desktopMenu, applet(), event); if (!desktopMenu.isEmpty()) { - desktopMenu.exec(static_cast(event)->globalPos()); + desktopMenu.exec(e->globalPos()); return true; }