New setting to clear notif from history when dismissed

This commit is contained in:
Thibault Martin
2026-02-16 14:01:56 +01:00
parent 73254f892f
commit c2b32e8416
6 changed files with 41 additions and 13 deletions
+3
View File
@@ -1277,6 +1277,8 @@
"duration-respect-expire-description": "Use the expire timeout set in the notification.",
"duration-respect-expire-label": "Respect expire timeout",
"duration-title": "Notification duration",
"history-clear-dismiss-description": "Clear notification from history when dismissed.",
"history-clear-dismiss-label": "Clear on dismissed",
"history-critical-urgency-description": "Save critical priority notifications to history.",
"history-critical-urgency-label": "Save critical urgency to history",
"history-desc": "Control which notifications are saved to history based on their urgency level.",
@@ -1768,6 +1770,7 @@
"collapse": "Collapse sidebar",
"copy-address": "Copy address",
"delete-notification": "Delete notification",
"dismiss-notification": "Dismiss notification",
"do-not-disturb-enabled": "Do Not Disturb",
"expand": "Expand sidebar",
"forget-network": "Forget network",
+1
View File
@@ -397,6 +397,7 @@
"lowUrgencyDuration": 3,
"normalUrgencyDuration": 8,
"criticalUrgencyDuration": 15,
"clearDismissed": true,
"saveToHistory": {
"low": true,
"normal": true,
+9
View File
@@ -1197,6 +1197,15 @@
"subTab": 0,
"subTabLabel": "common.appearance"
},
{
"labelKey": "panels.notifications.history-clear-dismiss-label",
"descriptionKey": "panels.notifications.history-clear-dismiss-description",
"widget": "NToggle",
"tab": 9,
"tabLabel": "common.notifications",
"subTab": 2,
"subTabLabel": "common.history"
},
{
"labelKey": "panels.notifications.settings-markdown-label",
"descriptionKey": "panels.notifications.settings-markdown-description",
+1
View File
@@ -605,6 +605,7 @@ Singleton {
property int lowUrgencyDuration: 3
property int normalUrgencyDuration: 8
property int criticalUrgencyDuration: 15
property bool clearDismissed: true
property JsonObject saveToHistory: JsonObject {
property bool low: true
property bool normal: true
+19 -13
View File
@@ -374,6 +374,9 @@ Variants {
onReleased: mouse => {
if (mouse.button === Qt.RightButton) {
card.animateOut();
if (Settings.data.notifications.clearDismissed) {
NotificationService.removeFromHistory(notificationId);
}
return;
}
@@ -385,6 +388,9 @@ Variants {
const threshold = card.useVerticalSwipe ? card.verticalSwipeDismissThreshold : card.swipeDismissThreshold;
if (dismissDistance >= threshold) {
card.dismissBySwipe();
if (Settings.data.notifications.clearDismissed) {
NotificationService.removeFromHistory(notificationId);
}
} else {
card.swipeOffset = 0;
card.swipeOffsetY = 0;
@@ -402,7 +408,7 @@ Variants {
return a.identifier === "default";
});
if (hasDefault) {
card.runDeferredAction("default", false);
card.runDeferredTimer("default", false);
}
}
onCanceled: {
@@ -491,12 +497,12 @@ Variants {
}
}
function runDeferredAction(actionId, isHistoryRemoval) {
function runDeferredTimer(actionId, isDismissed) {
if (Style.animationSlow <= 0) {
if (isHistoryRemoval) {
NotificationService.removeFromHistory(notificationId);
} else {
if (!isDismissed) {
NotificationService.invokeAction(notificationId, actionId);
} else if (Settings.data.notifications.clearDismissed) {
NotificationService.removeFromHistory(notificationId);
}
card.animateOut();
return;
@@ -504,7 +510,7 @@ Variants {
deferredActionTimer.stop();
deferredActionTimer.actionId = actionId || "";
deferredActionTimer.isHistoryRemoval = isHistoryRemoval;
deferredActionTimer.isDismissed = isDismissed;
deferredActionTimer.interval = Math.min(50, Math.max(1, Style.animationSlow - 1));
card.animateOut();
deferredActionTimer.start();
@@ -523,12 +529,12 @@ Variants {
id: deferredActionTimer
interval: 50
property string actionId: ""
property bool isHistoryRemoval: false
property bool isDismissed: false
onTriggered: {
if (isHistoryRemoval) {
NotificationService.removeFromHistory(notificationId);
} else {
if (!isDismissed) {
NotificationService.invokeAction(notificationId, actionId);
} else if (Settings.data.notifications.clearDismissed) {
NotificationService.removeFromHistory(notificationId);
}
}
}
@@ -716,7 +722,7 @@ Variants {
outlined: false
implicitHeight: 24
onClicked: {
card.runDeferredAction(actionData.identifier, false);
card.runDeferredTimer(actionData.identifier, false);
}
}
}
@@ -729,7 +735,7 @@ Variants {
NIconButton {
visible: !notifWindow.isCompact
icon: "close"
tooltipText: I18n.tr("common.close")
tooltipText: I18n.tr("tooltips.dismiss-notification")
baseSize: Style.baseWidgetSize * 0.6
anchors.top: cardBackground.top
anchors.topMargin: Style.marginM
@@ -737,7 +743,7 @@ Variants {
anchors.rightMargin: Style.marginM
onClicked: {
card.runDeferredAction("", true);
card.runDeferredTimer("", true);
}
}
@@ -9,6 +9,14 @@ ColumnLayout {
spacing: Style.marginL
Layout.fillWidth: true
NToggle {
label: I18n.tr("panels.notifications.history-clear-dismiss-label")
description: I18n.tr("panels.notifications.history-clear-dismiss-description")
checked: Settings.data.notifications.clearDismissed
onToggled: checked => Settings.data.notifications.clearDismissed = checked
defaultValue: Settings.getDefaultValue("notifications.clearDismissed")
}
NToggle {
label: I18n.tr("panels.notifications.settings-markdown-label")
description: I18n.tr("panels.notifications.settings-markdown-description")