diff --git a/scriptengines/javascript/simplejavascriptapplet.cpp b/scriptengines/javascript/simplejavascriptapplet.cpp index e6012218d..860e87dcb 100644 --- a/scriptengines/javascript/simplejavascriptapplet.cpp +++ b/scriptengines/javascript/simplejavascriptapplet.cpp @@ -147,6 +147,7 @@ QScriptValue qScriptValueFromKConfigGroup(QScriptEngine *engine, const KConfigGr //setting the key/value pairs for (it = begin; it != end; ++it) { + //kDebug() << "setting" << it.key() << "to" << it.value(); QString prop = it.key(); prop.replace(' ', '_'); obj.setProperty(prop, variant2ScriptValue(engine, it.value())); @@ -157,16 +158,17 @@ QScriptValue qScriptValueFromKConfigGroup(QScriptEngine *engine, const KConfigGr void kConfigGroupFromScriptValue(const QScriptValue& obj, KConfigGroup &config) { - QScriptValueIterator it(obj); - KConfigSkeleton *skel = new KConfigSkeleton(); config = KConfigGroup(skel->config(), obj.property("__name").toString()); + QScriptValueIterator it(obj); + while (it.hasNext()) { + it.next(); + //kDebug() << it.name() << "is" << it.value().toString(); if (it.name() != "__name") { config.writeEntry(it.name(), it.value().toString()); } - it.next(); } } @@ -382,7 +384,7 @@ void SimpleJavaScriptApplet::setupObjects() // Bindings for data engine m_engine->setDefaultPrototype(qMetaTypeId(), m_engine->newQObject(new DataEngine())); - m_engine->setDefaultPrototype(qMetaTypeId(), m_engine->newQObject(new DummyService())); + m_engine->setDefaultPrototype(qMetaTypeId(), m_engine->newQObject(new DummyService())); m_engine->setDefaultPrototype(qMetaTypeId(), m_engine->newQObject(new ServiceJob(QString(), QString(), QMap()))); global.setProperty("dataEngine", m_engine->newFunction(SimpleJavaScriptApplet::dataEngine)); diff --git a/scriptengines/javascript/tests/script-nowplaying/contents/code/main.js b/scriptengines/javascript/tests/script-nowplaying/contents/code/main.js index 70b1c1687..85f83fffc 100644 --- a/scriptengines/javascript/tests/script-nowplaying/contents/code/main.js +++ b/scriptengines/javascript/tests/script-nowplaying/contents/code/main.js @@ -12,7 +12,7 @@ plasmoid.dataUpdate = function(a, b) plasmoid.stop = function() { data = controller.operationDescription("stop"); - print(data+controller.name()); + print(controller.name()); for ( var i in data ) { print(i + ' -> ' + data[i] ); } @@ -21,8 +21,20 @@ plasmoid.stop = function() print("stopping"); } +plasmoid.setProgress = function(progress) +{ + operation = controller.operationDescription("seek"); + operation["seconds"] = progress; + for ( var i in operation ) { + print(i + ' -> ' + operation[i] ); + } + + controller.startOperationCall(operation); + print("set progress to " + progress); +} + layout = new LinearLayout(plasmoid); -layout.orientation = Vertical; +layout.setOrientation(Vertical); label = new Label(); layout.addItem(label); @@ -31,8 +43,14 @@ stop.text = "Stop"; layout.addItem(stop); controller.associateWidget(stop, "stop"); -print(controller.operationNames()); stop["clicked()"].connect(plasmoid.stop); +progress = new Slider(); +progress.orientation = Horizontal; +layout.addItem(progress); +controller.associateWidget(progress, "progress"); + +progress["valueChanged(int)"].connect(plasmoid.setProgress); + engine.connectSource(watchingPlayer, plasmoid, 500);