diff --git a/applet.cpp b/applet.cpp index 6823231eb..da4df013c 100644 --- a/applet.cpp +++ b/applet.cpp @@ -1314,27 +1314,6 @@ bool Applet::isContainment() const return d->isContainment; } -void Applet::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) -{ - //kDebug() << "context menu event!"; - if (!scene()) { - //kDebug() << "no scene?!"; - return; - } - - Applet* containment = dynamic_cast(topLevelItem()); - - if (!containment || containment == this) { - //kDebug() << "no containment. hm."; - Widget::contextMenuEvent(event); - return; - } - - // we want to pass up the context menu event to the Containment at - // this point - containment->contextMenuEvent(event); -} - } // Plasma namespace #include "applet.moc" diff --git a/applet.h b/applet.h index 6090674a4..1e14550a9 100644 --- a/applet.h +++ b/applet.h @@ -636,11 +636,6 @@ class PLASMA_EXPORT Applet : public Widget **/ bool eventFilter( QObject *o, QEvent *e ); - /** - * Reimplemented from QGraphicsItem - */ - void contextMenuEvent(QGraphicsSceneContextMenuEvent *contextMenuEvent); - /** * Reimplemented from QGraphicsItem */ diff --git a/widgets/widget.cpp b/widgets/widget.cpp index 1450a5ec1..4d843860a 100644 --- a/widgets/widget.cpp +++ b/widgets/widget.cpp @@ -519,5 +519,15 @@ void Widget::managingLayoutChanged() } } +void Widget::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) +{ + // HACK: QGraphicsItem's documentation says that the event will be + // passed to the parent if it's not handled, but it isn't passed. + Widget *parentWidget = parent(); + if (parentWidget) { + parentWidget->contextMenuEvent(event); + } +} + } // Plasma namespace diff --git a/widgets/widget.h b/widgets/widget.h index 3684cc201..4f3f09337 100644 --- a/widgets/widget.h +++ b/widgets/widget.h @@ -271,6 +271,12 @@ protected: * @param widget the parent QWidget (most likely the Corona) */ virtual void paintWidget(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); + + /** + * Reimplemented from QGraphicsItem + */ + virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *event); + QVariant itemChange(GraphicsItemChange change, const QVariant &value); void setSize(qreal width, qreal height); void setSize(const QSizeF& size);