File 0002-Show-that-the-last-check-failed-if-no-updates-availa.patch of Package plasma5-pk-updates
From b372eae9c7186797f62ba3cfb25d692075326d94 Mon Sep 17 00:00:00 2001
From: Fabian Vogt <fabian@ritter-vogt.de>
Date: Mon, 25 Dec 2017 18:13:15 +0100
Subject: [PATCH 2/3] Show that the last check failed if no updates available
Summary:
If the last check for updates failed, it would be misleading to show that
no updates are available.
Test Plan:
Ran pkupdates while YaST is open, instead of (incorrectly) showing
that no updates are available, it shows that the last check failed.
Reviewers: lukas, jgrulich
Subscribers: plasma-devel
Differential Revision: https://phabricator.kde.org/D9504
---
src/declarative/pkupdates.cpp | 10 ++++++++--
src/declarative/pkupdates.h | 1 +
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/declarative/pkupdates.cpp b/src/declarative/pkupdates.cpp
index f04c173..50265c9 100644
--- a/src/declarative/pkupdates.cpp
+++ b/src/declarative/pkupdates.cpp
@@ -134,6 +134,8 @@ QString PkUpdates::message() const
return msg + "<br>" + i18n("(including %1)", extra.join(i18n(" and ")));
} else if (!isNetworkOnline()) {
return i18n("Your system is offline");
+ } else if (!m_lastCheckSuccessful) {
+ return i18n("Checking for updates failed");
}
return i18n("Your system is up to date");
@@ -345,7 +347,9 @@ void PkUpdates::onFinished(PackageKit::Transaction::Exit status, uint runtime)
"in" << runtime/1000 << "seconds";
if (trans->role() == PackageKit::Transaction::RoleRefreshCache) {
- if (status == PackageKit::Transaction::ExitSuccess) {
+ m_lastCheckSuccessful = status == PackageKit::Transaction::ExitSuccess;
+
+ if (m_lastCheckSuccessful) {
qCDebug(PLASMA_PK_UPDATES) << "Cache transaction finished successfully";
// save the timestamp
@@ -359,7 +363,9 @@ void PkUpdates::onFinished(PackageKit::Transaction::Exit status, uint runtime)
emit done();
}
} else if (trans->role() == PackageKit::Transaction::RoleGetUpdates) {
- if (status == PackageKit::Transaction::ExitSuccess) {
+ m_lastCheckSuccessful = status == PackageKit::Transaction::ExitSuccess;
+
+ if (m_lastCheckSuccessful) {
qCDebug(PLASMA_PK_UPDATES) << "Check updates transaction finished successfully";
const int upCount = count();
if (upCount > 0) {
diff --git a/src/declarative/pkupdates.h b/src/declarative/pkupdates.h
index 10eeea8..6bb1b83 100644
--- a/src/declarative/pkupdates.h
+++ b/src/declarative/pkupdates.h
@@ -227,6 +227,7 @@ private:
QString m_statusMessage;
int m_percentage = 0;
Activity m_activity = Idle;
+ bool m_lastCheckSuccessful = false;
};
#endif // PLASMA_PK_UPDATES_H
--
2.15.0