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 <QStringList>
#include <KAuthorized>
#include <KDebug>
#include <KLocale>
#include <KMenu>
#include <KMimeType>
#include <KRun>
#include <KWindowSystem>
#include <KDebug>
#include <KMimeType>
#include "applet.h"
#include "dataengine.h"
@ -271,6 +272,10 @@ void Corona::dropEvent(QGraphicsSceneDragDropEvent *event)
void Corona::contextMenuEvent(QGraphicsSceneContextMenuEvent *contextMenuEvent)
{
if (!KAuthorized::authorizeKAction("desktop_contextmenu")) {
return;
}
QPointF point = contextMenuEvent->scenePos();
/*
* example for displaying the SuperKaramba context menu
@ -285,9 +290,20 @@ void Corona::contextMenuEvent(QGraphicsSceneContextMenuEvent *contextMenuEvent)
}
*/
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;
kDebug() << "context menu event " << d->immutable << endl;
//kDebug() << "context menu event " << d->immutable << endl;
if (!applet) {
if (d->immutable) {
return;
@ -295,6 +311,8 @@ void Corona::contextMenuEvent(QGraphicsSceneContextMenuEvent *contextMenuEvent)
desktopMenu.addTitle("Plasma");
desktopMenu.addAction(d->engineExplorerAction);
} else if (applet->immutable()) {
return;
} else {
desktopMenu.addTitle(applet->name());
desktopMenu.addSeparator();