diff options
Diffstat (limited to 'src/libs/installer/scriptengine.cpp')
-rw-r--r-- | src/libs/installer/scriptengine.cpp | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/src/libs/installer/scriptengine.cpp b/src/libs/installer/scriptengine.cpp index e85ce9671..a2fe9f049 100644 --- a/src/libs/installer/scriptengine.cpp +++ b/src/libs/installer/scriptengine.cpp @@ -192,6 +192,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()); @@ -216,6 +217,9 @@ ScriptEngine::ScriptEngine(PackageManagerCore *core) .setProperty(QLatin1String("components"), scriptComponentsObject); connect(this, SIGNAL(signalHandlerException(QScriptValue)), SLOT(handleException(QScriptValue))); + + connect(core, SIGNAL(guiObjectChanged(QObject*)), this, SLOT(setGuiQObject(QObject*))); + setGuiQObject(core->guiObject()); } ScriptEngine::~ScriptEngine() @@ -224,25 +228,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)); } @@ -324,6 +309,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 */ |