diff options
| author | Danilo M. <danix@danix.xyz> | 2026-09-15 18:12:26 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-09-15 18:12:26 +0200 |
| commit | 15dc51d86a964cc38aff23f0d47b80734a5356a8 (patch) | |
| tree | aa51c653d910a442f0efc1ea33ff5ba399b86814 /notifications/NotificationBalloon.qml | |
| parent | a94dfc49961db651b9659c6670125285fd7fc553 (diff) | |
| download | quickshell-15dc51d86a964cc38aff23f0d47b80734a5356a8.tar.gz quickshell-15dc51d86a964cc38aff23f0d47b80734a5356a8.zip | |
feat(notifications): draw the content image in the balloon
The daemon now publishes an image path; the balloon shows it below the
text, scaled to the balloon width with a 240px cap. A daemon without the
field leaves it hidden, so the renderer and the daemon can ship in
either order.
Diffstat (limited to 'notifications/NotificationBalloon.qml')
| -rw-r--r-- | notifications/NotificationBalloon.qml | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/notifications/NotificationBalloon.qml b/notifications/NotificationBalloon.qml index c6705e1..b77ca2a 100644 --- a/notifications/NotificationBalloon.qml +++ b/notifications/NotificationBalloon.qml @@ -37,7 +37,7 @@ Rectangle { } width: parent ? parent.width : 340 - implicitHeight: texts.implicitHeight + 20 + implicitHeight: texts.implicitHeight + 20 + (preview.visible ? preview.height + 8 : 0) radius: 10 color: Qt.alpha(Theme.base, 0.82) border.width: 1 @@ -132,4 +132,28 @@ Rectangle { color: Theme.subtext } } + + // The content image (a screenshot or an app-provided image), below the + // text. The daemon writes the path; an older daemon without the field + // leaves this hidden. The height matches the scaled width so + // PreserveAspectFit does not letterbox, and a tall screenshot is capped at + // 240px. Asynchronous so a large screenshot does not stall the shell. + Image { + id: preview + visible: b.notification.image !== "" && b.notification.image !== undefined + anchors { + left: parent.left + right: parent.right + top: texts.bottom + leftMargin: 10 + rightMargin: 10 + topMargin: 8 + } + height: visible && implicitWidth > 0 + ? Math.min(width * implicitHeight / implicitWidth, 240) + : 0 + source: visible ? "file://" + b.notification.image : "" + fillMode: Image.PreserveAspectFit + asynchronous: true + } } |
