Commit 01ca64c0 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧 Committed by Aleix Pol Gonzalez
Browse files

pk: Tell our users when they're running an unsupported version of their Distro

BUG: 449259
parent 976a3172
Pipeline #140600 passed with stage
in 1 minute and 10 seconds
......@@ -14,6 +14,11 @@ Kirigami.ScrollablePage
Kirigami.Theme.colorSet: Kirigami.Theme.View
Kirigami.Theme.inherit: false
header: Kirigami.InlineMessage {
id: headerInlineMessage
visible: false
}
readonly property var s1: Shortcut {
sequence: StandardKey.MoveToNextPage
enabled: root.isCurrentPage
......
......@@ -160,6 +160,14 @@ Kirigami.ApplicationWindow
showPassiveNotification(message)
console.log("message:", message)
}
function onInlineMessage (type, icon, message) {
leftPage.header.type = type
leftPage.header.icon.name = icon
leftPage.header.text = message
leftPage.header.visible = true
console.log("inline message:", message)
}
}
footer: Loader {
......
......@@ -12,6 +12,8 @@
#include "PKTransaction.h"
#include "PackageKitSourcesBackend.h"
#include "PackageKitUpdater.h"
#include <AppStreamQt/release.h>
#include <AppStreamQt/utils.h>
#include <appstream/AppStreamIntegration.h>
#include <appstream/AppStreamUtils.h>
#include <appstream/OdrsReviewsBackend.h>
......@@ -225,6 +227,23 @@ void PackageKitBackend::reloadPackageList()
Q_EMIT loadedAppStream();
}
acquireFetching(false);
const QList<AppStream::Component> distroComponents = m_appdata->componentsById(AppStream::Utils::currentDistroComponentId());
for (const AppStream::Component &dc : distroComponents) {
const auto releases = dc.releases();
for (auto r : releases) {
if (AppStream::Utils::vercmpSimple(r.version(), AppStreamIntegration::global()->osRelease()->version()) == 0) {
if (r.timestampEol() < QDateTime::currentDateTime()) {
const QString releaseDate = QLocale().toString(r.timestampEol());
Q_EMIT inlineMessage(InlineMessageType::Warning,
QStringLiteral("dialog-warning"),
i18nc("%1 is the date as formatted by the locale",
"Your operating system ended support on %1. Consider upgrading to a supported version.",
releaseDate));
}
}
}
}
});
fw->setFuture(QtConcurrent::run(&m_threadPool, &loadAppStream, m_appdata.get()));
}
......
......@@ -58,6 +58,14 @@ private:
QVariantList m_actions;
};
// Keep in sync with Kirigami's enums.h
enum class InlineMessageType {
Information = 0,
Positive,
Warning,
Error,
};
/**
* \class AbstractResourcesBackend AbstractResourcesBackend.h "AbstractResourcesBackend.h"
*
......@@ -248,6 +256,7 @@ Q_SIGNALS:
void resourceRemoved(AbstractResource *resource);
void passiveMessage(const QString &message);
void inlineMessage(InlineMessageType type, const QString &iconName, const QString &message);
void fetchingUpdatesProgressChanged();
private:
......
......@@ -148,6 +148,7 @@ void ResourcesModel::addResourcesBackend(AbstractResourcesBackend *backend)
});
connect(backend, &AbstractResourcesBackend::resourceRemoved, this, &ResourcesModel::resourceRemoved);
connect(backend, &AbstractResourcesBackend::passiveMessage, this, &ResourcesModel::passiveMessage);
connect(backend, &AbstractResourcesBackend::inlineMessage, this, &ResourcesModel::inlineMessage);
connect(backend->backendUpdater(), &AbstractBackendUpdater::progressingChanged, this, &ResourcesModel::slotFetching);
if (backend->reviewsBackend()) {
connect(backend->reviewsBackend(), &AbstractReviewsBackend::error, this, &ResourcesModel::passiveMessage, Qt::UniqueConnection);
......
......@@ -134,6 +134,7 @@ Q_SIGNALS:
void passiveMessage(const QString &message);
void currentApplicationBackendChanged(AbstractResourcesBackend *currentApplicationBackend);
void fetchingUpdatesProgressChanged(int fetchingUpdatesProgress);
void inlineMessage(InlineMessageType type, const QString &iconName, const QString &message);
private Q_SLOTS:
void callerFetchingChanged();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment