Files
quickdots/notifications/HistoryCard.qml
2026-04-24 02:14:35 +00:00

84 lines
3.4 KiB
QML

import QtQuick
import QtQuick.Layouts
Rectangle {
id: root
property int itemIndex: 0
property string appName: ""
property string summary: ""
property string body: ""
property int urgency: 0
property string timeStr: ""
property var t
property var urgencyColor: function(u) { return "#ffffff" }
property var urgencyIcon: function(u) { return "" }
signal dismissed(int itemIndex)
height: histItemContent.implicitHeight + 24
radius: 12
clip: true
color: histItemHover.hovered ? root.t.notifHistoryHover : "transparent"
Behavior on color { ColorAnimation { duration: 150; easing.type: Easing.OutCubic } }
HoverHandler { id: histItemHover }
SequentialAnimation {
id: dismissAnim
ParallelAnimation {
NumberAnimation { target: root; property: "opacity"; to: 0; duration: 150; easing.type: Easing.OutCubic }
NumberAnimation { target: root; property: "scale"; to: 0.95; duration: 150; easing.type: Easing.OutCubic }
}
NumberAnimation { target: root; property: "height"; to: 0; duration: 150; easing.type: Easing.InOutQuad }
ScriptAction { script: root.dismissed(root.itemIndex) }
}
Rectangle {
width: 3
height: Math.max(12, root.height - 24)
radius: 1.5
anchors { left: parent.left; leftMargin: 10; verticalCenter: parent.verticalCenter }
color: root.urgencyColor(root.urgency)
}
Rectangle {
anchors { right: parent.right; top: parent.top; margins: 8 }
width: 22; height: 22; radius: 11
color: histCloseHover.hovered ? root.t.notifHistoryHover : "transparent"
opacity: histItemHover.hovered ? 1 : 0
Behavior on opacity { NumberAnimation { duration: 150 } }
Behavior on color { ColorAnimation { duration: 150 } }
Text { anchors.centerIn: parent; text: "✕"; color: root.t.notifToastText; font.pixelSize: 10 }
HoverHandler { id: histCloseHover; cursorShape: Qt.PointingHandCursor }
TapHandler { onTapped: dismissAnim.start() }
}
ColumnLayout {
id: histItemContent
anchors { left: parent.left; right: parent.right; top: parent.top; leftMargin: 24; rightMargin: 36; topMargin: 12 }
spacing: 4
RowLayout {
Layout.fillWidth: true; spacing: 5
Text { text: root.urgencyIcon(root.urgency); color: root.urgencyColor(root.urgency); font.pixelSize: 11; Layout.alignment: Qt.AlignVCenter }
Text {
text: root.appName; color: root.t.notifToastAppName; font.pixelSize: 11; font.bold: true;
font.capitalization: Font.AllUppercase; Layout.fillWidth: true; elide: Text.ElideRight; verticalAlignment: Text.AlignVCenter
}
Text { text: root.timeStr; color: root.t.notifToastDim; font.pixelSize: 11; verticalAlignment: Text.AlignVCenter }
}
Text {
text: root.summary; color: root.t.notifToastText; font.pixelSize: 13; font.bold: true;
Layout.fillWidth: true; elide: Text.ElideRight; textFormat: Text.PlainText; visible: root.summary !== ""
}
Text {
text: root.body; color: root.t.notifToastDim; font.pixelSize: 12; Layout.fillWidth: true;
wrapMode: Text.WordWrap; maximumLineCount: 2; elide: Text.ElideRight; textFormat: Text.PlainText; visible: root.body !== ""; lineHeight: 1.15
}
}
}