feat: add NotificationButton widget to bar to display notifications and work NotificationButton to a usable state

This commit is contained in:
Hannes
2026-08-27 21:50:50 +02:00
parent 3cd6807681
commit f2e8d8a144
6 changed files with 230 additions and 34 deletions
+1
View File
@@ -73,6 +73,7 @@ PanelWindow {
// TODO: Add bluetooth, network, audio, power, maybe HW monitor // TODO: Add bluetooth, network, audio, power, maybe HW monitor
Tray{} Tray{}
NotificationButton {}
// AudioSource{} // AudioSource{}
AudioSink{} AudioSink{}
Battery{} Battery{}
@@ -0,0 +1,41 @@
import QtQuick
import Quickshell
import Quickshell.Widgets
import Quickshell.Io
import "../../notification/notificationServer/"
import "../../../config"
MouseArea {
id: notificationButton
width: Math.max(bar.height, notificationText.width + Config.spacing)
height: bar.height
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: {
menuProc.running = true
}
Rectangle {
anchors.fill: parent
color: "transparent"
radius: Config.radius_fun(notificationButton.height)
Text {
id: notificationText
anchors.centerIn: parent
text: Quickshell.iconPath("discord")
// text: "󰂚"
font.pixelSize: Config.bigIconSize(notificationButton.height)
font.family: Config.font
color: Colors.secondaryContainer_fg
}
Image{
id: iconImage
source: Quickshell.iconPath("discord")
width: Config.bigIconSize(notificationButton.height)
height: Config.bigIconSize(notificationButton.height)
}
}
}
+3 -1
View File
@@ -58,9 +58,11 @@ PanelWindow {
notification: notificationData notification: notificationData
onDismissed: function(notification) { onDismissed: function(notification, dismiss) {
notificationListModel.remove(index) notificationListModel.remove(index)
if (dismiss) {
notification.dismiss() notification.dismiss()
}
console.log("[Notification]: Dismissed Notification:", notification.appName, notification.id, notification.summary, notification.body) console.log("[Notification]: Dismissed Notification:", notification.appName, notification.id, notification.summary, notification.body)
} }
} }
+165 -23
View File
@@ -1,17 +1,20 @@
import QtQuick import QtQuick
import Quickshell import Quickshell
import "../../config" import "../../config"
import QtQuick.Layouts
Rectangle { Rectangle {
id: root id: root
//TODO: urgency, expireTimeoutText, ...
required property var notification required property var notification
property real duration: 5000 // Expected in milliseconds (e.g., 5000 for 5s) property real duration: 5000 // Expected in milliseconds (e.g., 5000 for 5s)
signal dismissed(var notification) signal dismissed(var notification, bool dismiss)
implicitWidth: content.implicitWidth + 2*18 implicitWidth: iconColumn.width+contentColumn.width+2*Config.spacing
implicitHeight: content.implicitHeight + 18 + progressBar.height implicitHeight: Math.max(iconColumn.height, contentColumn.height)+Config.spacing+Config.spacing
color: Qt.alpha(Colors.primaryContainer, 0.75) color: Qt.alpha(Colors.primaryContainer, 0.75)
border.width: Config.border_width border.width: Config.border_width
@@ -23,40 +26,179 @@ Rectangle {
hoverEnabled: true hoverEnabled: true
onClicked: { onClicked: {
dismissed(root.notification) dismissed(root.notification, true)
} }
Column { Row {
id: content id: contentRow
anchors.fill: parent anchors.fill: parent
anchors.margins: 10 anchors.margins: 10
spacing: 5 spacing: Config.spacing
Text { // Left side: icon + icon information
id: appNameText Column {
text: root.notification?.id + ": " + (root.notification?.appName ?? "") id: iconColumn
font.family: Config.font height: Math.max(iconImage.height+summaryText.height+3*Config.spacing, contentColumn.height)+Config.spacing
font.pixelSize: 18 width: Math.max(128, summaryText.implicitWidth) + Config.spacing
color: Colors.primary spacing: Config.spacing
elide: Text.ElideRight
Image {
id: iconImage
width: 128
height: 128
source: Quickshell.iconPath(root.notification?.appIcon ?? "")
fillMode: Image.PreserveAspectFit
asynchronous: true
} }
Text { Text {
id: summaryText id: summaryText
Layout.fillWidth: true
text: root.notification?.summary ?? "" text: root.notification?.summary ?? ""
font.family: Config.font font.family: Config.font
font.pixelSize: 22 font.pixelSize: 22
color: Colors.primary color: Colors.primary
wrapMode: Text.Wrap
horizontalAlignment: Text.AlignHCenter
}
}
// Right side: notification information
Column {
id: contentColumn
width: bodyText.width + Config.spacing
spacing: Config.spacing
Text {
id: bodyText
text: root.notification?.body ?? ""
width: Math.min(implicitWidth, iconColumn.width*2)
font.family: Config.font
font.pixelSize: 22
color: Colors.primary
wrapMode: Text.Wrap wrapMode: Text.Wrap
} }
Text { // Text {
id: bodyText // id: appNameText
text: root.notification?.body ?? "" // width: parent.width
font.family: Config.font // text: root.notification?.id + ": " +
font.pixelSize: 16 // (root.notification?.appName ?? "")
color: Colors.primary // font.family: Config.font
wrapMode: Text.Wrap // font.pixelSize: 18
// color: Colors.primary
// elide: Text.ElideRight
// }
// Text {
// id: inlineReplyPlaceholderText
// width: parent.width
// text: "inlineReplyPlaceholder: " + (root.notification?.inlineReplyPlaceholder ?? "")
// font.family: Config.font
// font.pixelSize: 16
// color: Colors.primary
// wrapMode: Text.Wrap
// }
// Text {
// id: iconPathText
// width: parent.width
// text: "iconPath: " + (root.notification?.iconPath ?? "")
// font.family: Config.font
// font.pixelSize: 16
// color: Colors.primary
// wrapMode: Text.Wrap
// }
// Text {
// id: expireTimeoutText
// width: parent.width
// text: "expireTimeout: " +
// (root.notification?.expireTimeout ?? "")
// font.family: Config.font
// font.pixelSize: 16
// color: Colors.primary
// wrapMode: Text.Wrap
// }
// Text {
// id: residentText
// width: parent.width
// text: "resident: " + (root.notification?.resident ?? "")
// font.family: Config.font
// font.pixelSize: 16
// color: Colors.primary
// wrapMode: Text.Wrap
// }
// Text {
// id: urgencyText
// width: parent.width
// text: "urgency: " + (root.notification?.urgency ?? "")
// font.family: Config.font
// font.pixelSize: 16
// color: Colors.primary
// wrapMode: Text.Wrap
// }
// Text {
// id: desktopEntryText
// width: parent.width
// text: "desktopEntry: " +
// (root.notification?.desktopEntry ?? "")
// font.family: Config.font
// font.pixelSize: 16
// color: Colors.primary
// wrapMode: Text.Wrap
// }
// Text {
// id: hintsText
// width: parent.width
// text: "hints: " + (root.notification?.hints ?? "")
// font.family: Config.font
// font.pixelSize: 16
// color: Colors.primary
// wrapMode: Text.Wrap
// }
// Text {
// id: transientText
// width: parent.width
// text: "transient: " + (root.notification?.transient ?? "")
// font.family: Config.font
// font.pixelSize: 16
// color: Colors.primary
// wrapMode: Text.Wrap
// }
// Text {
// id: hasInlineReplyText
// width: parent.width
// text: "hasInlineReply: " +
// (root.notification?.hasInlineReply ?? "")
// font.family: Config.font
// font.pixelSize: 16
// color: Colors.primary
// wrapMode: Text.Wrap
// }
// Text {
// id: hasActionIconsText
// width: parent.width
// text: "hasActionIcons: " +
// (root.notification?.hasActionIcons ?? "")
// font.family: Config.font
// font.pixelSize: 16
// color: Colors.primary
// wrapMode: Text.Wrap
// }
} }
} }
} }
@@ -66,7 +208,7 @@ Rectangle {
id: progressBar id: progressBar
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.left: parent.left anchors.left: parent.left
height: 10 height: Math.min(10, 0.1 * root.height)
color: Colors.primary color: Colors.primary
property real progress: 1.0 property real progress: 1.0
@@ -81,7 +223,7 @@ Rectangle {
duration: root.duration duration: root.duration
paused: mouseArea.containsMouse paused: mouseArea.containsMouse
onFinished: root.dismissed(root.notification) onFinished: root.dismissed(root.notification, false)
} }
} }
@@ -34,6 +34,16 @@ Item {
NotificationServer { NotificationServer {
id: notificationServer id: notificationServer
actionsSupported: true
bodyHyperlinksSupported: true
bodyImagesSupported: true
actionIconsSupported: true
imageSupported: true
persistenceSupported: true
bodyMarkupSupported: true
inlineReplySupported: true
onNotification: function(notification) { onNotification: function(notification) {
// if(notification.lastGeneration){ // if(notification.lastGeneration){
// console.log( // console.log(
+1 -1
View File
@@ -62,7 +62,7 @@ Variants {
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
onClicked: { onClicked: {
console.log("clicked ???, closing Wallpaper Picker") console.log("clicked Background, closing Wallpaper Picker")
wlogoutLoader.active = false wlogoutLoader.active = false
} }
GridLayout { GridLayout {