aboutsummaryrefslogtreecommitdiffstats
path: root/desktop/NotificationRow.qml
diff options
context:
space:
mode:
Diffstat (limited to 'desktop/NotificationRow.qml')
-rw-r--r--desktop/NotificationRow.qml89
1 files changed, 89 insertions, 0 deletions
diff --git a/desktop/NotificationRow.qml b/desktop/NotificationRow.qml
new file mode 100644
index 0000000..f95f3b4
--- /dev/null
+++ b/desktop/NotificationRow.qml
@@ -0,0 +1,89 @@
+// Copyright (C) 2026 Danilo M. <danix@danix.xyz>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2 as
+// published by the Free Software Foundation.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+import QtQuick
+
+// One notification in the drawer: app, summary and body. Live rows close with
+// the X and click through to their actions; a history row is inert.
+Item {
+ id: row
+
+ required property var notification
+ // A history row has no live client: no X, and a click does nothing.
+ property bool live: true
+
+ readonly property bool inert: row.notification.expires !== 0 && Date.now() >= row.notification.expires
+
+ implicitHeight: texts.implicitHeight + 16
+
+ MouseArea {
+ anchors.fill: parent
+ cursorShape: Qt.PointingHandCursor
+ onClicked: {
+ if (!row.live) return;
+ const acts = row.notification.actions || [];
+ if (acts.length > 0 && !row.inert) Notify.actions(row.notification.id, acts);
+ else Notify.close(row.notification.id);
+ }
+ }
+
+ Column {
+ id: texts
+ anchors {
+ left: parent.left
+ right: closeBtn.visible ? closeBtn.left : parent.right
+ rightMargin: 10
+ verticalCenter: parent.verticalCenter
+ }
+ spacing: 2
+
+ Text {
+ width: parent.width
+ text: (row.notification.app || "") + (row.notification.summary ? " " + row.notification.summary : "")
+ elide: Text.ElideRight
+ font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 3 }
+ color: Theme.text
+ }
+
+ Text {
+ width: parent.width
+ visible: text !== ""
+ text: row.notification.body || ""
+ textFormat: Text.RichText
+ wrapMode: Text.WordWrap
+ maximumLineCount: 2
+ elide: Text.ElideRight
+ font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 5 }
+ color: Theme.subtext
+ }
+ }
+
+ Text {
+ id: closeBtn
+ visible: row.live
+ anchors { right: parent.right; verticalCenter: parent.verticalCenter }
+ width: 20
+ height: 20
+ text: "\uf00d"
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ font { family: Theme.iconFamily; pixelSize: 11 }
+ color: closeArea.containsMouse ? Theme.red : Theme.subtext
+
+ MouseArea {
+ id: closeArea
+ anchors.fill: parent
+ hoverEnabled: true
+ cursorShape: Qt.PointingHandCursor
+ onClicked: Notify.close(row.notification.id)
+ }
+ }
+}