feat: add notification sound and notification window enhancements. Ready for alpha.NotificationBody needs work

This commit is contained in:
Hannes
2026-08-26 00:38:20 +02:00
parent 0b20e8eb85
commit 3cd6807681
7 changed files with 193 additions and 88 deletions
+77 -50
View File
@@ -6,7 +6,84 @@ Rectangle {
id: root
required property var notification
property real duration: 5000 // Expected in milliseconds (e.g., 5000 for 5s)
signal dismissed(var notification)
implicitWidth: content.implicitWidth + 2*18
implicitHeight: content.implicitHeight + 18 + progressBar.height
color: Qt.alpha(Colors.primaryContainer, 0.75)
border.width: Config.border_width
border.color: Colors.primary
MouseArea {
id: mouseArea
anchors.fill: parent
hoverEnabled: true
onClicked: {
dismissed(root.notification)
}
Column {
id: content
anchors.fill: parent
anchors.margins: 10
spacing: 5
Text {
id: appNameText
text: root.notification?.id + ": " + (root.notification?.appName ?? "")
font.family: Config.font
font.pixelSize: 18
color: Colors.primary
elide: Text.ElideRight
}
Text {
id: summaryText
text: root.notification?.summary ?? ""
font.family: Config.font
font.pixelSize: 22
color: Colors.primary
wrapMode: Text.Wrap
}
Text {
id: bodyText
text: root.notification?.body ?? ""
font.family: Config.font
font.pixelSize: 16
color: Colors.primary
wrapMode: Text.Wrap
}
}
}
// Timeout progress bar
Rectangle {
id: progressBar
anchors.bottom: parent.bottom
anchors.left: parent.left
height: 10
color: Colors.primary
property real progress: 1.0
width: root.width * progress
NumberAnimation on progress {
id: anim
running: root.duration > 0
from: 1.0
to: 0.0
// If your duration property comes in seconds (e.g., 5), change to: (root.duration * 1000)
duration: root.duration
paused: mouseArea.containsMouse
onFinished: root.dismissed(root.notification)
}
}
Component.onCompleted: {
console.log(
@@ -16,54 +93,4 @@ Rectangle {
notification.appName
)
}
implicitWidth: parent ? parent.width : 300
implicitHeight: content.implicitHeight + 20
color: "transparent"
border.width: Config.border_width
border.color: Colors.primary
Column {
id: content
anchors.fill: parent
anchors.margins: 10
spacing: 5
Text {
width: parent.width
text: root.notification?.appName ?? ""
font.family: Config.font
font.pixelSize: 18
color: Colors.primary
elide: Text.ElideRight
}
Text {
width: parent.width
text: root.notification?.summary ?? ""
font.family: Config.font
font.pixelSize: 22
color: Colors.primary
wrapMode: Text.Wrap
}
Text {
width: parent.width
text: root.notification?.body ?? ""
font.family: Config.font
font.pixelSize: 16
color: Colors.primary
wrapMode: Text.Wrap
}
}
}