Files
2026-07-17 20:03:04 +00:00

155 lines
4.2 KiB
QML

import QtQuick
import Quickshell
import Quickshell.Services.Notifications
import "../../config"
Rectangle {
id: card
required property var notification
required property var manager
width: parent.width
height: Math.max(64, cardContent.height + 24)
radius: Config.radius
property var urgency: notification.urgency
property bool isCritical: urgency === NotificationUrgency.Critical
color: {
if (isCritical) return Qt.alpha(Colors.errorContainer, 0.95)
if (urgency === NotificationUrgency.Low) return Qt.alpha(Colors.surfaceContainerHigh, 0.95)
return Qt.alpha(Colors.primaryContainer, 0.95)
}
border {
width: Config.border_width
color: {
if (isCritical) return Colors.error
if (urgency === NotificationUrgency.Low) return Colors.outline
return Colors.primaryContainer_fg
}
}
NumberAnimation on opacity {
id: fadeInAnim
from: 0
to: 1
duration: 200
easing.type: Easing.OutCubic
}
NumberAnimation on x {
id: slideInAnim
from: parent ? parent.width : 100
to: 0
duration: 300
easing.type: Easing.OutCubic
}
Component.onCompleted: {
fadeInAnim.start()
slideInAnim.start()
}
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
acceptedButtons: Qt.LeftButton
onClicked: {
manager.dismissNotification(notification)
}
}
Row {
id: cardContent
anchors {
top: parent.top
left: parent.left
right: parent.right
margins: 12
}
spacing: 10
Item {
id: iconContainer
width: 28
height: 28
anchors.verticalCenter: parent.verticalCenter
Image {
id: notifIcon
anchors.fill: parent
source: notification.appIcon ? "file://" + notification.appIcon : ""
sourceSize.width: 28
sourceSize.height: 28
asynchronous: true
visible: status === Image.Ready
}
Text {
anchors.centerIn: parent
text: "\uF0F3"
font.pixelSize: 16
font.family: Config.font
visible: !notifIcon.visible
color: Colors.primary_fg
}
}
Column {
id: textColumn
width: parent.width - iconContainer.width - parent.spacing - 20
spacing: 3
anchors.verticalCenter: parent.verticalCenter
Text {
id: summaryText
width: parent.width
text: notification.summary || notification.appName || "Notification"
font.pixelSize: 13
font.bold: true
font.family: Config.font
color: {
if (isCritical) return Colors.error
if (urgency === NotificationUrgency.Low) return Colors.secondaryContainer_fg
return Colors.primary
}
elide: Text.ElideRight
maximumLineCount: 1
}
Text {
id: bodyText
width: parent.width
text: notification.body || ""
visible: text !== ""
wrapMode: Text.WordWrap
font.pixelSize: 11
font.family: Config.font
color: isCritical ? Colors.errorContainer_fg : Colors.surface_fg
maximumLineCount: 2
elide: Text.ElideRight
}
}
Text {
text: "\u00D7"
font.pixelSize: 16
font.bold: true
color: isCritical ? Colors.error : Colors.secondary
anchors.verticalCenter: parent.verticalCenter
opacity: 0.6
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
hoverEnabled: true
onClicked: {
manager.dismissNotification(notification)
}
}
}
}
}