rightclick on popupapplet's dialog behaves like

rightclick on the applet itself

svn path=/trunk/KDE/kdelibs/; revision=1029866
This commit is contained in:
Chani Armitage 2009-09-30 23:07:42 +00:00
parent 225cab4ef4
commit cd65144478
4 changed files with 31 additions and 0 deletions

View File

@ -751,6 +751,19 @@ bool ContainmentPrivate::showContextMenu(const QPointF &point, const QPoint &scr
return false; 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) void Containment::setFormFactor(FormFactor formFactor)
{ {
if (d->formFactor == formFactor) { if (d->formFactor == formFactor) {

View File

@ -593,6 +593,7 @@ class PLASMA_EXPORT Containment : public Applet
friend class CoronaPrivate; friend class CoronaPrivate;
friend class ContainmentPrivate; friend class ContainmentPrivate;
friend class ContainmentActions; friend class ContainmentActions;
friend class PopupApplet;
ContainmentPrivate *const d; ContainmentPrivate *const d;
}; };

View File

@ -41,6 +41,7 @@
#include "plasma/private/extenderitemmimedata_p.h" #include "plasma/private/extenderitemmimedata_p.h"
#include "plasma/corona.h" #include "plasma/corona.h"
#include "plasma/containment.h" #include "plasma/containment.h"
#include "plasma/private/containment_p.h"
#include "plasma/dialog.h" #include "plasma/dialog.h"
#include "plasma/extenders/extender.h" #include "plasma/extenders/extender.h"
#include "plasma/extenders/extenderitem.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<QContextMenuEvent*>(event)->globalPos());
}
}
return Applet::eventFilter(watched, event); return Applet::eventFilter(watched, event);
} }

View File

@ -132,6 +132,12 @@ public:
Applet *appletAt(const QPointF &point); 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; Containment *q;
FormFactor formFactor; FormFactor formFactor;
Location location; Location location;