Skip to content

Commit c15cf9d

Browse files
committed
Notifications: Only show "Silence" button for notification Toasts
Non-notification toasts which are of type Warning or Error cannot be silenced as they cannot cause an alarm, since only notification backed toasts can cause alarms. This commit ensures that the "Silence" button will only be shown for notification-backed warning/error toasts, and that the normal "X" (dismiss/close) button is shown for non-notification-backed toasts. Contributes to issue #2675
1 parent 074c3c9 commit c15cf9d

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

components/ToastNotification.qml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,14 @@ Item {
9898
margins: isSilenceButton ? Theme.geometry_toastNotification_label_padding : 0
9999
}
100100

101-
readonly property bool isSilenceButton: root.type === VenusOS.Notification_Warning || root.type === VenusOS.Notification_Alarm
101+
readonly property bool isSilenceButton: notificationModelId !== 0 && (root.type === VenusOS.Notification_Warning || root.type === VenusOS.Notification_Alarm)
102102
width: isSilenceButton ? silenceLabel.x + silenceLabel.implicitWidth + silenceLabel.anchors.rightMargin
103103
: Theme.geometry_toastNotification_minHeight
104104
radius: isSilenceButton ? Theme.geometry_button_radius : Theme.geometry_button_border_width
105105

106106
onClicked: {
107-
if (isSilenceButton) {
107+
if (notificationModelId !== 0
108+
&& (root.type === VenusOS.Notification_Warning || root.type === VenusOS.Notification_Alarm)) {
108109
// Silence all similar or lower-level notifications by acknowledging them.
109110
// Do NOT acknowledge Info notifications, as they don't buzz, and we
110111
// still want the user to see the number of outstanding notifications
@@ -115,13 +116,16 @@ Item {
115116
} else {
116117
NotificationModel.acknowledgeType(VenusOS.Notification_Warning)
117118
}
118-
} else {
119+
}
120+
121+
if (root.type === VenusOS.Notification_Info) {
119122
// for Info toasts, remove from the toast model (but do NOT acknowledge) all Info toasts.
120123
// This ensures that if something generates a hundred Info toasts in a row the user
121124
// doesn't have to manually dismiss them all, but can still see the number of
122125
// unacknowledged notifications in the Notifications navbar icon bubble number.
123126
ToastModel.removeAllInfoExcept(root.toastModelId)
124127
}
128+
125129
root.dismissed()
126130
}
127131

0 commit comments

Comments
 (0)