238 lines
7.9 KiB
QML
238 lines
7.9 KiB
QML
import QtQuick
|
|
import Quickshell
|
|
import "../../config"
|
|
import QtQuick.Layouts
|
|
|
|
Rectangle {
|
|
id: root
|
|
|
|
//TODO: urgency, expireTimeoutText, ...
|
|
|
|
required property var notification
|
|
property real duration: 5000 // Expected in milliseconds (e.g., 5000 for 5s)
|
|
|
|
signal dismissed(var notification, bool dismiss)
|
|
|
|
implicitWidth: iconColumn.width+contentColumn.width+2*Config.spacing
|
|
implicitHeight: Math.max(iconColumn.height, contentColumn.height)+Config.spacing+Config.spacing
|
|
|
|
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, true)
|
|
}
|
|
|
|
Row {
|
|
id: contentRow
|
|
anchors.fill: parent
|
|
anchors.margins: 10
|
|
spacing: Config.spacing
|
|
|
|
// Left side: icon + icon information
|
|
Column {
|
|
id: iconColumn
|
|
height: Math.max(iconImage.height+summaryText.height+3*Config.spacing, contentColumn.height)+Config.spacing
|
|
width: Math.max(128, summaryText.implicitWidth) + Config.spacing
|
|
spacing: Config.spacing
|
|
|
|
Image {
|
|
id: iconImage
|
|
|
|
width: 128
|
|
height: 128
|
|
|
|
source: Quickshell.iconPath(root.notification?.appIcon ?? "")
|
|
fillMode: Image.PreserveAspectFit
|
|
asynchronous: true
|
|
}
|
|
|
|
Text {
|
|
id: summaryText
|
|
|
|
Layout.fillWidth: true
|
|
|
|
text: root.notification?.summary ?? ""
|
|
font.family: Config.font
|
|
font.pixelSize: 22
|
|
color: Colors.primary
|
|
|
|
wrapMode: Text.Wrap
|
|
horizontalAlignment: Text.AlignHCenter
|
|
}
|
|
}
|
|
|
|
// Right side: notification information
|
|
Column {
|
|
id: contentColumn
|
|
width: bodyText.width + Config.spacing
|
|
spacing: Config.spacing
|
|
|
|
Text {
|
|
id: bodyText
|
|
text: root.notification?.body ?? ""
|
|
|
|
width: Math.min(implicitWidth, iconColumn.width*2)
|
|
font.family: Config.font
|
|
font.pixelSize: 22
|
|
color: Colors.primary
|
|
wrapMode: Text.Wrap
|
|
}
|
|
|
|
// Text {
|
|
// id: appNameText
|
|
// width: parent.width
|
|
// text: root.notification?.id + ": " +
|
|
// (root.notification?.appName ?? "")
|
|
// font.family: Config.font
|
|
// font.pixelSize: 18
|
|
// color: Colors.primary
|
|
// elide: Text.ElideRight
|
|
// }
|
|
|
|
// Text {
|
|
// id: inlineReplyPlaceholderText
|
|
// width: parent.width
|
|
// text: "inlineReplyPlaceholder: " + (root.notification?.inlineReplyPlaceholder ?? "")
|
|
// font.family: Config.font
|
|
// font.pixelSize: 16
|
|
// color: Colors.primary
|
|
// wrapMode: Text.Wrap
|
|
// }
|
|
|
|
// Text {
|
|
// id: iconPathText
|
|
// width: parent.width
|
|
// text: "iconPath: " + (root.notification?.iconPath ?? "")
|
|
// font.family: Config.font
|
|
// font.pixelSize: 16
|
|
// color: Colors.primary
|
|
// wrapMode: Text.Wrap
|
|
// }
|
|
|
|
// Text {
|
|
// id: expireTimeoutText
|
|
// width: parent.width
|
|
// text: "expireTimeout: " +
|
|
// (root.notification?.expireTimeout ?? "")
|
|
// font.family: Config.font
|
|
// font.pixelSize: 16
|
|
// color: Colors.primary
|
|
// wrapMode: Text.Wrap
|
|
// }
|
|
|
|
// Text {
|
|
// id: residentText
|
|
// width: parent.width
|
|
// text: "resident: " + (root.notification?.resident ?? "")
|
|
// font.family: Config.font
|
|
// font.pixelSize: 16
|
|
// color: Colors.primary
|
|
// wrapMode: Text.Wrap
|
|
// }
|
|
|
|
// Text {
|
|
// id: urgencyText
|
|
// width: parent.width
|
|
// text: "urgency: " + (root.notification?.urgency ?? "")
|
|
// font.family: Config.font
|
|
// font.pixelSize: 16
|
|
// color: Colors.primary
|
|
// wrapMode: Text.Wrap
|
|
// }
|
|
|
|
// Text {
|
|
// id: desktopEntryText
|
|
// width: parent.width
|
|
// text: "desktopEntry: " +
|
|
// (root.notification?.desktopEntry ?? "")
|
|
// font.family: Config.font
|
|
// font.pixelSize: 16
|
|
// color: Colors.primary
|
|
// wrapMode: Text.Wrap
|
|
// }
|
|
|
|
// Text {
|
|
// id: hintsText
|
|
// width: parent.width
|
|
// text: "hints: " + (root.notification?.hints ?? "")
|
|
// font.family: Config.font
|
|
// font.pixelSize: 16
|
|
// color: Colors.primary
|
|
// wrapMode: Text.Wrap
|
|
// }
|
|
|
|
// Text {
|
|
// id: transientText
|
|
// width: parent.width
|
|
// text: "transient: " + (root.notification?.transient ?? "")
|
|
// font.family: Config.font
|
|
// font.pixelSize: 16
|
|
// color: Colors.primary
|
|
// wrapMode: Text.Wrap
|
|
// }
|
|
|
|
// Text {
|
|
// id: hasInlineReplyText
|
|
// width: parent.width
|
|
// text: "hasInlineReply: " +
|
|
// (root.notification?.hasInlineReply ?? "")
|
|
// font.family: Config.font
|
|
// font.pixelSize: 16
|
|
// color: Colors.primary
|
|
// wrapMode: Text.Wrap
|
|
// }
|
|
|
|
// Text {
|
|
// id: hasActionIconsText
|
|
// width: parent.width
|
|
// text: "hasActionIcons: " +
|
|
// (root.notification?.hasActionIcons ?? "")
|
|
// 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: Math.min(10, 0.1 * root.height)
|
|
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, false)
|
|
}
|
|
}
|
|
|
|
Component.onCompleted: {
|
|
console.log(
|
|
"[NotificationBody]:",
|
|
notification,
|
|
"notification:",
|
|
notification.appName
|
|
)
|
|
}
|
|
} |