import QtQuick import Quickshell import Quickshell.Hyprland import Quickshell.Services.Notifications import "../../config" import "./notificationServer" PanelWindow { // mask: Region {} id: notificationWindow focusable: true anchors.top: true anchors.left: true // implicitHeight: screen.height/6 implicitHeight: contentHeight+(content.spacing*(notificationListModel.count-1)) implicitWidth: contentWidth color: "transparent" ListModel { id: notificationListModel } Connections { target: NotificationS function onNotificationReceived(notification) { if (!NotificationS.correctMonitor(screen)) return if (NotificationS.correctMonitor(screen)) { Config.debug == "Notification" && console.log("[NotificationWindow " + Hyprland.monitorFor(screen).activeWorkspace.id + "]: This notification belongs to me! ") notificationListModel.append({notificationData: notification}) } } } Rectangle { anchors.fill: parent border.width: Config.border_width border.color: Colors.primary color: "transparent" Column { id: content anchors.fill: parent spacing: -2 Repeater { id: notificationRepeater model: notificationListModel delegate: NotificationBody { required property int index required property var notificationData screen: notificationWindow.screen notification: notificationData onDismissed: function(notification, dismiss) { const appName = notification.appName const id = notification.id const summary = notification.summary if (dismiss) { Config.debug == "Notification" && console.log("[NotificationWindow " + Hyprland.monitorFor(screen).activeWorkspace.id + "]: Dissmiss: " + appName + " " + id + " - " + summary) notification.dismiss() notificationListModel.remove(index) } else { Config.debug == "Notification" && console.log("[NotificationWindow " + Hyprland.monitorFor(screen).activeWorkspace.id + "]: Close: " + appName + " " + id + " - " + summary) notificationListModel.remove(index) } } } onItemAdded: updateContentSize() onItemRemoved: updateContentSize() } } } property real contentWidth: 0 property real contentHeight: 0 function updateContentSize() { let width = 0 let height = 0 for (let i = 0; i < notificationRepeater.count; ++i) { let item = notificationRepeater.itemAt(i) if (item) { width = Math.max(width, item.width) height += item.height } } contentWidth = width contentHeight = height Config.debug == "Notification" && console.log("[updateContentSize] contentWidth:", contentWidth, "contentHeight:", contentHeight) } }