From a2966f51abbcfd8959349aa8f64104713c18ea25 Mon Sep 17 00:00:00 2001 From: Damocles Date: Fri, 17 Apr 2026 11:14:03 +0200 Subject: [PATCH] fire default action on notification text click --- modules/NotifCard.qml | 157 ++++++++++++++++++++++++------------------ 1 file changed, 91 insertions(+), 66 deletions(-) diff --git a/modules/NotifCard.qml b/modules/NotifCard.qml index 27797c8..eb77208 100644 --- a/modules/NotifCard.qml +++ b/modules/NotifCard.qml @@ -125,79 +125,104 @@ Item { anchors.topMargin: 8 spacing: 2 - // App name + time row (optional) - Row { - visible: root.showAppName + // Text section — tappable for default action + Item { + id: _textSection width: parent.width + height: _textCol.implicitHeight + implicitHeight: _textCol.implicitHeight - Text { - text: root.notif?.appName ?? "Notification" - color: M.Theme.base04 - font.pixelSize: M.Theme.fontSize - 2 - font.family: M.Theme.fontFamily - width: parent.width - _timeText.implicitWidth - 4 - elide: Text.ElideRight + TapHandler { + cursorShape: root.notif?.actions?.some(a => a.identifier === "default") ? Qt.PointingHandCursor : undefined + onTapped: { + const def = root.notif?.actions?.find(a => a.identifier === "default"); + if (def) { + def.invoke(); + root.dismissRequested(); + } + } } - Text { - id: _timeText - text: root.notif?.timeStr ?? "" - color: M.Theme.base03 - font.pixelSize: M.Theme.fontSize - 2 - font.family: M.Theme.fontFamily + Column { + id: _textCol + width: parent.width + spacing: 2 + + // App name + time row (optional) + Row { + visible: root.showAppName + width: parent.width + + Text { + text: root.notif?.appName ?? "Notification" + color: M.Theme.base04 + font.pixelSize: M.Theme.fontSize - 2 + font.family: M.Theme.fontFamily + width: parent.width - _timeText.implicitWidth - 4 + elide: Text.ElideRight + } + + Text { + id: _timeText + text: root.notif?.timeStr ?? "" + color: M.Theme.base03 + font.pixelSize: M.Theme.fontSize - 2 + font.family: M.Theme.fontFamily + } + } + + // Summary (with inline time when app name row is hidden) + Row { + visible: !root.showAppName + width: parent.width + + Text { + text: root.notif?.summary ?? "" + color: M.Theme.base05 + font.pixelSize: M.Theme.fontSize + font.family: M.Theme.fontFamily + font.bold: true + elide: Text.ElideRight + width: parent.width - _inlineTime.implicitWidth - 4 + } + + Text { + id: _inlineTime + text: root.notif?.timeStr ?? "" + color: M.Theme.base03 + font.pixelSize: M.Theme.fontSize - 2 + font.family: M.Theme.fontFamily + anchors.verticalCenter: parent.verticalCenter + } + } + + Text { + visible: root.showAppName + width: parent.width + text: root.notif?.summary ?? "" + color: M.Theme.base05 + font.pixelSize: M.Theme.fontSize + font.family: M.Theme.fontFamily + font.bold: true + elide: Text.ElideRight + wrapMode: Text.WordWrap + maximumLineCount: 2 + } + + Text { + width: parent.width + text: root.notif?.body ?? "" + color: M.Theme.base04 + font.pixelSize: M.Theme.fontSize - 1 + font.family: M.Theme.fontFamily + elide: Text.ElideRight + wrapMode: Text.WordWrap + maximumLineCount: root.bodyMaxLines + visible: text !== "" + } } } - // Summary (with inline time when app name row is hidden) - Row { - visible: !root.showAppName - width: parent.width - - Text { - text: root.notif?.summary ?? "" - color: M.Theme.base05 - font.pixelSize: M.Theme.fontSize - font.family: M.Theme.fontFamily - font.bold: true - elide: Text.ElideRight - width: parent.width - _inlineTime.implicitWidth - 4 - } - - Text { - id: _inlineTime - text: root.notif?.timeStr ?? "" - color: M.Theme.base03 - font.pixelSize: M.Theme.fontSize - 2 - font.family: M.Theme.fontFamily - anchors.verticalCenter: parent.verticalCenter - } - } - - Text { - visible: root.showAppName - width: parent.width - text: root.notif?.summary ?? "" - color: M.Theme.base05 - font.pixelSize: M.Theme.fontSize - font.family: M.Theme.fontFamily - font.bold: true - elide: Text.ElideRight - wrapMode: Text.WordWrap - maximumLineCount: 2 - } - - Text { - width: parent.width - text: root.notif?.body ?? "" - color: M.Theme.base04 - font.pixelSize: M.Theme.fontSize - 1 - font.family: M.Theme.fontFamily - elide: Text.ElideRight - wrapMode: Text.WordWrap - maximumLineCount: root.bodyMaxLines - visible: text !== "" - } - // Action buttons — filter "default" (click-notification convention) and empty labels Row { spacing: 6