feat: add notification module with functionality to display notifications on focused monitor with a NotificationServer as Singleton
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Services.Notifications
|
||||
import "../../config"
|
||||
import "./notificationServer"
|
||||
|
||||
PanelWindow {
|
||||
mask: Region {}
|
||||
|
||||
id: notificationWindow
|
||||
|
||||
anchors.top: true
|
||||
anchors.left: true
|
||||
|
||||
implicitHeight: screen.height/6
|
||||
implicitWidth: screen.width/6
|
||||
|
||||
color: "transparent"
|
||||
|
||||
Connections {
|
||||
target: NotificationS
|
||||
|
||||
function onNotificationReceived(notification) {
|
||||
if (!NotificationS.correctMonitor(screen))
|
||||
return
|
||||
if (NotificationS.correctMonitor(screen)) {
|
||||
console.log("[Notification]: This notification belongs to me!", screen.x, screen.y)
|
||||
// currentNotifications.push(notification)
|
||||
// currentNotifications = currentNotifications
|
||||
currentNotification = notification
|
||||
currentNotifications = currentNotifications.concat([notification])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
property var currentNotification: null
|
||||
property var currentNotifications: []
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
|
||||
border.width: Config.border_width
|
||||
border.color: Colors.primary
|
||||
color: "transparent"
|
||||
|
||||
Column {
|
||||
anchors.fill: parent
|
||||
anchors.margins: 10
|
||||
spacing: 5
|
||||
|
||||
Repeater {
|
||||
model: currentNotifications
|
||||
|
||||
delegate: NotificationBody {
|
||||
required property int index
|
||||
|
||||
notification: currentNotifications[index]
|
||||
width: notificationWindow.width
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Component.onCompleted: {
|
||||
console.log(
|
||||
"[Notification]:",
|
||||
NotificationS,
|
||||
"notification:",
|
||||
NotificationS.newestNotification
|
||||
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user