diff --git a/.config/quickshell/ii/GlobalStates.qml b/.config/quickshell/ii/GlobalStates.qml index 077a810bc..caf94ab16 100644 --- a/.config/quickshell/ii/GlobalStates.qml +++ b/.config/quickshell/ii/GlobalStates.qml @@ -1,5 +1,6 @@ -import qs.modules.common import qs +import qs.modules.common +import qs.services import QtQuick import Quickshell import Quickshell.Hyprland @@ -44,6 +45,13 @@ Singleton { } } + onSidebarRightOpenChanged: { + if (GlobalStates.sidebarRightOpen) { + Notifications.timeoutAll(); + Notifications.markAllRead(); + } + } + property real screenZoom: 1 onScreenZoomChanged: { Quickshell.execDetached(["hyprctl", "keyword", "cursor:zoom_factor", root.screenZoom.toString()]); diff --git a/.config/quickshell/ii/modules/bar/BarContent.qml b/.config/quickshell/ii/modules/bar/BarContent.qml index 990db4b20..b69fd6646 100644 --- a/.config/quickshell/ii/modules/bar/BarContent.qml +++ b/.config/quickshell/ii/modules/bar/BarContent.qml @@ -295,6 +295,48 @@ Item { // Bar content region Layout.rightMargin: indicatorsRowLayout.realSpacing color: rightSidebarButton.colText } + Revealer { + reveal: Notifications.silent || Notifications.unread > 0 + Layout.fillHeight: true + Layout.rightMargin: reveal ? indicatorsRowLayout.realSpacing : 0 + implicitHeight: reveal ? notificationIcon.implicitHeight : 0 + implicitWidth: reveal ? notificationIcon.implicitWidth : 0 + Behavior on Layout.rightMargin { + animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this) + } + Rectangle { + id: notifPing + visible: !Notifications.silent && Notifications.unread > 0 + property bool showUnreadCount: Config.options.bar.indicators.notifications.showUnreadCount + anchors { + right: parent.right + top: parent.top + rightMargin: showUnreadCount ? 0 : 1 + topMargin: showUnreadCount ? 0 : 3 + } + radius: Appearance.rounding.full + color: Appearance.colors.colOnLayer0 + z: 1 + + implicitHeight: showUnreadCount ? Math.max(notificationCounterText.implicitWidth, notificationCounterText.implicitHeight) : 8 + implicitWidth: implicitHeight + + StyledText { + id: notificationCounterText + visible: notifPing.showUnreadCount + anchors.centerIn: parent + font.pixelSize: Appearance.font.pixelSize.smallest + color: Appearance.colors.colLayer0 + text: Notifications.unread + } + } + MaterialSymbol { + id: notificationIcon + text: Notifications.silent ? "notifications_paused" : "notifications" + iconSize: Appearance.font.pixelSize.larger + color: rightSidebarButton.colText + } + } MaterialSymbol { Layout.rightMargin: indicatorsRowLayout.realSpacing text: Network.materialSymbol diff --git a/.config/quickshell/ii/modules/common/Config.qml b/.config/quickshell/ii/modules/common/Config.qml index f20dba034..81edcf9c5 100644 --- a/.config/quickshell/ii/modules/common/Config.qml +++ b/.config/quickshell/ii/modules/common/Config.qml @@ -212,6 +212,11 @@ Singleton { property bool useUSCS: false // Instead of metric (SI) units property int fetchInterval: 10 // minutes } + property JsonObject indicators: JsonObject { + property JsonObject notifications: JsonObject { + property bool showUnreadCount: false + } + } } property JsonObject battery: JsonObject { diff --git a/.config/quickshell/ii/modules/sidebarRight/SidebarRight.qml b/.config/quickshell/ii/modules/sidebarRight/SidebarRight.qml index cdc861ce6..fcba76710 100644 --- a/.config/quickshell/ii/modules/sidebarRight/SidebarRight.qml +++ b/.config/quickshell/ii/modules/sidebarRight/SidebarRight.qml @@ -70,7 +70,6 @@ Scope { function toggle(): void { GlobalStates.sidebarRightOpen = !GlobalStates.sidebarRightOpen; - if(GlobalStates.sidebarRightOpen) Notifications.timeoutAll(); } function close(): void { @@ -79,7 +78,6 @@ Scope { function open(): void { GlobalStates.sidebarRightOpen = true; - Notifications.timeoutAll(); } } @@ -89,7 +87,6 @@ Scope { onPressed: { GlobalStates.sidebarRightOpen = !GlobalStates.sidebarRightOpen; - if(GlobalStates.sidebarRightOpen) Notifications.timeoutAll(); } } GlobalShortcut { @@ -98,7 +95,6 @@ Scope { onPressed: { GlobalStates.sidebarRightOpen = true; - Notifications.timeoutAll(); } } GlobalShortcut { diff --git a/.config/quickshell/ii/services/Notifications.qml b/.config/quickshell/ii/services/Notifications.qml index 00a87c3a7..16d8b760f 100644 --- a/.config/quickshell/ii/services/Notifications.qml +++ b/.config/quickshell/ii/services/Notifications.qml @@ -69,6 +69,7 @@ Singleton { } property bool silent: false + property int unread: 0 property var filePath: Directories.notificationsPath property list list: [] property var popupList: list.filter((notif) => notif.popup); @@ -173,12 +174,17 @@ Singleton { } } + root.unread++; root.notify(newNotifObject); // console.log(notifToString(newNotifObject)); notifFileView.setText(stringifyList(root.list)); } } + function markAllRead() { + root.unread = 0; + } + function discardNotification(id) { console.log("[Notifications] Discarding notification with ID: " + id); const index = root.list.findIndex((notif) => notif.notificationId === id);