wallpaperPlugins

svn path=/trunk/KDE/kdebase/workspace/; revision=1214674
This commit is contained in:
Aaron J. Seigo 2011-01-15 21:36:52 +00:00 committed by Marco Martin
parent 991badb778
commit 9d934932d4
2 changed files with 36 additions and 5 deletions

View File

@ -39,6 +39,7 @@
#include <Plasma/Containment> #include <Plasma/Containment>
#include <Plasma/Corona> #include <Plasma/Corona>
#include <Plasma/Package> #include <Plasma/Package>
#include <Plasma/Wallpaper>
#include "appinterface.h" #include "appinterface.h"
#include "containment.h" #include "containment.h"
@ -479,12 +480,12 @@ QScriptValue ScriptEngine::userDataPath(QScriptContext *context, QScriptEngine *
{ {
Q_UNUSED(engine) Q_UNUSED(engine)
if (context->argumentCount() == 0) { if (context->argumentCount() == 0) {
return QString(); return QDir::homePath();
} }
const QString type = context->argument(0).toString(); const QString type = context->argument(0).toString();
if (type.isEmpty()) { if (type.isEmpty()) {
return QString(); return QDir::homePath();
} }
if (context->argumentCount() > 1) { if (context->argumentCount() > 1) {
@ -492,9 +493,7 @@ QScriptValue ScriptEngine::userDataPath(QScriptContext *context, QScriptEngine *
return KStandardDirs::locateLocal(type.toLatin1(), filename); return KStandardDirs::locateLocal(type.toLatin1(), filename);
} }
if (type.compare("home", Qt::CaseInsensitive) == 0) { if (type.compare("desktop", Qt::CaseInsensitive) == 0) {
return QDir::homePath();
} else if (type.compare("desktop", Qt::CaseInsensitive) == 0) {
return KGlobalSettings::desktopPath(); return KGlobalSettings::desktopPath();
} else if (type.compare("autostart", Qt::CaseInsensitive) == 0) { } else if (type.compare("autostart", Qt::CaseInsensitive) == 0) {
return KGlobalSettings::autostartPath(); return KGlobalSettings::autostartPath();
@ -513,6 +512,36 @@ QScriptValue ScriptEngine::userDataPath(QScriptContext *context, QScriptEngine *
return QString(); return QString();
} }
QScriptValue ScriptEngine::wallpaperPlugins(QScriptContext *context, QScriptEngine *engine)
{
Q_UNUSED(engine)
QString formFactor;
if (context->argumentCount() > 0) {
formFactor = context->argument(0).toString();
}
QString constraint;
if (!formFactor.isEmpty()) {
constraint.append("[X-Plasma-FormFactors] ~~ '").append(formFactor).append("'");
}
KService::List services = KServiceTypeTrader::self()->query("Plasma/Wallpaper", constraint);
QScriptValue rv = engine->newArray(services.size());
foreach (const KService::Ptr service, services) {
QList<KServiceAction> modeActions = service->actions();
QScriptValue modes = engine->newArray(modeActions.size());
int i = 0;
foreach (const KServiceAction &action, modeActions) {
modes.setProperty(i++, action.name());
}
rv.setProperty(service->name(), modes);
}
return rv;
}
void ScriptEngine::setupEngine() void ScriptEngine::setupEngine()
{ {
QScriptValue v = globalObject(); QScriptValue v = globalObject();
@ -539,6 +568,7 @@ void ScriptEngine::setupEngine()
m_scriptSelf.setProperty("defaultApplication", newFunction(ScriptEngine::defaultApplication)); m_scriptSelf.setProperty("defaultApplication", newFunction(ScriptEngine::defaultApplication));
m_scriptSelf.setProperty("userDataPath", newFunction(ScriptEngine::userDataPath)); m_scriptSelf.setProperty("userDataPath", newFunction(ScriptEngine::userDataPath));
m_scriptSelf.setProperty("applicationPath", newFunction(ScriptEngine::applicationPath)); m_scriptSelf.setProperty("applicationPath", newFunction(ScriptEngine::applicationPath));
m_scriptSelf.setProperty("wallpaperPlugins", newFunction(ScriptEngine::wallpaperPlugins));
setGlobalObject(m_scriptSelf); setGlobalObject(m_scriptSelf);
} }

View File

@ -80,6 +80,7 @@ private:
static QScriptValue defaultApplication(QScriptContext *context, QScriptEngine *engine); static QScriptValue defaultApplication(QScriptContext *context, QScriptEngine *engine);
static QScriptValue applicationPath(QScriptContext *context, QScriptEngine *engine); static QScriptValue applicationPath(QScriptContext *context, QScriptEngine *engine);
static QScriptValue userDataPath(QScriptContext *context, QScriptEngine *engine); static QScriptValue userDataPath(QScriptContext *context, QScriptEngine *engine);
static QScriptValue wallpaperPlugins(QScriptContext *context, QScriptEngine *engine);
// helpers // helpers
static QScriptValue createContainment(const QString &type, const QString &defautPlugin, static QScriptValue createContainment(const QString &type, const QString &defautPlugin,