diff options
Diffstat (limited to 'src/libs')
-rw-r--r-- | src/libs/installer/scriptengine.cpp | 13 | ||||
-rw-r--r-- | src/libs/installer/scriptengine.h | 2 |
2 files changed, 9 insertions, 6 deletions
diff --git a/src/libs/installer/scriptengine.cpp b/src/libs/installer/scriptengine.cpp index 009215909..3b2e3ae1d 100644 --- a/src/libs/installer/scriptengine.cpp +++ b/src/libs/installer/scriptengine.cpp @@ -95,7 +95,7 @@ QJSValue InstallerProxy::components(const QString ®exp) const QJSValue InstallerProxy::componentByName(const QString &componentName) { if (m_core) - return m_engine->newQObject(m_core->componentByName(componentName)); + return m_engine->newQObject(m_core->componentByName(componentName), false); return QJSValue(); } @@ -418,9 +418,9 @@ ScriptEngine::ScriptEngine(PackageManagerCore *core) : /*! Creates a JavaScript object that wraps the given QObject \a object. - Signals and slots, properties and children of \a object are - available as properties of the created QJSValue. In addition some helper methods and properties - are added: + Signals and slots, properties and children of \a object are available as properties + of the created QJSValue. If \a qtScriptCompat is set to \c true (default), some helper + methods and properties from the legacy \c QtScript module are added: \list \li findChild(), findChildren() recursively search for child objects with the given @@ -429,7 +429,7 @@ ScriptEngine::ScriptEngine(PackageManagerCore *core) : names. \endlist */ -QJSValue ScriptEngine::newQObject(QObject *object) +QJSValue ScriptEngine::newQObject(QObject *object, bool qtScriptCompat) { QJSValue jsValue = m_engine.newQObject(object); if (!jsValue.isQObject()) @@ -437,6 +437,9 @@ QJSValue ScriptEngine::newQObject(QObject *object) QQmlEngine::setObjectOwnership(object, QQmlEngine::CppOwnership); + if (!qtScriptCompat) // skip adding the extra properties + return jsValue; + // add findChild(), findChildren() methods known from QtScript QJSValue findChild = m_engine.evaluate( QLatin1String("(function() { return gui.findChild(this, arguments[0]); })")); diff --git a/src/libs/installer/scriptengine.h b/src/libs/installer/scriptengine.h index ae3cdd04f..a7c0ef253 100644 --- a/src/libs/installer/scriptengine.h +++ b/src/libs/installer/scriptengine.h @@ -48,7 +48,7 @@ public: explicit ScriptEngine(PackageManagerCore *core = 0); QJSValue globalObject() const { return m_engine.globalObject(); } - QJSValue newQObject(QObject *object); + QJSValue newQObject(QObject *object, bool qtScriptCompat = true); QJSValue newArray(uint length = 0); QJSValue evaluate(const QString &program, const QString &fileName = QString(), int lineNumber = 1); |