diff --git a/containment.cpp b/containment.cpp index 64db344d6..369f3bd65 100644 --- a/containment.cpp +++ b/containment.cpp @@ -751,6 +751,19 @@ bool ContainmentPrivate::showContextMenu(const QPointF &point, const QPoint &scr return false; } +bool ContainmentPrivate::showAppletContextMenu(Applet *applet, const QPoint &screenPos) +{ + KMenu desktopMenu; + appletActions(desktopMenu, applet, true); + + if (!desktopMenu.isEmpty()) { + desktopMenu.exec(screenPos); + return true; + } + + return false; +} + void Containment::setFormFactor(FormFactor formFactor) { if (d->formFactor == formFactor) { diff --git a/containment.h b/containment.h index dfa43f91f..cc9ae41c1 100644 --- a/containment.h +++ b/containment.h @@ -593,6 +593,7 @@ class PLASMA_EXPORT Containment : public Applet friend class CoronaPrivate; friend class ContainmentPrivate; friend class ContainmentActions; + friend class PopupApplet; ContainmentPrivate *const d; }; diff --git a/popupapplet.cpp b/popupapplet.cpp index 5061d15d3..389a63013 100644 --- a/popupapplet.cpp +++ b/popupapplet.cpp @@ -41,6 +41,7 @@ #include "plasma/private/extenderitemmimedata_p.h" #include "plasma/corona.h" #include "plasma/containment.h" +#include "plasma/private/containment_p.h" #include "plasma/dialog.h" #include "plasma/extenders/extender.h" #include "plasma/extenders/extenderitem.h" @@ -419,6 +420,16 @@ bool PopupApplet::eventFilter(QObject *watched, QEvent *event) } */ + if (watched == d->dialog && event->type() == QEvent::ContextMenu) { + //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. + Containment *c = containment(); + if (c) { + return c->d->showAppletContextMenu(this, static_cast(event)->globalPos()); + } + } + return Applet::eventFilter(watched, event); } diff --git a/private/containment_p.h b/private/containment_p.h index e6d69f927..199184b68 100644 --- a/private/containment_p.h +++ b/private/containment_p.h @@ -132,6 +132,12 @@ public: Applet *appletAt(const QPointF &point); + /** + * force the contextmenu for @p applet to be shown at @p screenPos + * @since 4.4 + */ + bool showAppletContextMenu(Applet *applet, const QPoint &screenPos); + Containment *q; FormFactor formFactor; Location location;