From 88ec6de11392710df72f2bab6139dc385596743a Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Mon, 29 Feb 2016 11:59:10 +0000 Subject: [PATCH] Move contextualActionsAboutToShow to Applet Applet contains the menu actions, therefore reloading the menu should happen in Applet not AppletInterface. With AppletInterface being a dumb wrapper. This exposes functionality to anyone who overrides Applet, but also will also allows system tray to emit this signal without having to use private API. Change-Id: I95e65de315744a78a82ebba2a954e4f3ae1bd7b2 REVIEW: 127217 --- src/plasma/applet.h | 7 +++++++ src/scriptengines/qml/plasmoid/appletinterface.cpp | 3 +++ src/scriptengines/qml/plasmoid/containmentinterface.cpp | 4 ++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/plasma/applet.h b/src/plasma/applet.h index df57e945b..2c540d962 100644 --- a/src/plasma/applet.h +++ b/src/plasma/applet.h @@ -426,6 +426,13 @@ Q_SIGNALS: void userConfiguringChanged(bool configuring); //ACTIONS + /** + * Emitted just before the contextual actions are about to show + * For instance just before the context menu containing the actions + * added with setAction() is shown + */ + void contextualActionsAboutToShow(); + /** * Emitted when activation is requested due to, for example, a global * keyboard shortcut. By default the wiget is given focus. diff --git a/src/scriptengines/qml/plasmoid/appletinterface.cpp b/src/scriptengines/qml/plasmoid/appletinterface.cpp index 70bc5d371..6e949e0cc 100644 --- a/src/scriptengines/qml/plasmoid/appletinterface.cpp +++ b/src/scriptengines/qml/plasmoid/appletinterface.cpp @@ -71,6 +71,9 @@ AppletInterface::AppletInterface(DeclarativeAppletScript *script, const QVariant connect(applet(), &Plasma::Applet::userConfiguringChanged, this, &AppletInterface::userConfiguringChanged); + connect(applet(), &Plasma::Applet::contextualActionsAboutToShow, + this, &AppletInterface::contextualActionsAboutToShow); + connect(applet(), &Plasma::Applet::statusChanged, this, &AppletInterface::statusChanged); diff --git a/src/scriptengines/qml/plasmoid/containmentinterface.cpp b/src/scriptengines/qml/plasmoid/containmentinterface.cpp index bdb3c4aa5..845bb4dc4 100644 --- a/src/scriptengines/qml/plasmoid/containmentinterface.cpp +++ b/src/scriptengines/qml/plasmoid/containmentinterface.cpp @@ -924,7 +924,6 @@ void ContainmentInterface::mousePressEvent(QMouseEvent *event) if (AppletInterface *ai = qobject_cast(appletObject)) { if (ai->isVisible() && ai->contains(ai->mapFromItem(this, event->posF()))) { applet = ai->applet(); - emit ai->contextualActionsAboutToShow(); break; } else { ai = 0; @@ -938,9 +937,10 @@ void ContainmentInterface::mousePressEvent(QMouseEvent *event) m_contextMenu = &desktopMenu; if (applet) { + emit applet->contextualActionsAboutToShow(); addAppletActions(desktopMenu, applet, event); } else { - emit contextualActionsAboutToShow(); + emit m_containment->contextualActionsAboutToShow(); addContainmentActions(desktopMenu, event); }