From bc6d963800670c55675f80957868526ff565a239 Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Sun, 20 Apr 2025 12:14:44 +0200 Subject: [PATCH] notifications: handle body images --- .../common/widgets/NotificationWidget.qml | 28 ++++++++++++++++--- .config/quickshell/services/Notifications.qml | 2 +- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/.config/quickshell/modules/common/widgets/NotificationWidget.qml b/.config/quickshell/modules/common/widgets/NotificationWidget.qml index e22544d2..01c46072 100644 --- a/.config/quickshell/modules/common/widgets/NotificationWidget.qml +++ b/.config/quickshell/modules/common/widgets/NotificationWidget.qml @@ -5,6 +5,7 @@ import QtQuick import QtQuick.Controls import QtQuick.Layouts import Quickshell +import Quickshell.Io import Quickshell.Widgets import Quickshell.Services.Notifications import "./notification_utils.js" as NotificationUtils @@ -20,6 +21,11 @@ Item { Layout.fillWidth: true clip: true + Process { + id: closeSidebarProcess + command: ["bash", "-c", `qs ipc call sidebarRight close`] + } + implicitHeight: ready ? notificationColumnLayout.implicitHeight + notificationListSpacing : 0 Behavior on implicitHeight { enabled: enableAnimation @@ -96,7 +102,7 @@ Item { // Flick right to dismiss property real startX: 0 property real dragStartThreshold: 10 - property real dragConfirmThresholdRatio: 0.2 + property real dragConfirmThreshold: 70 property bool dragStarted: false onPressed: (mouse) => { @@ -111,7 +117,7 @@ Item { onReleased: (mouse) => { dragStarted = false if (mouse.button === Qt.LeftButton) { - if (notificationRowWrapper.x > width * dragConfirmThresholdRatio) { + if (notificationRowWrapper.x > dragConfirmThreshold) { Notifications.discardNotification(notificationObject.id); } else { // Animate back if not far enough @@ -376,6 +382,7 @@ Item { } StyledText { // Notification body + id: notificationBodyText Layout.fillWidth: true Layout.leftMargin: 10 Layout.rightMargin: 10 @@ -387,8 +394,21 @@ Item { font.pixelSize: Appearance.font.pixelSize.small horizontalAlignment: Text.AlignLeft color: Appearance.m3colors.m3outline - // textFormat: Text.MarkdownText - text: expanded ? notificationObject.body : notificationObject.body.split("\n")[0] + textFormat: expanded ? Text.RichText : Text.StyledText + text: expanded + ? `` + + `${notificationObject.body.replace(/\n/g, "
")}` + : notificationObject.body.replace(/