screenshots: clipboard-only, camera glyph instead of thumbnail

This commit is contained in:
rope 2026-08-21 17:13:12 +01:00
parent c3e8691c2c
commit 6bf3c3909e
3 changed files with 43 additions and 17 deletions

View file

@ -2119,9 +2119,11 @@ in
elide: Text.ElideRight
maximumLineCount: _nc.bodyLines
wrapMode: Text.Wrap
// ponytail: hyprshot's body is a noisy file path; the
// "Screenshot saved" summary + the preview say enough.
visible: text !== "" && !(_nc.notif && _nc.notif.appName === "Hyprshot")
// hyprshot's body used to be a noisy save path and was
// hidden. Under --clipboard-only it reads "Image copied
// to the clipboard", which is the only thing correcting
// its own "Screenshot saved" summary nothing is saved.
visible: text !== ""
}
Row {
spacing: 4
@ -3888,7 +3890,7 @@ in
}
// Preview image for a notification: its image hint, else a
// file-path appIcon (e.g. hyprshot's saved shot). "" = none.
// file-path appIcon (e.g. album art on disk). "" = none.
function notifPreviewSource(notif) {
if (!notif) return "";
if (notif.image && notif.image !== "") return notif.image;
@ -3897,6 +3899,15 @@ in
if (a.startsWith("/")) return "file://" + a;
return "";
}
// Glyph to fill the preview slot when there is no image to put
// there. Screenshots run --clipboard-only, so nothing is written
// to disk and there is no thumbnail to load which is the point:
// a decoded 3440x1440 texture cost ~19MB per retained shot.
function notifPreviewIcon(notif) {
if (!notif) return "";
return notif.appName === "Hyprshot" ? "camera" : "";
}
// Jump to the window that sent a notification. Toplevel.activate()
// goes over wlr-foreign-toplevel the same path a taskbar uses
// so Hyprland follows it across workspaces. The app raising
@ -6969,6 +6980,7 @@ in
id: notifItem
required property var modelData
readonly property string previewSource: bar.notifPreviewSource(notifItem.modelData)
readonly property string previewIcon: bar.notifPreviewIcon(notifItem.modelData)
width: parent.width
Item {
@ -6994,10 +7006,11 @@ in
}
}
// Image preview (album art, screenshot thumb)
// Image preview (album art), or a glyph for
// senders that have no image worth loading.
ClippingRectangle {
id: notifPreview
visible: notifItem.previewSource !== ""
visible: notifItem.previewSource !== "" || notifItem.previewIcon !== ""
anchors.left: parent.left
anchors.top: parent.top
width: 48; height: 48
@ -7006,14 +7019,19 @@ in
Image {
anchors.fill: parent
fillMode: Image.PreserveAspectCrop
// Decode to thumbnail height: without this a
// screenshot notification keeps a full-resolution
// 3440x1440 texture (~19MB) resident for as long
// as it is tracked 30 retained notifications is
// Decode to thumbnail height: a full-resolution
// 3440x1440 texture is ~19MB resident for as long
// as the notification is tracked 30 retained is
// half a gigabyte of VRAM for 48px previews.
sourceSize.height: 96
source: notifItem.previewSource
}
SIcon {
anchors.centerIn: parent
visible: notifItem.previewSource === ""
text: notifItem.previewIcon
font.pixelSize: 22
}
}
NotifContent {
@ -7330,6 +7348,7 @@ in
color: Theme.cardBg
property string previewSource: bar.notifPreviewSource(toastItem.currentNotif)
property string previewIcon: bar.notifPreviewIcon(toastItem.currentNotif)
// First child, so the action chips and the dismiss
// button still take their own clicks.
@ -7343,10 +7362,10 @@ in
}
}
// Image preview (screenshot thumb, album art)
// Image preview (album art), else the sender's glyph.
ClippingRectangle {
id: toastPreview
visible: toastCard.previewSource !== ""
visible: toastCard.previewSource !== "" || toastCard.previewIcon !== ""
anchors.left: parent.left
anchors.top: parent.top
anchors.margins: 8
@ -7360,6 +7379,12 @@ in
sourceSize.height: 96
source: toastCard.previewSource
}
SIcon {
anchors.centerIn: parent
visible: toastCard.previewSource === ""
text: toastCard.previewIcon
font.pixelSize: 22
}
}
NotifContent {