diff options
-rw-r--r-- | src/libs/installer/scriptengine.cpp | 7 | ||||
-rw-r--r-- | src/libs/installer/scriptengine_p.h | 24 |
2 files changed, 29 insertions, 2 deletions
diff --git a/src/libs/installer/scriptengine.cpp b/src/libs/installer/scriptengine.cpp index 0c7b3a77c..37610cfc9 100644 --- a/src/libs/installer/scriptengine.cpp +++ b/src/libs/installer/scriptengine.cpp @@ -65,7 +65,12 @@ ScriptEngine::ScriptEngine(PackageManagerCore *core) global.setProperty(QLatin1String("InstallerProxy"), proxy); global.setProperty(QLatin1String("print"), m_engine.newQObject(new ConsoleProxy) .property(QLatin1String("log"))); - +#if QT_VERSION < 0x050400 + global.setProperty(QLatin1String("qsTr"), m_engine.newQObject(new QCoreApplicationProxy) + .property(QStringLiteral("qsTr"))); +#else + m_engine.installTranslatorFunctions(); +#endif global.setProperty(QLatin1String("QInstaller"), generateQInstallerObject()); global.setProperty(QLatin1String("buttons"), generateWizardButtonsObject()); global.setProperty(QLatin1String("QMessageBox"), generateMessageBoxObject()); diff --git a/src/libs/installer/scriptengine_p.h b/src/libs/installer/scriptengine_p.h index 0ab54df7c..3476ab1e8 100644 --- a/src/libs/installer/scriptengine_p.h +++ b/src/libs/installer/scriptengine_p.h @@ -126,10 +126,32 @@ public slots : } }; -} +#if QT_VERSION < 0x050400 +class QCoreApplicationProxy : public QObject +{ + Q_OBJECT + Q_DISABLE_COPY(QCoreApplicationProxy) + +public: + QCoreApplicationProxy() {} + +public slots: + QString qsTr(const QString &text = QString(), const QString &disambiguation = QString(), int n = -1) const + { + return QCoreApplication::translate(QCoreApplication::applicationName().toUtf8().constData(), + text.toUtf8().constData(), disambiguation.toUtf8().constData(), n); + } +}; +#endif + +} // namespace QInstaller + Q_DECLARE_METATYPE(QInstaller::ConsoleProxy*) Q_DECLARE_METATYPE(QInstaller::InstallerProxy*) Q_DECLARE_METATYPE(QInstaller::QFileDialogProxy*) Q_DECLARE_METATYPE(QInstaller::QDesktopServicesProxy*) +#if QT_VERSION < 0x050400 +Q_DECLARE_METATYPE(QInstaller::QCoreApplicationProxy*) +#endif #endif // SCRIPTENGINE_H |