Commit 0c1c5a16 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

Use update-high as the updates page icon if there's security updates

BUG: 381170
parent 91fa0231
......@@ -69,7 +69,7 @@ Kirigami.ApplicationWindow
}
TopLevelPageData {
id: updateAction
iconName: ResourcesModel.updatesCount>0 ? "update-low" : "update-none"
iconName: ResourcesModel.updatesCount>0 ? ResourcesModel.hasSecurityUpdates ? "update-high" : "update-low" : "update-none"
text: ResourcesModel.updatesCount<=0 ? (ResourcesModel.isFetching ? i18n("Checking for updates...") : i18n("No Updates") ) : i18nc("Update section name", "Update (%1)", ResourcesModel.updatesCount)
component: topUpdateComp
objectName: "update"
......
......@@ -246,6 +246,7 @@ void PackageKitBackend::fetchUpdates()
connect(tUpdates, &PackageKit::Transaction::package, this, &PackageKitBackend::addPackageToUpdate);
connect(tUpdates, &PackageKit::Transaction::errorCode, this, &PackageKitBackend::transactionError);
m_updatesPackageId.clear();
m_hasSecurityUpdates = false;
m_updater->setProgressing(true);
}
......@@ -417,6 +418,11 @@ ResultsStream * PackageKitBackend::findResourceByPackageName(const QUrl& url)
return new ResultsStream(QStringLiteral("PackageKitStream-url"), pkg ? QVector<AbstractResource*>{pkg} : QVector<AbstractResource*>{});
}
bool PackageKitBackend::hasSecurityUpdates() const
{
return m_hasSecurityUpdates;
}
int PackageKitBackend::updatesCount() const
{
return m_updatesPackageId.count();
......@@ -478,10 +484,15 @@ QSet<AbstractResource*> PackageKitBackend::upgradeablePackages() const
void PackageKitBackend::addPackageToUpdate(PackageKit::Transaction::Info info, const QString& packageId, const QString& summary)
{
if (info != PackageKit::Transaction::InfoBlocked) {
m_updatesPackageId += packageId;
addPackage(info, packageId, summary, true);
if (info == PackageKit::Transaction::InfoBlocked) {
return;
}
if (info == PackageKit::Transaction::InfoSecurity)
m_hasSecurityUpdates = true;
m_updatesPackageId += packageId;
addPackage(info, packageId, summary, true);
}
void PackageKitBackend::getUpdatesFinished(PackageKit::Transaction::Exit, uint)
......
......@@ -50,6 +50,7 @@ class DISCOVERCOMMON_EXPORT PackageKitBackend : public AbstractResourcesBackend
ResultsStream* search(const AbstractResourcesBackend::Filters & search) override;
ResultsStream* findResourceByPackageName(const QUrl& search) override;
int updatesCount() const override;
bool hasSecurityUpdates() const override;
Transaction* installApplication(AbstractResource* app) override;
Transaction* installApplication(AbstractResource* app, const AddonList& addons) override;
......@@ -107,6 +108,7 @@ class DISCOVERCOMMON_EXPORT PackageKitBackend : public AbstractResourcesBackend
QPointer<PackageKit::Transaction> m_refresher;
int m_isFetching;
QSet<QString> m_updatesPackageId;
bool m_hasSecurityUpdates = false;
QSet<PackageKitResource*> m_packagesToAdd;
QSet<PackageKitResource*> m_packagesToDelete;
QList<QAction*> m_messageActions;
......
......@@ -76,6 +76,7 @@ class DISCOVERCOMMON_EXPORT AbstractResourcesBackend : public QObject
Q_PROPERTY(QString displayName READ displayName CONSTANT)
Q_PROPERTY(AbstractReviewsBackend* reviewsBackend READ reviewsBackend CONSTANT)
Q_PROPERTY(int updatesCount READ updatesCount NOTIFY updatesCountChanged)
Q_PROPERTY(bool hasSecurityUpdates READ hasSecurityUpdates NOTIFY updatesCountChanged)
Q_PROPERTY(bool isFetching READ isFetching NOTIFY fetchingChanged)
Q_PROPERTY(QList<QAction*> messageActions READ messageActions CONSTANT)
public:
......@@ -131,6 +132,11 @@ class DISCOVERCOMMON_EXPORT AbstractResourcesBackend : public QObject
*/
virtual int updatesCount() const = 0;//FIXME: Probably provide a standard implementation?!
/**
* @returns whether either of the updates contains a security fix
*/
virtual bool hasSecurityUpdates() const { return false; }
/**
* Tells whether the backend is fetching resources
*/
......
......@@ -174,6 +174,17 @@ int ResourcesModel::updatesCount() const
return ret;
}
bool ResourcesModel::hasSecurityUpdates() const
{
bool ret = false;
foreach(AbstractResourcesBackend* backend, m_backends) {
ret |= backend->hasSecurityUpdates();
}
return ret;
}
void ResourcesModel::installApplication(AbstractResource* app)
{
TransactionModel::global()->addTransaction(app->backend()->installApplication(app));
......
......@@ -52,6 +52,7 @@ class DISCOVERCOMMON_EXPORT ResourcesModel : public QObject
{
Q_OBJECT
Q_PROPERTY(int updatesCount READ updatesCount NOTIFY updatesCountChanged)
Q_PROPERTY(bool hasSecurityUpdates READ hasSecurityUpdates NOTIFY updatesCountChanged)
Q_PROPERTY(bool isFetching READ isFetching NOTIFY fetchingChanged)
Q_PROPERTY(QVariantList applicationBackends READ applicationBackendsVariant NOTIFY backendsChanged)
Q_PROPERTY(AbstractResourcesBackend* currentApplicationBackend READ currentApplicationBackend WRITE setCurrentApplicationBackend NOTIFY currentApplicationBackendChanged)
......@@ -65,6 +66,7 @@ class DISCOVERCOMMON_EXPORT ResourcesModel : public QObject
QVector< AbstractResourcesBackend* > backends() const;
int updatesCount() const;
bool hasSecurityUpdates() const;
bool isBusy() const;
bool isFetching() const;
......
Markdown is supported
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