From 9fa4ea3ec37f8909a3677a832a0ffa6ebfb0b3fe Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Wed, 26 Sep 2007 23:01:57 +0000 Subject: [PATCH] - remove deprecated createInstance call - as Containment is going to remain an Applet, we can put the context menu hack in Applet instead which is nicer on the widgets anyways. also make it a bit less of a hack... svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=717489 --- applet.cpp | 23 ++++++++++++++++++++++- applet.h | 5 +++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/applet.cpp b/applet.cpp index 834bc6ade..25bd0a298 100644 --- a/applet.cpp +++ b/applet.cpp @@ -990,7 +990,7 @@ Applet* Applet::loadApplet(const QString& appletName, uint appletId, const QVari QVariantList allArgs; allArgs << offers.first()->storageId() << appletId << args; QString error; - Applet* applet = KService::createInstance(offers.first(), 0, allArgs, &error); + Applet* applet = offers.first()->createInstance(0, allArgs, &error); if (!applet) { kDebug() << "Couldn't load applet \"" << appletName << "\"! reason given: " << error; @@ -1073,6 +1073,27 @@ QVariant Applet::itemChange(GraphicsItemChange change, const QVariant &value) return QGraphicsItem::itemChange(change, value); } +void Applet::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) +{ + //kDebug() << "context menu event!"; + if (!scene()) { + return; + } + + Applet* containment = dynamic_cast(topLevelItem()); + + if (!containment) { + Widget::contextMenuEvent(event); + return; + } + + // we want to pass up the context menu event to the Containment at + // this point + containment->contextMenuEvent(event); + return; +} + + } // Plasma namespace #include "applet.moc" diff --git a/applet.h b/applet.h index ff60bbc71..88793fe97 100644 --- a/applet.h +++ b/applet.h @@ -553,6 +553,11 @@ class PLASMA_EXPORT Applet : public Widget **/ bool eventFilter( QObject *o, QEvent *e ); + /** + * Reimplemented from QGraphicsItem + */ + void contextMenuEvent(QGraphicsSceneContextMenuEvent *contextMenuEvent); + /** * @internal for adjusting the shadow */