From e0d38ae4140d6101b483fde25158fc94b34a3a64 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Tue, 16 Apr 2019 16:46:36 +0200 Subject: Export Wizard values to JavaScript macro Registers a new function "value('name')", available to the wizard json files, which returns the value of the variable "name" as a JavaScript object. So, variables with a string value are actual JavaScript strings, booleans are booleans, lists are lists, and dictionaries are dictionaries. The patch also makes it actually possible to assign JSON lists and dictionaries to values. This removes some hacks involving creating complex JavaScript objects through string substitution. Change-Id: I4ac6da22bc5bccc9fadee97694c2fa14d44c9307 Reviewed-by: Christian Stenger Reviewed-by: Christian Kandeler --- src/plugins/modeleditor/jsextension.h | 2 +- src/plugins/modeleditor/modeleditor_plugin.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/plugins/modeleditor') diff --git a/src/plugins/modeleditor/jsextension.h b/src/plugins/modeleditor/jsextension.h index 74c7cbc892c..6192636e3b7 100644 --- a/src/plugins/modeleditor/jsextension.h +++ b/src/plugins/modeleditor/jsextension.h @@ -35,7 +35,7 @@ class JsExtension : public QObject Q_OBJECT public: - JsExtension(QObject *parent = nullptr) : QObject(parent) { } + JsExtension() {} Q_INVOKABLE QString fileNameToElementName(const QString &file); Q_INVOKABLE QString elementNameToFileName(const QString &element); diff --git a/src/plugins/modeleditor/modeleditor_plugin.cpp b/src/plugins/modeleditor/modeleditor_plugin.cpp index 7571703cbbd..8e08854f4db 100644 --- a/src/plugins/modeleditor/modeleditor_plugin.cpp +++ b/src/plugins/modeleditor/modeleditor_plugin.cpp @@ -92,7 +92,7 @@ bool ModelEditorPlugin::initialize(const QStringList &arguments, QString *errorS d->modelFactory = new ModelEditorFactory(d->uiController, this); d->settingsController = new SettingsController(this); - Core::JsExpander::registerQObjectForJs(QLatin1String("Modeling"), new JsExtension(this)); + Core::JsExpander::registerGlobalObject("Modeling"); connect(d->settingsController, &SettingsController::saveSettings, d->uiController, &UiController::saveSettings); -- cgit v1.2.3