Commit 8dc1db04 authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇
Browse files

[Notifications] Add hint for a notification being response to explicit user interaction

This can be useful for notifications that confirm direct user interaction, such as successful Bluetooth pairing,
Screenshot creation, or plasmoid removal.
It only overrules filtering based on urgency, disabling notifications for that application altogether will still hide them.
Such a notification also won't increase the unread counter as it can be assumed when they do something, e.g. click on "Pair",
they will notice that the pairing progress dialog went away and a confirmation notification is shown.

Differential Revision:
parent 90a69a7b
......@@ -380,6 +380,12 @@ void Notification::Private::processHints(const QVariantMap &hints)
userActionFeedback = hints.value(QStringLiteral("x-kde-user-action-feedback")).toBool();
if (userActionFeedback) {
// A confirmation of an explicit user interaction is assumed to have been seen by the user.
read = true;
urls = QUrl::fromStringList(hints.value(QStringLiteral("x-kde-urls")).toStringList());
// Underscored hints was in use in version 1.1 of the spec but has been
......@@ -652,6 +658,11 @@ Notifications::Urgency Notification::urgency() const
return d->urgency;
bool Notification::userActionFeedback() const
return d->userActionFeedback;
int Notification::timeout() const
return d->timeout;
......@@ -101,6 +101,8 @@ public:
Notifications::Urgency urgency() const;
void setUrgency(Notifications::Urgency urgency);
bool userActionFeedback() const;
int timeout() const;
void setTimeout(int timeout);
......@@ -90,6 +90,7 @@ public:
QList<QUrl> urls;
bool userActionFeedback = false;
Notifications::Urgency urgency = Notifications::NormalUrgency;
int timeout = -1;
......@@ -178,6 +178,11 @@ bool NotificationFilterProxyModel::filterAcceptsRow(int source_row, const QModel
const bool userActionFeedback =;
if (userActionFeedback) {
return true;
bool ok;
const auto urgency = static_cast<Notifications::Urgency>(;
if (ok) {
......@@ -257,7 +257,9 @@ public:
ExpiredRole, ///< The notification timed out and closed. Actions on it cannot be invoked anymore.
DismissedRole, ///< The notification got temporarily hidden by the user but could still be interacted with.
ReadRole ///< Whether the notification got read by the user. If true, the notification isn't considered unread even if created after lastRead. @since 5.17
ReadRole, ///< Whether the notification got read by the user. If true, the notification isn't considered unread even if created after lastRead. @since 5.17
UserActionFeedbackRole, ///< Whether this notification is a response/confirmation to an explicit user action. @since 5.18
......@@ -300,6 +300,7 @@ QVariant NotificationsModel::data(const QModelIndex &index, int role) const
case Notifications::UrlsRole: return QVariant::fromValue(notification.urls());
case Notifications::UrgencyRole: return static_cast<int>(notification.urgency());
case Notifications::UserActionFeedbackRole: return notification.userActionFeedback();
case Notifications::TimeoutRole: return notification.timeout();
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