138 lines
3.5 KiB
QML
138 lines
3.5 KiB
QML
import Quickshell
|
|
import QtQuick
|
|
import QtQuick.Layouts
|
|
import Quickshell.Widgets
|
|
|
|
Rectangle {
|
|
id: notificationWrapper
|
|
|
|
signal dismissed
|
|
|
|
property bool hasImage: notification?.image ? true : false
|
|
property var notification: null
|
|
|
|
property string image: {
|
|
if (hasImage) {
|
|
return notification.image;
|
|
}
|
|
if (notification?.appIcon === "") {
|
|
return "";
|
|
}
|
|
return Quickshell.iconPath(notification?.appIcon);
|
|
}
|
|
|
|
implicitWidth: 400
|
|
implicitHeight: notifLayout.implicitHeight
|
|
topLeftRadius: image ? 100 : 20
|
|
bottomLeftRadius: image ? 100 : 20
|
|
topRightRadius: 20
|
|
bottomRightRadius: 20
|
|
color: "#80000000"
|
|
|
|
MouseArea {
|
|
anchors.fill: parent
|
|
onClicked: {
|
|
notificationWrapper.dismissed();
|
|
}
|
|
}
|
|
|
|
RowLayout {
|
|
id: notifLayout
|
|
|
|
anchors {
|
|
fill: parent
|
|
}
|
|
|
|
ClippingRectangle {
|
|
|
|
Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
|
|
|
|
implicitWidth: 100
|
|
implicitHeight: 100
|
|
visible: notificationWrapper.image ? true : false
|
|
|
|
color: "grey"
|
|
|
|
radius: 100
|
|
|
|
IconImage {
|
|
anchors.centerIn: parent
|
|
implicitSize: 100
|
|
source: notificationWrapper.image
|
|
}
|
|
}
|
|
|
|
ColumnLayout {
|
|
|
|
Layout.leftMargin: 10
|
|
Layout.rightMargin: 10
|
|
|
|
Rectangle {
|
|
Layout.fillWidth: true
|
|
|
|
implicitHeight: summaryText.implicitHeight + 10
|
|
radius: 20
|
|
color: "#50ffffff"
|
|
|
|
Rectangle {
|
|
anchors {
|
|
left: parent.left
|
|
top: parent.top
|
|
bottom: parent.bottom
|
|
}
|
|
|
|
implicitWidth: parent.width
|
|
radius: parent.radius
|
|
color: "white"
|
|
|
|
Text {
|
|
id: summaryText
|
|
|
|
anchors.fill: parent
|
|
horizontalAlignment: Text.AlignHCenter
|
|
verticalAlignment: Text.AlignVCenter
|
|
font.pixelSize: 12
|
|
wrapMode: Text.WordWrap
|
|
textFormat: Text.MarkdownText
|
|
|
|
text: notificationWrapper.notification.summary
|
|
}
|
|
}
|
|
}
|
|
|
|
Rectangle {
|
|
Layout.fillWidth: true
|
|
|
|
implicitHeight: bodyText.implicitHeight + 10
|
|
radius: 20
|
|
|
|
Rectangle {
|
|
anchors {
|
|
left: parent.left
|
|
top: parent.top
|
|
bottom: parent.bottom
|
|
}
|
|
|
|
implicitWidth: parent.width
|
|
radius: parent.radius
|
|
color: "white"
|
|
|
|
Text {
|
|
id: bodyText
|
|
|
|
anchors.fill: parent
|
|
horizontalAlignment: Text.AlignHCenter
|
|
verticalAlignment: Text.AlignVCenter
|
|
font.pixelSize: 14
|
|
wrapMode: Text.WordWrap
|
|
textFormat: Text.MarkdownText
|
|
|
|
text: notificationWrapper.notification.body
|
|
onLinkActivated: link => Qt.openUrlExternally(link)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|