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;
}
property string debug: "Notification"
}
+8 -15
View File
@@ -1,5 +1,6 @@
import QtQuick
import Quickshell
import Quickshell.Hyprland
import Quickshell.Services.Notifications
import "../../config"
import "./notificationServer"
@@ -30,7 +31,7 @@ PanelWindow {
if (!NotificationS.correctMonitor(screen))
return
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})
}
}
@@ -55,15 +56,17 @@ PanelWindow {
delegate: NotificationBody {
required property int index
required property var notificationData
screen: notificationWindow.screen
notification: notificationData
onDismissed: function(notification, dismiss) {
notificationListModel.remove(index)
if (dismiss) {
notification.dismiss()
}
console.log("[Notification]: Dismissed Notification:", notification.appName, notification.id, notification.summary, notification.body)
// if (dismiss) {
// notification.dismiss()
// console.log("[NotificationWindow " + Hyprland.monitorFor(screen).activeWorkspace.id + "]: Dissmiss: " + notification.appName + " " + notification.id + " - " + notification.summary)
// }
console.log("[NotificationWindow " + Hyprland.monitorFor(screen).activeWorkspace.id + "]: Close: " + notification.appName + " " + notification.id + " - " + notification.summary)
}
}
onItemAdded: updateContentSize()
@@ -92,14 +95,4 @@ PanelWindow {
contentHeight = height
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, ...
required property var notification
required property var screen
property real duration: 5000 // Expected in milliseconds (e.g., 5000 for 5s)
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
color: Qt.alpha(Colors.primaryContainer, 0.75)
@@ -28,6 +29,65 @@ Rectangle {
onClicked: {
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 {
id: contentRow
@@ -39,16 +99,17 @@ Rectangle {
Column {
id: iconColumn
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
Image {
id: iconImage
width: 128
height: 128
width: screen.width/22
height: iconImage.width
source: (notification.appIcon != "" ? Quickshell.iconPath(notification.appIcon) : notification.image)
source: Quickshell.iconPath(root.notification?.appIcon ?? "")
fillMode: Image.PreserveAspectFit
asynchronous: true
}
@@ -57,6 +118,7 @@ Rectangle {
id: summaryText
Layout.fillWidth: true
width: iconImage.width
text: root.notification?.summary ?? ""
font.family: Config.font
@@ -71,7 +133,7 @@ Rectangle {
// Right side: notification information
Column {
id: contentColumn
width: bodyText.width + Config.spacing
width: Math.max(bodyText.width + Config.spacing, iconColumn.width)
spacing: Config.spacing
Text {
@@ -228,11 +290,30 @@ Rectangle {
}
Component.onCompleted: {
console.log(
"[NotificationBody]:",
notification,
"notification:",
notification.appName
)
if(Config.debug == "Notification"){
console.log("\x1b[31m[NotificationBody]:"+"\x1b[0m")
console.log("\x1b[31m\t"+"inlineReplyPlaceholder: " + notification.inlineReplyPlaceholder +"\x1b[0m")
console.log("\x1b[31m\t"+"body: " + notification.body+"\x1b[0m")
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() {
wlLoader.openWlogout()
}
GlobalShortcut {
name: "QsReload"
onPressed: {
Quickshell.reload(false)
}
}
}