Unread notification count on bar (#2153)

This commit is contained in:
end-4
2025-10-12 10:24:17 +02:00
committed by GitHub
5 changed files with 62 additions and 5 deletions
@@ -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
@@ -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 {
@@ -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 {