feat: add notification window with debug option

This commit is contained in:
Hannes
2026-08-29 01:19:21 +02:00
parent 8352ba5a56
commit 095839c45a
4 changed files with 111 additions and 27 deletions
+2
View File
@@ -69,4 +69,6 @@ QtObject {
return maxWidth; return maxWidth;
} }
property string debug: "Notification"
} }
+8 -15
View File
@@ -1,5 +1,6 @@
import QtQuick import QtQuick
import Quickshell import Quickshell
import Quickshell.Hyprland
import Quickshell.Services.Notifications import Quickshell.Services.Notifications
import "../../config" import "../../config"
import "./notificationServer" import "./notificationServer"
@@ -30,7 +31,7 @@ PanelWindow {
if (!NotificationS.correctMonitor(screen)) if (!NotificationS.correctMonitor(screen))
return return
if (NotificationS.correctMonitor(screen)) { if (NotificationS.correctMonitor(screen)) {
console.log("[Notification]: This notification belongs to me!", screen.x, screen.y) console.log("[NotificationWindow " + Hyprland.monitorFor(screen).activeWorkspace.id + "]: This notification belongs to me! ")
notificationListModel.append({notificationData: notification}) notificationListModel.append({notificationData: notification})
} }
} }
@@ -55,15 +56,17 @@ PanelWindow {
delegate: NotificationBody { delegate: NotificationBody {
required property int index required property int index
required property var notificationData required property var notificationData
screen: notificationWindow.screen
notification: notificationData notification: notificationData
onDismissed: function(notification, dismiss) { onDismissed: function(notification, dismiss) {
notificationListModel.remove(index) notificationListModel.remove(index)
if (dismiss) { // if (dismiss) {
notification.dismiss() // notification.dismiss()
} // console.log("[NotificationWindow " + Hyprland.monitorFor(screen).activeWorkspace.id + "]: Dissmiss: " + notification.appName + " " + notification.id + " - " + notification.summary)
console.log("[Notification]: Dismissed Notification:", notification.appName, notification.id, notification.summary, notification.body) // }
console.log("[NotificationWindow " + Hyprland.monitorFor(screen).activeWorkspace.id + "]: Close: " + notification.appName + " " + notification.id + " - " + notification.summary)
} }
} }
onItemAdded: updateContentSize() onItemAdded: updateContentSize()
@@ -92,14 +95,4 @@ PanelWindow {
contentHeight = height contentHeight = height
console.log("[updateContentSize] contentWidth:", contentWidth, "contentHeight:", contentHeight) console.log("[updateContentSize] contentWidth:", contentWidth, "contentHeight:", contentHeight)
} }
Component.onCompleted: {
console.log(
"[Notification]:",
NotificationS,
"notification:",
NotificationS.newestNotification
)
}
} }
+93 -12
View File
@@ -9,11 +9,12 @@ Rectangle {
//TODO: urgency, expireTimeoutText, ... //TODO: urgency, expireTimeoutText, ...
required property var notification required property var notification
required property var screen
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, bool dismiss) signal dismissed(var notification, bool dismiss)
implicitWidth: iconColumn.width+contentColumn.width+2*Config.spacing implicitWidth: Math.min(iconColumn.width+contentColumn.width+2*Config.spacing, screen.width/5)
implicitHeight: Math.max(iconColumn.height, contentColumn.height)+Config.spacing+Config.spacing 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)
@@ -28,6 +29,65 @@ Rectangle {
onClicked: { onClicked: {
dismissed(root.notification, true) dismissed(root.notification, true)
} }
// Row {
// spacing: 10
// Rectangle {
// width: 80
// height: 80
// border.width: 2
// color: "transparent"
// Image {
// anchors.centerIn: parent
// width: 64
// height: 64
// source: "image://icon/org.mozilla.Thunderbird"
// fillMode: Image.PreserveAspectFit
// }
// Component.onCompleted: {
// print("Signal:", Quickshell.iconPath("signal-desktop"))
// print("Thunderbird:", Quickshell.iconPath("org.mozilla.Thunderbird"))
// print("Signal exists:",
// Quickshell.hasThemeIcon("signal-desktop"))
// print("Thunderbird exists:",
// Quickshell.hasThemeIcon("org.mozilla.Thunderbird"))
// }
// }
// Rectangle {
// width: 80
// height: 80
// border.width: 2
// color: "transparent"
// Image {
// anchors.centerIn: parent
// width: 64
// height: 64
// source: Quickshell.iconPath("org.mozilla.Thunderbird")
// fillMode: Image.PreserveAspectFit
// }
// }
// Rectangle {
// width: 80
// height: 80
// border.width: 2
// color: "transparent"
// Image {
// anchors.centerIn: parent
// width: 64
// height: 64
// source: "/usr/share/icons/hicolor/128x128/apps/org.mozilla.Thunderbird.png"
// fillMode: Image.PreserveAspectFit
// }
// }
// }
Row { Row {
id: contentRow id: contentRow
@@ -39,16 +99,17 @@ Rectangle {
Column { Column {
id: iconColumn id: iconColumn
height: Math.max(iconImage.height+summaryText.height+3*Config.spacing, contentColumn.height)+Config.spacing height: Math.max(iconImage.height+summaryText.height+3*Config.spacing, contentColumn.height)+Config.spacing
width: Math.max(128, summaryText.implicitWidth) + Config.spacing width: iconImage.width
spacing: Config.spacing spacing: Config.spacing
Image { Image {
id: iconImage id: iconImage
width: 128 width: screen.width/22
height: 128 height: iconImage.width
source: (notification.appIcon != "" ? Quickshell.iconPath(notification.appIcon) : notification.image)
source: Quickshell.iconPath(root.notification?.appIcon ?? "")
fillMode: Image.PreserveAspectFit fillMode: Image.PreserveAspectFit
asynchronous: true asynchronous: true
} }
@@ -57,6 +118,7 @@ Rectangle {
id: summaryText id: summaryText
Layout.fillWidth: true Layout.fillWidth: true
width: iconImage.width
text: root.notification?.summary ?? "" text: root.notification?.summary ?? ""
font.family: Config.font font.family: Config.font
@@ -71,7 +133,7 @@ Rectangle {
// Right side: notification information // Right side: notification information
Column { Column {
id: contentColumn id: contentColumn
width: bodyText.width + Config.spacing width: Math.max(bodyText.width + Config.spacing, iconColumn.width)
spacing: Config.spacing spacing: Config.spacing
Text { Text {
@@ -228,11 +290,30 @@ Rectangle {
} }
Component.onCompleted: { Component.onCompleted: {
console.log( if(Config.debug == "Notification"){
"[NotificationBody]:", console.log("\x1b[31m[NotificationBody]:"+"\x1b[0m")
notification, console.log("\x1b[31m\t"+"inlineReplyPlaceholder: " + notification.inlineReplyPlaceholder +"\x1b[0m")
"notification:", console.log("\x1b[31m\t"+"body: " + notification.body+"\x1b[0m")
notification.appName console.log("\x1b[31m\t"+"lastGeneration: " + notification.lastGeneration+"\x1b[0m")
) console.log("\x1b[31m\t"+"appName: " + notification.appName+"\x1b[0m")
console.log("\x1b[31m\t"+"image: " + notification.image+"\x1b[0m")
console.log("\x1b[31m\t"+"expireTimeout: " + notification.expireTimeout+"\x1b[0m")
console.log("\x1b[31m\t"+"resident: " + notification.resident+"\x1b[0m")
console.log("\x1b[31m\t"+"id: " + notification.id+"\x1b[0m")
console.log("\x1b[31m\t"+"actions: " + notification.actions+"\x1b[0m")
console.log("\x1b[31m\t"+"urgency: " + notification.urgency+"\x1b[0m")
console.log("\x1b[31m\t"+"appIcon: " + notification.appIcon + " | " + Quickshell.iconPath(notification.appIcon)+"\x1b[0m")
console.log("\x1b[31m\t"+"desktopEntry: " + notification.desktopEntry+"\x1b[0m")
console.log("\x1b[31m\t"+"hints: " + notification.hints+"\x1b[0m")
for (const item of Object.keys(notification.hints)) {
console.log("\x1b[31m\t"+"hints-"+ item +": " + notification.hints[item]+"\x1b[0m")
}
console.log("\x1b[31m\t"+"summary: " + notification.summary+"\x1b[0m")
console.log("\x1b[31m\t"+"transient: " + notification.transient+"\x1b[0m")
console.log("\x1b[31m\t"+"hasInlineReply: " + notification.hasInlineReply+"\x1b[0m")
console.log("\x1b[31m\t"+"hasActionIcons: " + notification.hasActionIcons+"\x1b[0m")
console.log("\x1b[31m\t"+"image.source: " + iconImage.source+"\x1b[0m")
}
} }
} }
+8
View File
@@ -40,4 +40,12 @@ ShellRoot {
function openWlogout() { function openWlogout() {
wlLoader.openWlogout() wlLoader.openWlogout()
} }
GlobalShortcut {
name: "QsReload"
onPressed: {
Quickshell.reload(false)
}
}
} }