auto registers all the enums in widgets declared as Q_ENUMS, accessed as
widget.EnumValue svn path=/trunk/KDE/kdebase/workspace/plasma/scriptengines/javascript/; revision=928727
This commit is contained in:
parent
b0df57c67d
commit
5f75ed8359
@ -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<Controls>(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<VideoWidget *>(w)) {
|
||||
qScriptRegisterMetaType<Controls>(engine, qScriptValueFromControls, controlsFromScriptValue, QScriptValue());
|
||||
}
|
||||
|
||||
return fun;
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user