we do actually still want context menus on applets, even with the hover thing.

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=738430
This commit is contained in:
Aaron J. Seigo 2007-11-18 22:02:01 +00:00
parent c9ce91e944
commit 5b4dbbe303
2 changed files with 38 additions and 7 deletions

View File

@ -1189,12 +1189,14 @@ void Applet::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
//kDebug() << "context menu event!";
if (!scene()) {
//kDebug() << "no scene?!";
return;
}
Applet* containment = dynamic_cast<Plasma::Applet*>(topLevelItem());
if (!containment) {
//kDebug() << "no containment. hm.";
Widget::contextMenuEvent(event);
return;
}
@ -1202,7 +1204,6 @@ void Applet::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
// we want to pass up the context menu event to the Containment at
// this point
containment->contextMenuEvent(event);
return;
}
} // Plasma namespace

View File

@ -163,7 +163,7 @@ void Containment::contextMenuEvent(QGraphicsSceneContextMenuEvent* event)
}
KMenu desktopMenu;
//kDebug() << "context menu event " << immutable;
//kDebug() << "context menu event " << (QObject*)applet;
if (!applet) {
if (!scene() || static_cast<Corona*>(scene())->isImmutable()) {
//kDebug() << "immutability";
@ -185,9 +185,40 @@ void Containment::contextMenuEvent(QGraphicsSceneContextMenuEvent* event)
desktopMenu.addAction(action);
}
} else {
//kDebug() << "immutable applet";
QGraphicsItem::contextMenuEvent(event);
return;
bool hasEntries = false;
if (applet->hasConfigurationInterface()) {
QAction* configureApplet = new QAction(i18n("%1 Settings...", applet->name()), &desktopMenu);
connect(configureApplet, SIGNAL(triggered(bool)),
applet, SLOT(showConfigurationInterface()));
desktopMenu.addAction(configureApplet);
hasEntries = true;
}
if (scene() && !static_cast<Corona*>(scene())->isImmutable()) {
QAction* closeApplet = new QAction(i18n("Remove this %1", applet->name()), &desktopMenu);
QVariant appletV;
appletV.setValue((QObject*)applet);
closeApplet->setData(appletV);
connect(closeApplet, SIGNAL(triggered(bool)),
this, SLOT(destroyApplet()));
desktopMenu.addAction(closeApplet);
hasEntries = true;
}
QList<QAction*> actions = applet->contextActions();
if (!actions.isEmpty()) {
desktopMenu.addSeparator();
foreach(QAction* action, actions) {
desktopMenu.addAction(action);
}
hasEntries = true;
}
if (!hasEntries) {
QGraphicsItem::contextMenuEvent(event);
kDebug() << "no entries";
return;
}
}
event->accept();
@ -529,8 +560,7 @@ bool Containment::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
switch (event->type()) {
case QEvent::GraphicsSceneHoverEnter:
if (!d->immutable && !applet->isImmutable()
&& !d->handles.contains(applet)) {
if (!d->immutable && !applet->isImmutable() && !d->handles.contains(applet)) {
AppletHandle *handle = new AppletHandle(this, applet);
d->handles[applet] = handle;
connect(handle, SIGNAL(disappearDone(AppletHandle*)),