aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/modeleditor
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2019-04-16 16:46:36 +0200
committerEike Ziller <eike.ziller@qt.io>2019-05-09 11:19:43 +0000
commite0d38ae4140d6101b483fde25158fc94b34a3a64 (patch)
tree9137897e6cc85c195ff76ebedc9de0d9a447a168 /src/plugins/modeleditor
parent0c5837a1114ef526727748a0db956f0758597350 (diff)
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 <christian.stenger@qt.io> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src/plugins/modeleditor')
-rw-r--r--src/plugins/modeleditor/jsextension.h2
-rw-r--r--src/plugins/modeleditor/modeleditor_plugin.cpp2
2 files changed, 2 insertions, 2 deletions
diff --git a/src/plugins/modeleditor/jsextension.h b/src/plugins/modeleditor/jsextension.h
index 74c7cbc892..6192636e3b 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 7571703cbb..8e08854f4d 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<JsExtension>("Modeling");
connect(d->settingsController, &SettingsController::saveSettings,
d->uiController, &UiController::saveSettings);