quickshell: trim hyprshot body, add image preview to toast (shared helper)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
7cd7a0e3dc
commit
23a5ad2914
1 changed files with 36 additions and 13 deletions
|
|
@ -513,7 +513,9 @@ in
|
|||
elide: Text.ElideRight
|
||||
maximumLineCount: _nc.bodyLines
|
||||
wrapMode: Text.Wrap
|
||||
visible: text !== ""
|
||||
// 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")
|
||||
}
|
||||
Row {
|
||||
spacing: 4
|
||||
|
|
@ -966,6 +968,17 @@ in
|
|||
activeDropdown.animateClose();
|
||||
}
|
||||
}
|
||||
|
||||
// Preview image for a notification: its image hint, else a
|
||||
// file-path appIcon (e.g. hyprshot's saved shot). "" = none.
|
||||
function notifPreviewSource(notif) {
|
||||
if (!notif) return "";
|
||||
if (notif.image && notif.image !== "") return notif.image;
|
||||
let a = notif.appIcon || "";
|
||||
if (a.startsWith("file://")) return a;
|
||||
if (a.startsWith("/")) return "file://" + a;
|
||||
return "";
|
||||
}
|
||||
function toggleDropdown(dd, setupFn) {
|
||||
if (dd.visible && !dd.closing) {
|
||||
dd.animateClose();
|
||||
|
|
@ -2625,16 +2638,7 @@ in
|
|||
Rectangle {
|
||||
id: notifItem
|
||||
required property var modelData
|
||||
// Prefer the notification's image; fall back to a
|
||||
// file-path appIcon (e.g. hyprshot's saved shot).
|
||||
readonly property string previewSource: {
|
||||
let m = notifItem.modelData;
|
||||
if (m.image && m.image !== "") return m.image;
|
||||
let a = m.appIcon || "";
|
||||
if (a.startsWith("file://")) return a;
|
||||
if (a.startsWith("/")) return "file://" + a;
|
||||
return "";
|
||||
}
|
||||
readonly property string previewSource: bar.notifPreviewSource(notifItem.modelData)
|
||||
width: parent.width
|
||||
height: Math.max(notifPreview.visible ? 48 : 0, ncBody.height) + 16
|
||||
radius: Theme.radiusSmall
|
||||
|
|
@ -2785,14 +2789,33 @@ in
|
|||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.margins: 6
|
||||
height: toastCol.height + 16
|
||||
height: Math.max(toastPreview.visible ? 48 : 0, toastCol.height) + 16
|
||||
radius: Theme.radiusSmall
|
||||
color: Theme.base02
|
||||
|
||||
property string previewSource: bar.notifPreviewSource(toastItem.currentNotif)
|
||||
|
||||
// Image preview (screenshot thumb, album art…)
|
||||
ClippingRectangle {
|
||||
id: toastPreview
|
||||
visible: toastCard.previewSource !== ""
|
||||
anchors.left: parent.left
|
||||
anchors.top: parent.top
|
||||
anchors.margins: 8
|
||||
width: 48; height: 48
|
||||
radius: Theme.radiusTiny
|
||||
color: Theme.base01
|
||||
Image {
|
||||
anchors.fill: parent
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
source: toastCard.previewSource
|
||||
}
|
||||
}
|
||||
|
||||
NotifContent {
|
||||
id: toastCol
|
||||
notif: toastItem.currentNotif
|
||||
anchors.left: parent.left
|
||||
anchors.left: toastPreview.visible ? toastPreview.right : parent.left
|
||||
anchors.right: toastDismiss.left
|
||||
anchors.top: parent.top
|
||||
anchors.margins: 8
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue