Add invokable public API for emitting contextualActionsAboutToShow

Summary:
This signal is emitted just before showing the context menu to allow
lazy-loading expensive actions like hasAlternatives.

This emitted by our code whenever we show a context menu from an event
filter, however we want to use this code from a tooltip in D17410

Test Plan:
Hovered over some applets, they correctly enabled/disabled the
alternatives button

Reviewers: #plasma

Subscribers: kde-frameworks-devel

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D20417
This commit is contained in:
David Edmundson 2019-04-09 22:15:54 +01:00
parent 417a82b1b9
commit 83d85dc228
2 changed files with 14 additions and 1 deletions

View File

@ -784,6 +784,11 @@ bool AppletInterface::event(QEvent *event)
return AppletQuickItem::event(event);
}
void AppletInterface::prepareContextualActions()
{
emit applet()->contextualActionsAboutToShow();
}
bool AppletInterface::eventFilter(QObject *watched, QEvent *event)
{
if (event->type() == QEvent::MouseButtonPress) {
@ -825,7 +830,7 @@ bool AppletInterface::eventFilter(QObject *watched, QEvent *event)
if (desktopMenu->winId()) {
desktopMenu->windowHandle()->setTransientParent(window());
}
emit applet()->contextualActionsAboutToShow();
prepareContextualActions();
ci->addAppletActions(desktopMenu, applet(), event);
if (!desktopMenu->isEmpty()) {

View File

@ -277,6 +277,14 @@ public:
Q_INVOKABLE QAction *action(QString name) const;
/**
* Should be called before retrieving any action
* to ensure contents are up to date
* @see contextualActionsAboutToShow
* @since 5.58
*/
Q_INVOKABLE void prepareContextualActions();
/**
* FIXME: remove?
* Retrieve the path of a file from the Plasmoid package