Fix KDE string conversions and reserve relay refresh headroom
This commit is contained in:
parent
56c2e9ba86
commit
c805bb41e4
1 changed files with 26 additions and 24 deletions
|
|
@ -11,6 +11,8 @@
|
|||
#include <QSharedPointer>
|
||||
#include <QTimer>
|
||||
|
||||
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<PackageState> addonsInformation() override { return {}; }
|
||||
QString longDescription() override {
|
||||
QString text = comment().toHtmlEscaped();
|
||||
if (record["state"] == "pending") text += tr("<p>A deployment is staged. Restart when ready.</p>");
|
||||
if (record["state"] == "applying") text += tr("<p>The operating system update is being prepared. Detailed progress is recorded in the system log.</p>");
|
||||
if (record["state"] == "downloading") text += tr("<p>The verified operating system image is being downloaded.</p>");
|
||||
if (record["state"] == "error") text += "<p>" + record["error"].toString().toHtmlEscaped() + "</p>";
|
||||
text += "<pre>" + record["support_description"].toString().toHtmlEscaped() + "</pre>";
|
||||
text += "<ul>";
|
||||
for (const auto &entry : record["plan"].toObject()["package_changes"].toArray()) {
|
||||
if (record["state"_L1] == "pending"_L1) text += tr("<p>A deployment is staged. Restart when ready.</p>");
|
||||
if (record["state"_L1] == "applying"_L1) text += tr("<p>The operating system update is being prepared. Detailed progress is recorded in the system log.</p>");
|
||||
if (record["state"_L1] == "downloading"_L1) text += tr("<p>The verified operating system image is being downloaded.</p>");
|
||||
if (record["state"_L1] == "error"_L1) text += "<p>"_L1 + record["error"_L1].toString().toHtmlEscaped() + "</p>"_L1;
|
||||
text += "<pre>"_L1 + record["support_description"_L1].toString().toHtmlEscaped() + "</pre>"_L1;
|
||||
text += "<ul>"_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 += "<li>" + change["name"].toString().toHtmlEscaped() + ": "
|
||||
+ before.toHtmlEscaped() + QStringLiteral(" → ") + after.toHtmlEscaped() + "</li>";
|
||||
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 += "<li>"_L1 + change["name"_L1].toString().toHtmlEscaped() + ": "_L1
|
||||
+ before.toHtmlEscaped() + QStringLiteral(" → ") + after.toHtmlEscaped() + "</li>"_L1;
|
||||
}
|
||||
return text + "</ul>";
|
||||
return text + "</ul>"_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<InlineMessage> 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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue