From kde-commits Wed Sep 30 23:07:43 2009 From: Chani Armitage Date: Wed, 30 Sep 2009 23:07:43 +0000 To: kde-commits Subject: KDE/kdelibs/plasma Message-Id: <1254352063.867267.627.nullmailer () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=125435207121022 SVN commit 1029866 by chani: rightclick on popupapplet's dialog behaves like rightclick on the applet itself M +13 -0 containment.cpp M +1 -0 containment.h M +11 -0 popupapplet.cpp M +6 -0 private/containment_p.h --- trunk/KDE/kdelibs/plasma/containment.cpp #1029865:1029866 @@ -751,6 +751,19 @@ 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) { --- trunk/KDE/kdelibs/plasma/containment.h #1029865:1029866 @@ -593,6 +593,7 @@ friend class CoronaPrivate; friend class ContainmentPrivate; friend class ContainmentActions; + friend class PopupApplet; ContainmentPrivate *const d; }; --- trunk/KDE/kdelibs/plasma/popupapplet.cpp #1029865:1029866 @@ -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 @@ } */ + 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); } --- trunk/KDE/kdelibs/plasma/private/containment_p.h #1029865:1029866 @@ -132,6 +132,12 @@ 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;