diff --git a/applet.cpp b/applet.cpp index d87f53959..f86f64d7f 100644 --- a/applet.cpp +++ b/applet.cpp @@ -666,11 +666,15 @@ void Applet::constraintsEvent(Plasma::Constraints constraints) void Applet::initExtenderItem(ExtenderItem *item) { - kWarning() << "Missing implementation of initExtenderItem in the applet " - << item->config().readEntry("SourceAppletPluginName", "") - << "!\n Any applet that uses extenders should implement initExtenderItem to " - << "instantiate a widget. Destroying the item..."; - item->destroy(); + if (d->script) { + emit initScriptExtenderItem(item); + } else { + kWarning() << "Missing implementation of initExtenderItem in the applet " + << item->config().readEntry("SourceAppletPluginName", "") + << "!\n Any applet that uses extenders should implement initExtenderItem to " + << "instantiate a widget. Destroying the item..."; + item->destroy(); + } } Extender *Applet::extender() const diff --git a/applet.h b/applet.h index 53cae4ee3..96a40ea1a 100644 --- a/applet.h +++ b/applet.h @@ -693,6 +693,11 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget */ void newStatus(Plasma::ItemStatus status); + /** + * Emitted when an ExtenderItem in a scripting applet needs to be initialized + */ + void initScriptExtenderItem(Plasma::ExtenderItem *item); + public Q_SLOTS: /** * Sets the immutability type for this applet (not immutable, diff --git a/popupapplet.cpp b/popupapplet.cpp index 83251362f..e2b93b2d8 100644 --- a/popupapplet.cpp +++ b/popupapplet.cpp @@ -112,12 +112,26 @@ QIcon PopupApplet::popupIcon() const QWidget *PopupApplet::widget() { - return 0; + return d->widget; +} + +void PopupApplet::setWidget(QWidget * widget) +{ + d->widget = widget; } QGraphicsWidget *PopupApplet::graphicsWidget() { - return static_cast(this)->d->extender; + if (d->graphicsWidget != 0) { + return d->graphicsWidget; + } else { + return static_cast(this)->d->extender; + } +} + +void PopupApplet::setGraphicsWidget(QGraphicsWidget * graphicsWidget) +{ + d->graphicsWidget = graphicsWidget; } void PopupAppletPrivate::checkExtenderAppearance(Plasma::FormFactor f) @@ -486,6 +500,8 @@ PopupAppletPrivate::PopupAppletPrivate(PopupApplet *applet) icon(0), dialog(0), proxy(0), + widget(0), + graphicsWidget(0), popupPlacement(Plasma::FloatingPopup), savedAspectRatio(Plasma::InvalidAspectRatioMode), timer(0), diff --git a/popupapplet.h b/popupapplet.h index 17d9833fb..7855961ea 100644 --- a/popupapplet.h +++ b/popupapplet.h @@ -77,6 +77,7 @@ public: * depending on the form factor of the applet. */ virtual QWidget *widget(); + void setWidget(QWidget * widget); /** * Implement either this function or widget(). @@ -84,6 +85,7 @@ public: * depending on the form factor of the applet. */ virtual QGraphicsWidget *graphicsWidget(); + void setGraphicsWidget(QGraphicsWidget * widget); /** * @return the placement of the popup relating to the icon diff --git a/private/popupapplet_p.h b/private/popupapplet_p.h index 571ffe4ed..37ef19a0c 100644 --- a/private/popupapplet_p.h +++ b/private/popupapplet_p.h @@ -44,6 +44,8 @@ public: Plasma::IconWidget *icon; QPointer dialog; QGraphicsProxyWidget *proxy; + QWidget *widget; + QGraphicsWidget *graphicsWidget; Plasma::PopupPlacement popupPlacement; Plasma::AspectRatioMode savedAspectRatio; QTimer *timer;