diff options
Diffstat (limited to 'src/libs/installer')
-rw-r--r-- | src/libs/installer/component.cpp | 15 | ||||
-rw-r--r-- | src/libs/installer/constants.h | 5 | ||||
-rw-r--r-- | src/libs/installer/scriptengine.cpp | 20 | ||||
-rw-r--r-- | src/libs/installer/scriptengine.h | 3 |
4 files changed, 24 insertions, 19 deletions
diff --git a/src/libs/installer/component.cpp b/src/libs/installer/component.cpp index 690b4ee93..edd03a191 100644 --- a/src/libs/installer/component.cpp +++ b/src/libs/installer/component.cpp @@ -64,9 +64,6 @@ using namespace QInstaller; -static const char *scClearCacheHint = QT_TR_NOOP( - "Clearing the cache directory and restarting the application may solve this."); - /*! \enum QInstaller::Component::UnstableError @@ -692,8 +689,8 @@ void Component::loadUserInterfaces(const QDir &directory, const QStringList &uis while (it.hasNext()) { QFile file(it.next()); if (!file.open(QIODevice::ReadOnly)) { - throw Error(tr("Cannot open the requested UI file \"%1\": %2.\n\n%3").arg( - it.fileName(), file.errorString(), tr(scClearCacheHint))); + throw Error(tr("Cannot open the requested UI file \"%1\": %2.\n\n%3 \"%4\"").arg( + it.fileName(), file.errorString(), tr(scClearCacheHint), packageManagerCore()->settings().localCachePath())); } static QUiLoader loader; @@ -701,8 +698,8 @@ void Component::loadUserInterfaces(const QDir &directory, const QStringList &uis loader.setLanguageChangeEnabled(true); QWidget *const widget = loader.load(&file, 0); if (!widget) { - throw Error(tr("Cannot load the requested UI file \"%1\": %2.\n\n%3").arg( - it.fileName(), loader.errorString(), tr(scClearCacheHint))); + throw Error(tr("Cannot load the requested UI file \"%1\": %2.\n\n%3 \"%4\"").arg( + it.fileName(), loader.errorString(), tr(scClearCacheHint), packageManagerCore()->settings().localCachePath())); } d->scriptEngine()->newQObject(widget); d->m_userInterfaces.insert(widget->objectName(), widget); @@ -747,8 +744,8 @@ void Component::loadLicenses(const QString &directory, const QHash<QString, QVar QFile file(fileInfo.filePath()); if (!file.open(QIODevice::ReadOnly)) { - throw Error(tr("Cannot open the requested license file \"%1\": %2.\n\n%3").arg( - file.fileName(), file.errorString(), tr(scClearCacheHint))); + throw Error(tr("Cannot open the requested license file \"%1\": %2.\n\n%3 \"%4\"").arg( + file.fileName(), file.errorString(), tr(scClearCacheHint), packageManagerCore()->settings().localCachePath())); } QTextStream stream(&file); stream.setCodec("UTF-8"); diff --git a/src/libs/installer/constants.h b/src/libs/installer/constants.h index 1ac1d8940..ecd85fe11 100644 --- a/src/libs/installer/constants.h +++ b/src/libs/installer/constants.h @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (C) 2022 The Qt Company Ltd. +** Copyright (C) 2023 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Installer Framework. @@ -75,6 +75,9 @@ static const QLatin1String scMetadataName("MetadataName"); static const QLatin1String scContentSha1("ContentSha1"); static const QLatin1String scCheckSha1CheckSum("CheckSha1CheckSum"); +static const char *scClearCacheHint = QT_TR_NOOP( + "This may be solved by restarting the application after clearing the cache from:"); + // symbols static const QLatin1String scCaretSymbol("^"); static const QLatin1String scCommaWithSpace(", "); diff --git a/src/libs/installer/scriptengine.cpp b/src/libs/installer/scriptengine.cpp index bcd475d54..baf348868 100644 --- a/src/libs/installer/scriptengine.cpp +++ b/src/libs/installer/scriptengine.cpp @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (C) 2022 The Qt Company Ltd. +** Copyright (C) 2023 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Installer Framework. @@ -34,6 +34,7 @@ #include "loggingutils.h" #include "packagemanagergui.h" #include "component.h" +#include "settings.h" #include <QMetaEnum> #include <QQmlEngine> @@ -377,9 +378,9 @@ QString QFileDialogProxy::getExistingFileOrDirectory(const QString &caption, /*! Constructs a script engine with \a core as parent. */ -ScriptEngine::ScriptEngine(PackageManagerCore *core) : - QObject(core), - m_guiProxy(new GuiProxy(this, this)) +ScriptEngine::ScriptEngine(PackageManagerCore *core) : QObject(core) + , m_guiProxy(new GuiProxy(this, this)) + , m_core(core) { m_engine.installExtensions(QJSEngine::TranslationExtension); QJSValue global = m_engine.globalObject(); @@ -574,14 +575,17 @@ QJSValue ScriptEngine::callScriptMethod(const QJSValue &scriptContext, const QSt if (!method.isCallable()) return QJSValue(QJSValue::UndefinedValue); if (method.isError()) { - throw Error(method.toString().isEmpty() ? QString::fromLatin1("Unknown error.") - : method.toString()); + QString errorString = method.toString().isEmpty() ? QString::fromLatin1("Unknown error.") + : method.toString(); + + throw Error(QString::fromLatin1("%1 \n%2 \"%3\"").arg(errorString, tr(scClearCacheHint), m_core->settings().localCachePath())); } const QJSValue result = method.call(arguments); if (result.isError()) { - throw Error(result.toString().isEmpty() ? QString::fromLatin1("Unknown error.") - : result.toString()); + QString errorString = result.toString().isEmpty() ? QString::fromLatin1("Unknown error.") + : result.toString(); + throw Error(QString::fromLatin1("%1 \n%2 \"%3\"").arg(errorString, tr(scClearCacheHint), m_core->settings().localCachePath())); } stack.removeLast(); diff --git a/src/libs/installer/scriptengine.h b/src/libs/installer/scriptengine.h index a7c0ef253..0b43465cb 100644 --- a/src/libs/installer/scriptengine.h +++ b/src/libs/installer/scriptengine.h @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (C) 2022 The Qt Company Ltd. +** Copyright (C) 2023 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Installer Framework. @@ -77,6 +77,7 @@ private: QJSEngine m_engine; QHash<QString, QStringList> m_callstack; GuiProxy *m_guiProxy; + PackageManagerCore *m_core; }; } |