ok, now any right click on an applet gets the applet right click menu.

obviously this is fairly broken as now applets can't provide right click menus for anything. i have some thoughts on how to fix this but need to consider it more.

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=678566
This commit is contained in:
Aaron J. Seigo 2007-06-21 18:25:09 +00:00
parent c2815e1f84
commit bac0859be5

View File

@ -27,12 +27,13 @@
#include <QGraphicsView> #include <QGraphicsView>
#include <QStringList> #include <QStringList>
#include <KAuthorized>
#include <KDebug>
#include <KLocale> #include <KLocale>
#include <KMenu> #include <KMenu>
#include <KMimeType>
#include <KRun> #include <KRun>
#include <KWindowSystem> #include <KWindowSystem>
#include <KDebug>
#include <KMimeType>
#include "applet.h" #include "applet.h"
#include "dataengine.h" #include "dataengine.h"
@ -271,6 +272,10 @@ void Corona::dropEvent(QGraphicsSceneDragDropEvent *event)
void Corona::contextMenuEvent(QGraphicsSceneContextMenuEvent *contextMenuEvent) void Corona::contextMenuEvent(QGraphicsSceneContextMenuEvent *contextMenuEvent)
{ {
if (!KAuthorized::authorizeKAction("desktop_contextmenu")) {
return;
}
QPointF point = contextMenuEvent->scenePos(); QPointF point = contextMenuEvent->scenePos();
/* /*
* example for displaying the SuperKaramba context menu * example for displaying the SuperKaramba context menu
@ -285,9 +290,20 @@ void Corona::contextMenuEvent(QGraphicsSceneContextMenuEvent *contextMenuEvent)
} }
*/ */
contextMenuEvent->accept(); contextMenuEvent->accept();
Applet* applet = qgraphicsitem_cast<Applet*>(itemAt(point)); QGraphicsItem* item = itemAt(point);
Applet* applet = 0;
while (item) {
applet = qgraphicsitem_cast<Applet*>(item);
if (applet) {
break;
}
item = item->parentItem();
}
KMenu desktopMenu; KMenu desktopMenu;
kDebug() << "context menu event " << d->immutable << endl; //kDebug() << "context menu event " << d->immutable << endl;
if (!applet) { if (!applet) {
if (d->immutable) { if (d->immutable) {
return; return;
@ -295,6 +311,8 @@ void Corona::contextMenuEvent(QGraphicsSceneContextMenuEvent *contextMenuEvent)
desktopMenu.addTitle("Plasma"); desktopMenu.addTitle("Plasma");
desktopMenu.addAction(d->engineExplorerAction); desktopMenu.addAction(d->engineExplorerAction);
} else if (applet->immutable()) {
return;
} else { } else {
desktopMenu.addTitle(applet->name()); desktopMenu.addTitle(applet->name());
desktopMenu.addSeparator(); desktopMenu.addSeparator();