loadService() function to load services without dataengines.
will be propagated to the js appletscript too svn path=/trunk/KDE/kdebase/runtime/; revision=1189005
This commit is contained in:
parent
61b3302821
commit
dc0ab1345f
@ -368,6 +368,7 @@ void DeclarativeAppletScript::setupObjects()
|
||||
bindI18N(m_engine);
|
||||
global.setProperty("dataEngine", m_engine->newFunction(DeclarativeAppletScript::dataEngine));
|
||||
global.setProperty("service", m_engine->newFunction(DeclarativeAppletScript::service));
|
||||
global.setProperty("loadService", m_engine->newFunction(DeclarativeAppletScript::loadService));
|
||||
|
||||
//Add stuff from Qt
|
||||
ByteArrayClass *baClass = new ByteArrayClass(m_engine);
|
||||
@ -423,6 +424,25 @@ QScriptValue DeclarativeAppletScript::service(QScriptContext *context, QScriptEn
|
||||
return engine->newQObject(service, QScriptEngine::AutoOwnership);
|
||||
}
|
||||
|
||||
QScriptValue DeclarativeAppletScript::loadService(QScriptContext *context, QScriptEngine *engine)
|
||||
{
|
||||
if (context->argumentCount() != 1) {
|
||||
return context->throwError(i18n("service() takes one argument"));
|
||||
}
|
||||
|
||||
QString pluginName = context->argument(0).toString();
|
||||
|
||||
AppletInterface *interface = AppletInterface::extract(engine);
|
||||
if (!interface) {
|
||||
return context->throwError(i18n("Could not extract the Applet"));
|
||||
}
|
||||
|
||||
Plasma::Service *service = Plasma::Service::load(pluginName, interface);
|
||||
|
||||
//kDebug( )<< "lets try to get" << source << "from" << dataEngine;
|
||||
return engine->newQObject(service, QScriptEngine::AutoOwnership);
|
||||
}
|
||||
|
||||
void DeclarativeAppletScript::setEngine(QScriptValue &val)
|
||||
{
|
||||
if (val.engine() == m_engine) {
|
||||
|
@ -67,6 +67,7 @@ public:
|
||||
static QScriptValue newPlasmaExtenderItem(QScriptContext *context, QScriptEngine *engine);
|
||||
static QScriptValue dataEngine(QScriptContext *context, QScriptEngine *engine);
|
||||
static QScriptValue service(QScriptContext *context, QScriptEngine *engine);
|
||||
static QScriptValue loadService(QScriptContext *context, QScriptEngine *engine);
|
||||
|
||||
public Q_SLOTS:
|
||||
void dataUpdated(const QString &name, const Plasma::DataEngine::Data &data);
|
||||
|
Loading…
x
Reference in New Issue
Block a user