summaryrefslogtreecommitdiffstats
path: root/src/libs
diff options
context:
space:
mode:
authorTim Jenssen <tim.jenssen@digia.com>2013-10-29 11:28:20 +0100
committerTim Jenssen <tim.jenssen@digia.com>2013-10-29 14:46:02 +0100
commitb7c401a8aba23194df2bde708f7fcd3f227e4697 (patch)
treef45fb58bf9500fabcfbdf3c79e72f5c5e09012c9 /src/libs
parent62788b068bb9c7df7557712803e14a1d9ca9faa9 (diff)
prepare script engine to get the gui object later
- Since we need two different script engines we need to be able to set the gui object later Change-Id: Ie40f8ec3dd84dc4d5b3cf127c3e41ce25ef53b66 Reviewed-by: Karsten Heimrich <karsten.heimrich@digia.com>
Diffstat (limited to 'src/libs')
-rw-r--r--src/libs/installer/scriptengine.cpp41
-rw-r--r--src/libs/installer/scriptengine.h3
2 files changed, 24 insertions, 20 deletions
diff --git a/src/libs/installer/scriptengine.cpp b/src/libs/installer/scriptengine.cpp
index b6a8a971a..4e236be7f 100644
--- a/src/libs/installer/scriptengine.cpp
+++ b/src/libs/installer/scriptengine.cpp
@@ -189,6 +189,7 @@ ScriptEngine::ScriptEngine(PackageManagerCore *core)
installTranslatorFunctions();
globalObject().setProperty(QLatin1String("QMessageBox"), generateMessageBoxObject());
+ globalObject().setProperty(QLatin1String("buttons"), generateWizardButtonsObject());
globalObject().setProperty(QLatin1String("QDesktopServices"), generateDesktopServicesObject());
globalObject().setProperty(QLatin1String("QInstaller"), generateQInstallerObject());
@@ -219,25 +220,6 @@ ScriptEngine::~ScriptEngine()
void ScriptEngine::setGuiQObject(QObject *guiQObject)
{
- if (qobject_cast<QWizard*>(guiQObject)) {
-#undef REGISTER_BUTTON
-#define REGISTER_BUTTON(x) buttons.setProperty(QLatin1String(#x), \
- newVariant(static_cast<int>(QWizard::x)));
-
- QScriptValue buttons = newArray();
- REGISTER_BUTTON(BackButton)
- REGISTER_BUTTON(NextButton)
- REGISTER_BUTTON(CommitButton)
- REGISTER_BUTTON(FinishButton)
- REGISTER_BUTTON(CancelButton)
- REGISTER_BUTTON(HelpButton)
- REGISTER_BUTTON(CustomButton1)
- REGISTER_BUTTON(CustomButton2)
- REGISTER_BUTTON(CustomButton3)
-
-#undef REGISTER_BUTTON
- globalObject().setProperty(QLatin1String("buttons"), buttons);
- }
globalObject().setProperty(QLatin1String("gui"), newQObject(guiQObject));
}
@@ -319,6 +301,27 @@ QScriptValue ScriptEngine::callScriptMethod(const QScriptValue &scriptContext,
}
+QScriptValue ScriptEngine::generateWizardButtonsObject()
+{
+#undef REGISTER_BUTTON
+#define REGISTER_BUTTON(x) buttons.setProperty(QLatin1String(#x), \
+ newVariant(static_cast<int>(QWizard::x)));
+
+ QScriptValue buttons = newArray();
+ REGISTER_BUTTON(BackButton)
+ REGISTER_BUTTON(NextButton)
+ REGISTER_BUTTON(CommitButton)
+ REGISTER_BUTTON(FinishButton)
+ REGISTER_BUTTON(CancelButton)
+ REGISTER_BUTTON(HelpButton)
+ REGISTER_BUTTON(CustomButton1)
+ REGISTER_BUTTON(CustomButton2)
+ REGISTER_BUTTON(CustomButton3)
+
+#undef REGISTER_BUTTON
+ return buttons;
+}
+
/*!
generates QMessageBox::StandardButton enum as an QScriptValue array
*/
diff --git a/src/libs/installer/scriptengine.h b/src/libs/installer/scriptengine.h
index 50c50539b..e52862e06 100644
--- a/src/libs/installer/scriptengine.h
+++ b/src/libs/installer/scriptengine.h
@@ -70,14 +70,15 @@ class INSTALLER_EXPORT ScriptEngine : public QScriptEngine
public:
explicit ScriptEngine(PackageManagerCore *core);
~ScriptEngine();
- void setGuiQObject(QObject *guiQObject);
QScriptValue callScriptMethod(const QScriptValue &scriptContext, const QString &methodName,
const QScriptValueList &arguments = QScriptValueList()) const;
QScriptValue loadInConext(const QString &context, const QString &fileName, const QString &scriptInjection = QString());
private slots:
void handleException(const QScriptValue &value);
+ void setGuiQObject(QObject *guiQObject);
private:
+ QScriptValue generateWizardButtonsObject();
QScriptValue generateMessageBoxObject();
QScriptValue generateDesktopServicesObject();
QScriptValue generateQInstallerObject();