quickshell/modules/notifications/NotificationCard.qml

95 lines
2.7 KiB
QML
Raw Normal View History

2026-03-11 14:23:10 +01:00
import QtQuick
import qs.settings
import QtQuick.Layouts
import qs
2026-03-19 11:32:23 +01:00
import Quickshell
2026-03-11 14:23:10 +01:00
import qs.widgets
import Quickshell.Widgets
Rectangle {
id: notifyItem
required property var modelData
2026-03-25 21:08:36 +01:00
implicitWidth: ListView.view ? ListView.view.width : 500
2026-03-19 11:32:23 +01:00
implicitHeight: fullLayout.implicitHeight + 40
color: dismissArea.containsMouse ? Colors.base02 : Colors.base00
2026-03-11 14:23:10 +01:00
radius: Settings.config.rounding
2026-03-20 10:34:10 +01:00
border.width: 2
2026-03-19 11:32:23 +01:00
border.color: Colors.base0D
2026-03-11 14:23:10 +01:00
Timer {
id: dismissTimer
interval: 5000
running: true
2026-03-25 21:08:36 +01:00
onTriggered: notifyItem.modelData.expire()
2026-03-11 14:23:10 +01:00
}
RowLayout {
id: fullLayout
2026-03-20 10:34:10 +01:00
anchors.margins: 20
2026-03-11 14:23:10 +01:00
anchors.fill: parent
2026-03-20 10:34:10 +01:00
anchors.centerIn: parent
2026-03-11 14:23:10 +01:00
spacing: 10
ClippingWrapperRectangle {
2026-03-25 21:08:36 +01:00
id: notiIconWrapper
Layout.alignment: Qt.AlignTop
2026-03-11 14:23:10 +01:00
radius: notifyItem.radius - notifyItem.radius / 3
2026-03-25 21:08:36 +01:00
implicitWidth: notiIcon.implicitSize
2026-03-11 14:23:10 +01:00
color: "transparent"
2026-03-25 21:08:36 +01:00
implicitHeight: notiIcon.implicitSize
visible: notifyItem.modelData.image !== ""
2026-03-11 14:23:10 +01:00
IconImage {
2026-03-25 21:08:36 +01:00
id: notiIcon
source: notifyItem.modelData.image !== "" ? notifyItem.modelData.image : Quickshell.iconPath("preferences-desktop-notification-bell")
2026-03-11 14:23:10 +01:00
implicitSize: 64
asynchronous: true
}
}
ColumnLayout {
id: textLayout
Layout.fillWidth: true
Layout.alignment: Qt.AlignTop
2026-03-25 21:08:36 +01:00
spacing: 0
2026-03-11 14:23:10 +01:00
2026-03-25 21:08:36 +01:00
CText {
id: appName
text: notifyItem.modelData.appName
opacity: 0.5
font.pixelSize: 10
}
2026-03-11 14:23:10 +01:00
CText {
id: summary
text: notifyItem.modelData.summary
font.bold: true
elide: Text.ElideRight
Layout.fillWidth: true
2026-03-25 21:08:36 +01:00
Layout.bottomMargin: 0
Layout.topMargin: 5
maximumLineCount: 1
2026-03-11 14:23:10 +01:00
onTextChanged: {
dismissTimer.restart();
}
}
CText {
text: notifyItem.modelData.body
font.pixelSize: Settings.config.fontSize - 2
2026-03-25 21:08:36 +01:00
maximumLineCount: 1
opacity: 0.3
2026-03-11 14:23:10 +01:00
wrapMode: Text.WordWrap
elide: Text.ElideRight
Layout.fillWidth: true
}
}
}
MouseArea {
id: dismissArea
anchors.fill: parent
acceptedButtons: Qt.LeftButton
onClicked: notifyItem.modelData.dismiss()
cursorShape: Qt.PointingHandCursor
hoverEnabled: true
}
}