Projects
Eulaceura:Factory
plasma-pk-updates
_service:obs_scm:0011-Make-the-notifications-le...
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:obs_scm:0011-Make-the-notifications-less-obtrusive.patch of Package plasma-pk-updates
From 50383c74098bf19cea1b90a2edea7477ff8b062d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Br=C3=BCns?= <stefan.bruens@rwth-aachen.de> Date: Sat, 22 Jun 2019 23:04:42 +0200 Subject: [PATCH 11/51] Make the notifications less obtrusive Summary: Currently, whenever the PK package cache is refreshed, a new notification is show, even when the update count does not change. The notification also persists after the update has installed. To make the notifications less obtrusive: 1. Skip the "You have N new updates" message generation completely when the update count is unchanged. 2. In case the update count changes, close the old one generate a new one. Using "CloseOnTimeout" has the 3. Change the "Updates Installed" notification from "Persistent" to "CloseOnTimeout". The notification is still in the history. 4. After update installation, also remove the "You have N new updates" Popup. Depends on D22026 Test Plan: call `pkcon refresh` multiple times Reviewers: jgrulich, lukas, ngraham, fvogt Reviewed By: ngraham, fvogt Differential Revision: https://phabricator.kde.org/D22027 --- src/declarative/pkupdates.cpp | 19 ++++++++++++++++--- src/declarative/pkupdates.h | 3 +++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/declarative/pkupdates.cpp b/src/declarative/pkupdates.cpp index 4de20dd..937e318 100644 --- a/src/declarative/pkupdates.cpp +++ b/src/declarative/pkupdates.cpp @@ -397,12 +397,22 @@ void PkUpdates::onFinished(PackageKit::Transaction::Exit status, uint runtime) if (m_lastCheckSuccessful) { qCDebug(PLASMA_PK_UPDATES) << "Check updates transaction finished successfully"; const int upCount = count(); - if (upCount > 0) { - KNotification::event(s_eventIdUpdatesAvailable, + if (upCount != m_lastUpdateCount && m_lastNotification) { + qCDebug(PLASMA_PK_UPDATES) << "Disposing old update count notification"; + m_lastNotification->close(); + } + if (upCount > 0 && upCount != m_lastUpdateCount) { + m_lastUpdateCount = upCount; + m_lastNotification = KNotification::event(s_eventIdUpdatesAvailable, QString(), i18np("You have 1 new update", "You have %1 new updates", upCount), s_pkUpdatesIconName, nullptr, KNotification::Persistent, s_componentName); + connect(m_lastNotification, &KNotification::closed, this, [this] { + qCDebug(PLASMA_PK_UPDATES) << "Old notification closed"; + m_lastNotification = nullptr; + m_lastUpdateCount = 0; + }); } } else { qCDebug(PLASMA_PK_UPDATES) << "Check updates transaction didn't finish successfully"; @@ -423,11 +433,14 @@ void PkUpdates::onFinished(PackageKit::Transaction::Exit status, uint runtime) return; } else if (status == PackageKit::Transaction::ExitSuccess) { qCDebug(PLASMA_PK_UPDATES) << "Update packages transaction finished successfully"; + if (m_lastNotification) { + m_lastNotification->close(); + } KNotification::event(s_eventIdUpdatesInstalled, i18n("Updates Installed"), i18np("Successfully updated %1 package", "Successfully updated %1 packages", packages.count()), s_pkUpdatesIconName, nullptr, - KNotification::Persistent, + KNotification::CloseOnTimeout, s_componentName); emit updatesInstalled(); } else { diff --git a/src/declarative/pkupdates.h b/src/declarative/pkupdates.h index d9cb063..ef02cc9 100644 --- a/src/declarative/pkupdates.h +++ b/src/declarative/pkupdates.h @@ -29,6 +29,7 @@ #include <PackageKit/Transaction> class QTimer; +class KNotification; Q_DECLARE_LOGGING_CATEGORY(PLASMA_PK_UPDATES) @@ -229,6 +230,8 @@ private: QPointer<PackageKit::Transaction> m_cacheTrans; QPointer<PackageKit::Transaction> m_installTrans; QPointer<PackageKit::Transaction> m_detailTrans; + QPointer<KNotification> m_lastNotification; + int m_lastUpdateCount = 0; QVariantMap m_updateList; QStringList m_importantList; QStringList m_securityList; -- 2.28.0
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2