From 771ff1446277b6da099b1771a1d06e9275953993 Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Sun, 1 Jun 2025 10:12:37 +0200 Subject: [PATCH] notifications: add silent button --- .../notifications/NotificationList.qml | 46 +++++++++++++------ .../NotificationStatusButton.qml | 15 +++--- .config/quickshell/services/Notifications.qml | 4 +- 3 files changed, 43 insertions(+), 22 deletions(-) diff --git a/.config/quickshell/modules/sidebarRight/notifications/NotificationList.qml b/.config/quickshell/modules/sidebarRight/notifications/NotificationList.qml index 7dd4e28c6..491b7683f 100644 --- a/.config/quickshell/modules/sidebarRight/notifications/NotificationList.qml +++ b/.config/quickshell/modules/sidebarRight/notifications/NotificationList.qml @@ -17,6 +17,7 @@ Item { anchors.right: parent.right anchors.top: parent.top anchors.bottom: statusRow.top + anchors.bottomMargin: 5 clip: true layer.enabled: true @@ -65,17 +66,24 @@ Item { } } - RowLayout { + Item { id: statusRow anchors.left: parent.left anchors.right: parent.right anchors.bottom: parent.bottom + + Layout.fillWidth: true + implicitHeight: Math.max( + controls.implicitHeight, + statusText.implicitHeight + ) + StyledText { - Layout.margins: 10 - Layout.bottomMargin: 5 - Layout.alignment: Qt.AlignVCenter + id: statusText + anchors.left: parent.left + anchors.verticalCenter: parent.verticalCenter + anchors.leftMargin: 10 horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter text: `${Notifications.list.length} notifications` opacity: Notifications.list.length > 0 ? 1 : 0 @@ -85,16 +93,26 @@ Item { } } - Item { Layout.fillWidth: true } + ButtonGroup { + id: controls + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + anchors.rightMargin: 5 - NotificationStatusButton { - Layout.alignment: Qt.AlignVCenter - Layout.margins: 5 - Layout.topMargin: 10 - buttonIcon: "clear_all" - buttonText: qsTr("Clear") - onClicked: () => { - Notifications.discardAllNotifications() + NotificationStatusButton { + buttonIcon: "notifications_paused" + buttonText: qsTr("Silent") + toggled: Notifications.silent + onClicked: () => { + Notifications.silent = !Notifications.silent; + } + } + NotificationStatusButton { + buttonIcon: "clear_all" + buttonText: qsTr("Clear") + onClicked: () => { + Notifications.discardAllNotifications() + } } } } diff --git a/.config/quickshell/modules/sidebarRight/notifications/NotificationStatusButton.qml b/.config/quickshell/modules/sidebarRight/notifications/NotificationStatusButton.qml index f5bb6844a..4bef8903e 100644 --- a/.config/quickshell/modules/sidebarRight/notifications/NotificationStatusButton.qml +++ b/.config/quickshell/modules/sidebarRight/notifications/NotificationStatusButton.qml @@ -9,33 +9,34 @@ GroupButton { property string buttonText: "" property string buttonIcon: "" - baseWidth: contentRowLayout.implicitWidth + 10 * 2 + baseWidth: content.implicitWidth + 10 * 2 baseHeight: 30 - clickedWidth: baseWidth + 15 buttonRadius: baseHeight / 2 buttonRadiusPressed: Appearance.rounding.small colBackground: Appearance.colors.colLayer2 colBackgroundHover: Appearance.colors.colLayer2Hover colBackgroundActive: Appearance.colors.colLayer2Active - background.anchors.fill: button + property color colText: toggled ? Appearance.m3colors.m3onPrimary : Appearance.colors.colOnLayer1 contentItem: Item { + id: content + anchors.fill: parent + implicitWidth: contentRowLayout.implicitWidth + implicitHeight: contentRowLayout.implicitHeight RowLayout { id: contentRowLayout anchors.centerIn: parent spacing: 0 MaterialSymbol { text: buttonIcon - Layout.fillWidth: false iconSize: Appearance.font.pixelSize.larger - color: Appearance.colors.colOnLayer1 + color: button.colText } StyledText { text: buttonText - Layout.fillWidth: false font.pixelSize: Appearance.font.pixelSize.small - color: Appearance.colors.colOnLayer1 + color: button.colText } } } diff --git a/.config/quickshell/services/Notifications.qml b/.config/quickshell/services/Notifications.qml index d5c7e63cb..75033292c 100644 --- a/.config/quickshell/services/Notifications.qml +++ b/.config/quickshell/services/Notifications.qml @@ -60,10 +60,12 @@ Singleton { destroy() } } + + property bool silent: false property var filePath: Directories.notificationsPath property list list: [] property var popupList: list.filter((notif) => notif.popup); - property bool popupInhibited: GlobalStates?.sidebarRightOpen ?? false + property bool popupInhibited: (GlobalStates?.sidebarRightOpen ?? false) || silent property var latestTimeForApp: ({}) Component { id: notifComponent