This repository has been archived on 2026-11-02. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
dotfiles/mutable_config/quickshell/components/NotificationDaemon.qml
T
2026-08-23 20:20:02 +02:00

128 lines
3.6 KiB
QML

import Quickshell
import Quickshell.Services.Notifications
import QtQuick
import QtQuick.Layouts
import "../core"
PanelWindow {
id: notifWindow
// Anchor to top right, just below the bar
anchors {
top: true
right: true
}
// Offset slightly from the screen edges
margins {
top: 40 // height of top bar (32) + 8 padding
right: 8
}
// Dynamic height based on notifications
implicitWidth: 320
implicitHeight: notifList.contentHeight
color: "transparent"
// Make invisible if no notifications
visible: notificationServer.trackedNotifications.values.length > 0
NotificationServer {
id: notificationServer
bodySupported: true
actionsSupported: false
inlineReplySupported: false
imageSupported: true
actionIconsSupported: false
persistenceSupported: false
onNotification: function(notification) {
notification.tracked = true;
}
}
ListView {
id: notifList
anchors.fill: parent
spacing: 8
model: notificationServer.trackedNotifications.values
clip: false // Allow shadows or animations outside
delegate: Rectangle {
id: delegateRect
width: notifWindow.width
height: layout.height + Theme.padding * 2
color: Theme.bg
radius: Theme.radius
border.color: Theme.bgAlt
border.width: 1
property var notif: modelData
ColumnLayout {
id: layout
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.margins: Theme.padding
spacing: 4
RowLayout {
Layout.fillWidth: true
Text {
text: notif.appName || "Notification"
color: Theme.primary
font: Theme.fontBold
Layout.fillWidth: true
}
Text {
text: "✕"
color: Theme.fgAlt
font: Theme.fontBold
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onClicked: notif.dismiss()
}
}
}
Text {
text: notif.summary || ""
color: Theme.fg
font: Theme.fontBold
Layout.fillWidth: true
wrapMode: Text.Wrap
}
Text {
text: notif.body || ""
color: Theme.fgAlt
font: Theme.font
Layout.fillWidth: true
wrapMode: Text.Wrap
maximumLineCount: 4
elide: Text.ElideRight
visible: text.length > 0
}
}
Timer {
id: expireTimer
interval: notif.expireTimeout > 0 ? (notif.expireTimeout) : 5000
running: true
onTriggered: notif.expire()
}
MouseArea {
anchors.fill: parent
// Don't swallow clicks for the close button
z: -1
onClicked: notif.dismiss()
}
}
}
}