From 4280515eebb01d20e04bed48bd91921b48ebc014 Mon Sep 17 00:00:00 2001 From: Kai Uwe Broulik Date: Mon, 23 Dec 2019 11:47:37 +0100 Subject: [PATCH] [Notifications] For non-configurable applications use fake "@other" category Allows to control the behavior of those applications rather than flat-out ignoring them. Adjust default configuration to blacklist them, though. Differential Revision: https://phabricator.kde.org/D26160 --- .../notificationfilterproxymodel.cpp | 18 +++++++++--------- libnotificationmanager/plasmanotifyrc | 5 +++++ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/libnotificationmanager/notificationfilterproxymodel.cpp b/libnotificationmanager/notificationfilterproxymodel.cpp index ab3a96c47..324743997 100644 --- a/libnotificationmanager/notificationfilterproxymodel.cpp +++ b/libnotificationmanager/notificationfilterproxymodel.cpp @@ -137,21 +137,22 @@ bool NotificationFilterProxyModel::filterAcceptsRow(int source_row, const QModel return false; } - // If the application isn't configurable in any way, it doesn't deserve to be in the history - // since there's no way for the user to get rid of it there. - if (expired && !sourceIdx.data(Notifications::ConfigurableRole).toBool() - // jobs are never configurable so this only applies to notifications - && sourceIdx.data(Notifications::TypeRole).toInt() == Notifications::NotificationType) { + if (!m_showDismissed && sourceIdx.data(Notifications::DismissedRole).toBool()) { return false; } - if (!m_showDismissed && sourceIdx.data(Notifications::DismissedRole).toBool()) { - return false; + QString desktopEntry = sourceIdx.data(Notifications::DesktopEntryRole).toString(); + if (desktopEntry.isEmpty()) { + // For non-configurable notifications use the fake "@other" category. + if (!sourceIdx.data(Notifications::ConfigurableRole).toBool() + // jobs are never configurable so this only applies to notifications + && sourceIdx.data(Notifications::TypeRole).toInt() == Notifications::NotificationType) { + desktopEntry = QStringLiteral("@other"); + } } // Blacklist takes precedence over whitelist, i.e. when in doubt don't show if (!m_blacklistedDesktopEntries.isEmpty()) { - const QString desktopEntry = sourceIdx.data(Notifications::DesktopEntryRole).toString(); if (!desktopEntry.isEmpty() && m_blacklistedDesktopEntries.contains(desktopEntry)) { return false; } @@ -165,7 +166,6 @@ bool NotificationFilterProxyModel::filterAcceptsRow(int source_row, const QModel } if (!m_whitelistedDesktopEntries.isEmpty()) { - const QString desktopEntry = sourceIdx.data(Notifications::DesktopEntryRole).toString(); if (!desktopEntry.isEmpty() && m_whitelistedDesktopEntries.contains(desktopEntry)) { return true; } diff --git a/libnotificationmanager/plasmanotifyrc b/libnotificationmanager/plasmanotifyrc index a5d8feaee..03f6b530e 100644 --- a/libnotificationmanager/plasmanotifyrc +++ b/libnotificationmanager/plasmanotifyrc @@ -9,3 +9,8 @@ ShowInHistory=false # Klipper notifications might contain sensitive information [Applications][org.kde.klipper] ShowInHistory=false + +# Non-configurable applications don't deserve to be in history by default +[Applications][@other] +ShowInHistory=false +ShowBadges=false # wouldn't work anyway