* Allow scripting PopupApplets to be created if the metadata.desktop for the

applet has a 'ServiceTypes=Plasma/PopupApplet' line

svn path=/branches/KDE/4.2/kdelibs/; revision=958045
This commit is contained in:
Richard Dale 2009-04-23 10:56:21 +00:00
parent 7334b569d0
commit bf61997a9f

View File

@ -1572,14 +1572,27 @@ Applet *Applet::load(const QString &appletName, uint appletId, const QVariantLis
//TODO: what would be -really- cool is offer to try and download the applet
// from the network at this point
offers = KServiceTypeTrader::self()->query("Plasma/Containment", constraint);
if (offers.count() > 0) {
isContainment = true;
}
}
bool isPopupApplet = false;
if (offers.isEmpty()) {
offers = KServiceTypeTrader::self()->query("Plasma/PopupApplet", constraint);
if (offers.count() > 0) {
isPopupApplet = true;
}
}
/* if (offers.count() > 1) {
kDebug() << "hey! we got more than one! let's blindly take the first one";
} */
if (offers.isEmpty()) {
kDebug() << "offers is empty for " << appletName;
return 0;
}
} /* else if (offers.count() > 1) {
kDebug() << "hey! we got more than one! let's blindly take the first one";
} */
KService::Ptr offer = offers.first();
@ -1587,13 +1600,19 @@ Applet *Applet::load(const QString &appletName, uint appletId, const QVariantLis
appletId = ++AppletPrivate::s_maxAppletId;
}
QVariantList allArgs;
allArgs << offer->storageId() << appletId << args;
if (!offer->property("X-Plasma-API").toString().isEmpty()) {
kDebug() << "we have a script using the"
<< offer->property("X-Plasma-API").toString() << "API";
if (isContainment) {
return new Containment(0, offer->storageId(), appletId);
return new Containment(0, allArgs);
} else if (isPopupApplet) {
return new PopupApplet(0, allArgs);
} else {
return new Applet(0, allArgs);
}
return new Applet(0, offer->storageId(), appletId);
}
KPluginLoader plugin(*offer);
@ -1603,8 +1622,6 @@ Applet *Applet::load(const QString &appletName, uint appletId, const QVariantLis
return 0;
}
QVariantList allArgs;
allArgs << offer->storageId() << appletId << args;
QString error;
Applet *applet;