From c805bb41e43a4dcddfe65f47a22d90b1451dd082 Mon Sep 17 00:00:00 2001 From: Pavel Isaev Date: Fri, 6 Nov 2026 23:47:30 +0300 Subject: [PATCH] Fix KDE string conversions and reserve relay refresh headroom --- integrations/discover/ArchipelagoBackend.cpp | 50 ++++++++++---------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/integrations/discover/ArchipelagoBackend.cpp b/integrations/discover/ArchipelagoBackend.cpp index 6cc9d4c..bb26c49 100644 --- a/integrations/discover/ArchipelagoBackend.cpp +++ b/integrations/discover/ArchipelagoBackend.cpp @@ -11,6 +11,8 @@ #include #include +using namespace Qt::StringLiterals; + class OSResource final : public AbstractResource { Q_OBJECT @@ -24,14 +26,14 @@ public: bool canExecute() const override { return false; } void invokeApplication() const override {} bool isRemovable() const override { return false; } - State state() override { return record["state"] == "available" ? Upgradeable : Installed; } - bool hasCategory(const QString &category) const override { return category == "System"; } + State state() override { return record["state"_L1] == "available"_L1 ? Upgradeable : Installed; } + bool hasCategory(const QString &category) const override { return category == "System"_L1; } Type type() const override { return System; } quint64 size() override { return 0; } // The transport has not reported download size. QString sizeDescription() override { return tr("Download size is determined by OSTree"); } QJsonArray licenses() override { return {}; } - QString installedVersion() const override { return record["plan"].toObject()["base"].toString(); } - QString availableVersion() const override { return record["plan"].toObject()["target"].toString(); } + QString installedVersion() const override { return record["plan"_L1].toObject()["base"_L1].toString(); } + QString availableVersion() const override { return record["plan"_L1].toObject()["target"_L1].toString(); } QString origin() const override { return QStringLiteral("Archipelago"); } QString section() override { return QStringLiteral("System"); } QString author() const override { return QStringLiteral("Archipelago"); } @@ -40,27 +42,27 @@ public: QList addonsInformation() override { return {}; } QString longDescription() override { QString text = comment().toHtmlEscaped(); - if (record["state"] == "pending") text += tr("

A deployment is staged. Restart when ready.

"); - if (record["state"] == "applying") text += tr("

The operating system update is being prepared. Detailed progress is recorded in the system log.

"); - if (record["state"] == "downloading") text += tr("

The verified operating system image is being downloaded.

"); - if (record["state"] == "error") text += "

" + record["error"].toString().toHtmlEscaped() + "

"; - text += "
" + record["support_description"].toString().toHtmlEscaped() + "
"; - text += "
    "; - for (const auto &entry : record["plan"].toObject()["package_changes"].toArray()) { + if (record["state"_L1] == "pending"_L1) text += tr("

    A deployment is staged. Restart when ready.

    "); + if (record["state"_L1] == "applying"_L1) text += tr("

    The operating system update is being prepared. Detailed progress is recorded in the system log.

    "); + if (record["state"_L1] == "downloading"_L1) text += tr("

    The verified operating system image is being downloaded.

    "); + if (record["state"_L1] == "error"_L1) text += "

    "_L1 + record["error"_L1].toString().toHtmlEscaped() + "

    "_L1; + text += "
    "_L1 + record["support_description"_L1].toString().toHtmlEscaped() + "
    "_L1; + text += "
      "_L1; + for (const auto &entry : record["plan"_L1].toObject()["package_changes"_L1].toArray()) { const auto change = entry.toObject(); - const QString before = change["old_version"].isString() ? change["old_version"].toString() : tr("not installed"); - const QString after = change["new_version"].isString() ? change["new_version"].toString() : tr("will be removed"); - text += "
    • " + change["name"].toString().toHtmlEscaped() + ": " - + before.toHtmlEscaped() + QStringLiteral(" → ") + after.toHtmlEscaped() + "
    • "; + const QString before = change["old_version"_L1].isString() ? change["old_version"_L1].toString() : tr("not installed"); + const QString after = change["new_version"_L1].isString() ? change["new_version"_L1].toString() : tr("will be removed"); + text += "
    • "_L1 + change["name"_L1].toString().toHtmlEscaped() + ": "_L1 + + before.toHtmlEscaped() + QStringLiteral(" → ") + after.toHtmlEscaped() + "
    • "_L1; } - return text + "
    "; + return text + "
"_L1; } void fetchChangelog() override { Q_EMIT changelogFetched(longDescription()); } void reload() { QFile file(QStringLiteral("/var/lib/archipelago/software/status.json")); QJsonObject next; if (file.open(QIODevice::ReadOnly)) next = QJsonDocument::fromJson(file.readAll()).object(); - if (next["version"].toInt() != 1) next = {{"state", "error"}, {"error", tr("Update status unavailable; refresh to retrieve a verified plan.")}}; + if (next["version"_L1].toInt() != 1) next = {{"state"_L1, "error"_L1}, {"error"_L1, tr("Update status unavailable; refresh to retrieve a verified plan.")}}; if (record == next) return; record = next; Q_EMIT stateChanged(); @@ -76,7 +78,7 @@ public: explicit OSTransaction(OSResource *resource) : Transaction(resource->backend(), resource, InstallRole, {}) { setCancellable(false); - const QString id = resource->record["plan_id"].toString(); + const QString id = resource->record["plan_id"_L1].toString(); QTimer::singleShot(0, this, [this, resource, id] { if (resource->state() != AbstractResource::Upgradeable || !QRegularExpression(QStringLiteral("^[a-f0-9]{64}$")).match(id).hasMatch()) { @@ -115,16 +117,16 @@ public: resource = new OSResource(this); updater = new StandardBackendUpdater(this); connect(resource, &AbstractResource::stateChanged, this, [this] { - updater->setNeedsReboot(resource->record["state"] == "pending"); + updater->setNeedsReboot(resource->record["state"_L1] == "pending"_L1); Q_EMIT updatesCountChanged(); Q_EMIT resourcesChanged(resource, {"state", "installedVersion", "availableVersion", "longDescription"}); - const QString state = resource->record["state"].toString(); + const QString state = resource->record["state"_L1].toString(); QSharedPointer message; - if (state == "error") { - message.reset(new InlineMessage(InlineMessage::Error, QStringLiteral("dialog-error"), resource->record["error"].toString())); - } else if (state == "pending") { + if (state == "error"_L1) { + message.reset(new InlineMessage(InlineMessage::Error, QStringLiteral("dialog-error"), resource->record["error"_L1].toString())); + } else if (state == "pending"_L1) { message.reset(new InlineMessage(InlineMessage::Information, QStringLiteral("system-reboot"), tr("Archipelago is ready. Restart when you choose to activate the new deployment."))); - } else if (state == "applying" || state == "downloading") { + } else if (state == "applying"_L1 || state == "downloading"_L1) { message.reset(new InlineMessage(InlineMessage::Information, QStringLiteral("system-software-update"), tr("An Archipelago transaction is running. Please wait for its result."))); } Q_EMIT inlineMessageChanged(message);