From 4d9620977c81401f88212196b1d1a1094fc19699 Mon Sep 17 00:00:00 2001 From: Katja Marttila Date: Tue, 12 Jan 2021 16:28:06 +0200 Subject: Fix translating from component script Translate using QCoreApplication::translate instead of QObject::tr. Removed the use of obsolete installTranslatorFunctions() function. Task-number: QTIFW-392 Change-Id: Icdd67efb6889acd26d63297fb89945c3431c881c Reviewed-by: Arttu Tarkiainen --- src/libs/installer/scriptengine.cpp | 7 +------ src/libs/installer/scriptengine_p.h | 21 --------------------- 2 files changed, 1 insertion(+), 27 deletions(-) (limited to 'src/libs/installer') diff --git a/src/libs/installer/scriptengine.cpp b/src/libs/installer/scriptengine.cpp index 4d062c9cb..ae5bed72c 100644 --- a/src/libs/installer/scriptengine.cpp +++ b/src/libs/installer/scriptengine.cpp @@ -372,6 +372,7 @@ ScriptEngine::ScriptEngine(PackageManagerCore *core) : QObject(core), m_guiProxy(new GuiProxy(this, this)) { + m_engine.installExtensions(QJSEngine::TranslationExtension); QJSValue global = m_engine.globalObject(); global.setProperty(QLatin1String("console"), m_engine.newQObject(new ConsoleProxy)); global.setProperty(QLatin1String("QFileDialog"), m_engine.newQObject(new QFileDialogProxy(core))); @@ -379,12 +380,6 @@ 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("systemInfo"), m_engine.newQObject(new SystemInfo)); global.setProperty(QLatin1String("QInstaller"), generateQInstallerObject()); diff --git a/src/libs/installer/scriptengine_p.h b/src/libs/installer/scriptengine_p.h index bf8240d98..c5f04c0dc 100644 --- a/src/libs/installer/scriptengine_p.h +++ b/src/libs/installer/scriptengine_p.h @@ -125,24 +125,6 @@ private: ScriptEngine *m_engine; }; -#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 - class GuiProxy : public QObject { Q_OBJECT @@ -198,8 +180,5 @@ 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 -- cgit v1.2.3