Make sure the args part of Containment::createApplet(..., args) ends up in the applet.
This commit is contained in:
parent
556c1e321a
commit
1805bb7496
@ -90,7 +90,7 @@ Applet::Applet(QObject *parentObject, const QVariantList &args)
|
||||
|
||||
// WARNING: do not access config() OR globalConfig() in this method!
|
||||
// that requires a scene, which is not available at this point
|
||||
d->init();
|
||||
d->init(QString(), args.mid(2));
|
||||
d->setupPackage();
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ DataEngine::DataEngine(const KPluginInfo &plugin, QObject *parent)
|
||||
|
||||
DataEngine::DataEngine(QObject *parent, const QVariantList &args)
|
||||
: QObject(parent),
|
||||
d(new DataEnginePrivate(this, KPluginInfo(args)))
|
||||
d(new DataEnginePrivate(this, KPluginInfo(args), args))
|
||||
{
|
||||
if (d->script) {
|
||||
d->setupScriptSupport();
|
||||
@ -406,7 +406,7 @@ void DataEngine::setStorageEnabled(const QString &source, bool store)
|
||||
}
|
||||
|
||||
// Private class implementations
|
||||
DataEnginePrivate::DataEnginePrivate(DataEngine *e, const KPluginInfo &info)
|
||||
DataEnginePrivate::DataEnginePrivate(DataEngine *e, const KPluginInfo &info, const QVariantList &args)
|
||||
: q(e),
|
||||
dataEngineDescription(info),
|
||||
refCount(-1), // first ref
|
||||
@ -437,7 +437,7 @@ DataEnginePrivate::DataEnginePrivate(DataEngine *e, const KPluginInfo &info)
|
||||
package->setPath(path);
|
||||
|
||||
if (package->isValid()) {
|
||||
script = Plasma::loadScriptEngine(api, q);
|
||||
script = Plasma::loadScriptEngine(api, q, args);
|
||||
}
|
||||
|
||||
if (!script) {
|
||||
|
@ -97,7 +97,7 @@ AppletPrivate::~AppletPrivate()
|
||||
delete modificationsTimer;
|
||||
}
|
||||
|
||||
void AppletPrivate::init(const QString &packagePath)
|
||||
void AppletPrivate::init(const QString &packagePath, const QVariantList &args)
|
||||
{
|
||||
// WARNING: do not access config() OR globalConfig() in this method!
|
||||
// that requires a Corona, which is not available at this point
|
||||
@ -145,7 +145,7 @@ void AppletPrivate::init(const QString &packagePath)
|
||||
// now we try and set up the script engine.
|
||||
// it will be parented to this applet and so will get
|
||||
// deleted when the applet does
|
||||
script = Plasma::loadScriptEngine(api, q);
|
||||
script = Plasma::loadScriptEngine(api, q, args);
|
||||
|
||||
if (!script) {
|
||||
delete package;
|
||||
|
@ -46,7 +46,7 @@ public:
|
||||
AppletPrivate(KService::Ptr service, const KPluginInfo *info, int uniqueID, Applet *applet);
|
||||
virtual ~AppletPrivate();
|
||||
|
||||
void init(const QString &packagePath = QString());
|
||||
void init(const QString &packagePath = QString(), const QVariantList &args = QVariantList());
|
||||
|
||||
// the interface
|
||||
virtual void showConfigurationRequiredMessage(bool show, const QString &reason);
|
||||
|
@ -34,7 +34,7 @@ class Service;
|
||||
class DataEnginePrivate
|
||||
{
|
||||
public:
|
||||
DataEnginePrivate(DataEngine *e, const KPluginInfo &info);
|
||||
DataEnginePrivate(DataEngine *e, const KPluginInfo &info, const QVariantList &args = QVariantList());
|
||||
~DataEnginePrivate();
|
||||
DataContainer *source(const QString &sourceName, bool createWhenMissing = true);
|
||||
void connectSource(DataContainer *s, QObject *visualization, uint pollingInterval,
|
||||
|
@ -139,11 +139,11 @@ KService::List engineOffers(const QString &language, Types::ComponentType type)
|
||||
return offers;
|
||||
}
|
||||
|
||||
ScriptEngine *loadEngine(const QString &language, Types::ComponentType type, QObject *parent)
|
||||
ScriptEngine *loadEngine(const QString &language, Types::ComponentType type, QObject *parent,
|
||||
const QVariantList &args = QVariantList())
|
||||
{
|
||||
KService::List offers = engineOffers(language, type);
|
||||
|
||||
QVariantList args;
|
||||
QString error;
|
||||
|
||||
ScriptEngine *engine = 0;
|
||||
@ -176,10 +176,10 @@ ScriptEngine *loadEngine(const QString &language, Types::ComponentType type, QOb
|
||||
return 0;
|
||||
}
|
||||
|
||||
AppletScript *loadScriptEngine(const QString &language, Applet *applet)
|
||||
AppletScript *loadScriptEngine(const QString &language, Applet *applet, const QVariantList &args)
|
||||
{
|
||||
AppletScript *engine =
|
||||
static_cast<AppletScript *>(loadEngine(language, Types::AppletComponent, applet));
|
||||
static_cast<AppletScript *>(loadEngine(language, Types::AppletComponent, applet, args));
|
||||
|
||||
if (engine) {
|
||||
engine->setApplet(applet);
|
||||
@ -188,10 +188,10 @@ AppletScript *loadScriptEngine(const QString &language, Applet *applet)
|
||||
return engine;
|
||||
}
|
||||
|
||||
DataEngineScript *loadScriptEngine(const QString &language, DataEngine *dataEngine)
|
||||
DataEngineScript *loadScriptEngine(const QString &language, DataEngine *dataEngine, const QVariantList &args)
|
||||
{
|
||||
DataEngineScript *engine =
|
||||
static_cast<DataEngineScript *>(loadEngine(language, Types::DataEngineComponent, dataEngine));
|
||||
static_cast<DataEngineScript *>(loadEngine(language, Types::DataEngineComponent, dataEngine, args));
|
||||
|
||||
if (engine) {
|
||||
engine->setDataEngine(dataEngine);
|
||||
|
@ -92,7 +92,7 @@ PLASMA_EXPORT QStringList knownLanguages(Types::ComponentTypes types);
|
||||
* @return pointer to the AppletScript or 0 on failure; the caller is responsible
|
||||
* for the return object which will be parented to the Applet
|
||||
**/
|
||||
PLASMA_EXPORT AppletScript *loadScriptEngine(const QString &language, Applet *applet);
|
||||
PLASMA_EXPORT AppletScript *loadScriptEngine(const QString &language, Applet *applet, const QVariantList &args);
|
||||
|
||||
/**
|
||||
* Loads an DataEngine script engine for the given language.
|
||||
@ -102,7 +102,7 @@ PLASMA_EXPORT AppletScript *loadScriptEngine(const QString &language, Applet *ap
|
||||
* @return pointer to the DataEngineScript or 0 on failure; the caller is responsible
|
||||
* for the return object which will be parented to the DataEngine
|
||||
**/
|
||||
PLASMA_EXPORT DataEngineScript *loadScriptEngine(const QString &language, DataEngine *dataEngine);
|
||||
PLASMA_EXPORT DataEngineScript *loadScriptEngine(const QString &language, DataEngine *dataEngine, const QVariantList &args);
|
||||
|
||||
} // namespace Plasma
|
||||
|
||||
|
@ -53,6 +53,10 @@ DeclarativeAppletScript::DeclarativeAppletScript(QObject *parent, const QVariant
|
||||
m_interface(0),
|
||||
m_args(args)
|
||||
{
|
||||
// Chop off list entry added by KService::createInstance() before we
|
||||
// hand this to the applet via externalData() later.
|
||||
m_args.removeLast();
|
||||
|
||||
//qmlRegisterType<AppletInterface>();
|
||||
//FIXME: use this if/when will be possible to have properties of attached items subclasses on the left hand of expressions
|
||||
/*qmlRegisterUncreatableType<AppletLoader>("org.kde.plasma.plasmoid", 2, 0, "Plasmoid",
|
||||
|
Loading…
Reference in New Issue
Block a user