Move the "call the parent's contextMenuEvent()" hack from Applet into

Widget so that applets with embedded widgets also get the containment's
context menu.

BUG: 152698

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=749078
This commit is contained in:
Jason Stubbs 2007-12-16 13:21:16 +00:00
parent 4fb7cbc2d6
commit 1dc5cc58fc
4 changed files with 16 additions and 26 deletions

View File

@ -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<Plasma::Applet*>(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"

View File

@ -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
*/

View File

@ -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

View File

@ -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);