diff --git a/scriptengines/javascript/simplejavascriptapplet.cpp b/scriptengines/javascript/simplejavascriptapplet.cpp index be7b584f9..f9d33a8a9 100644 --- a/scriptengines/javascript/simplejavascriptapplet.cpp +++ b/scriptengines/javascript/simplejavascriptapplet.cpp @@ -670,11 +670,6 @@ void SimpleJavaScriptApplet::installWidgets(QScriptEngine *engine) s_widgetLoader = new UiLoader; } - //two customs things needed for VideoWidget - registerEnums(m_engine, globalObject, VideoWidget::staticMetaObject); - - qScriptRegisterMetaType(m_engine, qScriptValueFromControls, controlsFromScriptValue, QScriptValue()); - foreach (const QString &widget, s_widgetLoader->availableWidgets()) { QScriptValue fun = engine->newFunction(createWidget); QScriptValue name = engine->toScriptValue(widget); @@ -715,6 +710,14 @@ QScriptValue SimpleJavaScriptApplet::createWidget(QScriptContext *context, QScri QScriptValue fun = engine->newQObject(w); fun.setPrototype(context->callee().property("prototype")); + //register enums will be accessed for instance as frame.Sunken for Frame shadow... + registerEnums(engine, fun, *w->metaObject()); + + //FIXME: still don't have a better approach than try to cast for every widget that could have flags.. + if (qobject_cast(w)) { + qScriptRegisterMetaType(engine, qScriptValueFromControls, controlsFromScriptValue, QScriptValue()); + } + return fun; } diff --git a/scriptengines/javascript/tests/script-mediaplayer/contents/code/main.js b/scriptengines/javascript/tests/script-mediaplayer/contents/code/main.js index e14cf4455..e435df720 100644 --- a/scriptengines/javascript/tests/script-mediaplayer/contents/code/main.js +++ b/scriptengines/javascript/tests/script-mediaplayer/contents/code/main.js @@ -1,8 +1,7 @@ layout = new LinearLayout(plasmoid); video = new VideoWidget(); -video.usedControls = DefaultControls; +video.usedControls = video.DefaultControls; layout.addItem(video); video.url = startupArguments[0]; video.play(); -