Hi all, I write to update about my work on replacing QTScript with QJSEngine. I have just pushed to the branch a substantial change, which includes: - fully functional Script console with JS console logging - loading of old scripts (though with errors, depending on what's used)
If you have the interest, take a look at the working branch: https://invent.kde.org/multimedia/amarok/-/tree/replace_Qtscript_with_QtQml There's still quite some work ahead. At least if the goal is to minimize changes to older scripts. The main issue is that the QJSEngine API provides *way less* features than QScriptEngine. Also, the documentation is not so complete. One example: QScriptEngine had "newFunction" which allowed any method/function to be exposed to the script engine. There's no such at QJSEngine, but I managed to implement an equivalent solution by 1) creating a QObject with a Q_INVOKE method, 2) exporting the object: QJSValue scriptObj = engine->newQObject( myQObj ); 3) get a reference to the method: QJSValue scriptFunction = scriptObj.property("methodName"); 4) create a global property to the method: engine->globalObject().setProperty("functionName", scriptFunction); The main issue I have now is that QJSEngine does not have an equivalent to QScriptContext. This provides invocation information that is necessary; especially a reference to the "this" JS object. Without it I can't think of a solution that avoids rework at all current scripts. Another issue is that there's no direct equivalent to QtBindings. These is specifically useful to manipulate QT widgets via script. However those should naturally be replaced with some QML equivant, though I couldn't look at it yet. If there are more people interested, I'd be really glad to help bring on board. There's a lot of fun stuff to work with. Cheers, Pedro