Add getters and setters for PopupApplet::widget() and PopupApplet::graphicsWidget()

for use in scripting languages. Add a initScriptingExtenderItem() signal for script
engines to connect to and call their versions of Applet::initExtenderItem()


svn path=/trunk/KDE/kdelibs/; revision=998323
This commit is contained in:
Richard Dale 2009-07-17 12:31:08 +00:00
parent d9d08c94e0
commit 695168a4bd
5 changed files with 36 additions and 7 deletions

View File

@ -666,12 +666,16 @@ void Applet::constraintsEvent(Plasma::Constraints constraints)
void Applet::initExtenderItem(ExtenderItem *item) void Applet::initExtenderItem(ExtenderItem *item)
{ {
if (d->script) {
emit initScriptExtenderItem(item);
} else {
kWarning() << "Missing implementation of initExtenderItem in the applet " kWarning() << "Missing implementation of initExtenderItem in the applet "
<< item->config().readEntry("SourceAppletPluginName", "") << item->config().readEntry("SourceAppletPluginName", "")
<< "!\n Any applet that uses extenders should implement initExtenderItem to " << "!\n Any applet that uses extenders should implement initExtenderItem to "
<< "instantiate a widget. Destroying the item..."; << "instantiate a widget. Destroying the item...";
item->destroy(); item->destroy();
} }
}
Extender *Applet::extender() const Extender *Applet::extender() const
{ {

View File

@ -693,6 +693,11 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget
*/ */
void newStatus(Plasma::ItemStatus status); 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: public Q_SLOTS:
/** /**
* Sets the immutability type for this applet (not immutable, * Sets the immutability type for this applet (not immutable,

View File

@ -112,13 +112,27 @@ QIcon PopupApplet::popupIcon() const
QWidget *PopupApplet::widget() QWidget *PopupApplet::widget()
{ {
return 0; return d->widget;
}
void PopupApplet::setWidget(QWidget * widget)
{
d->widget = widget;
} }
QGraphicsWidget *PopupApplet::graphicsWidget() QGraphicsWidget *PopupApplet::graphicsWidget()
{ {
if (d->graphicsWidget != 0) {
return d->graphicsWidget;
} else {
return static_cast<Applet*>(this)->d->extender; return static_cast<Applet*>(this)->d->extender;
} }
}
void PopupApplet::setGraphicsWidget(QGraphicsWidget * graphicsWidget)
{
d->graphicsWidget = graphicsWidget;
}
void PopupAppletPrivate::checkExtenderAppearance(Plasma::FormFactor f) void PopupAppletPrivate::checkExtenderAppearance(Plasma::FormFactor f)
{ {
@ -486,6 +500,8 @@ PopupAppletPrivate::PopupAppletPrivate(PopupApplet *applet)
icon(0), icon(0),
dialog(0), dialog(0),
proxy(0), proxy(0),
widget(0),
graphicsWidget(0),
popupPlacement(Plasma::FloatingPopup), popupPlacement(Plasma::FloatingPopup),
savedAspectRatio(Plasma::InvalidAspectRatioMode), savedAspectRatio(Plasma::InvalidAspectRatioMode),
timer(0), timer(0),

View File

@ -77,6 +77,7 @@ public:
* depending on the form factor of the applet. * depending on the form factor of the applet.
*/ */
virtual QWidget *widget(); virtual QWidget *widget();
void setWidget(QWidget * widget);
/** /**
* Implement either this function or widget(). * Implement either this function or widget().
@ -84,6 +85,7 @@ public:
* depending on the form factor of the applet. * depending on the form factor of the applet.
*/ */
virtual QGraphicsWidget *graphicsWidget(); virtual QGraphicsWidget *graphicsWidget();
void setGraphicsWidget(QGraphicsWidget * widget);
/** /**
* @return the placement of the popup relating to the icon * @return the placement of the popup relating to the icon

View File

@ -44,6 +44,8 @@ public:
Plasma::IconWidget *icon; Plasma::IconWidget *icon;
QPointer<Plasma::Dialog> dialog; QPointer<Plasma::Dialog> dialog;
QGraphicsProxyWidget *proxy; QGraphicsProxyWidget *proxy;
QWidget *widget;
QGraphicsWidget *graphicsWidget;
Plasma::PopupPlacement popupPlacement; Plasma::PopupPlacement popupPlacement;
Plasma::AspectRatioMode savedAspectRatio; Plasma::AspectRatioMode savedAspectRatio;
QTimer *timer; QTimer *timer;