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
|
elide: Text.ElideRight
|
||||||
maximumLineCount: _nc.bodyLines
|
maximumLineCount: _nc.bodyLines
|
||||||
wrapMode: Text.Wrap
|
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 {
|
Row {
|
||||||
spacing: 4
|
spacing: 4
|
||||||
|
|
@ -966,6 +968,17 @@ in
|
||||||
activeDropdown.animateClose();
|
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) {
|
function toggleDropdown(dd, setupFn) {
|
||||||
if (dd.visible && !dd.closing) {
|
if (dd.visible && !dd.closing) {
|
||||||
dd.animateClose();
|
dd.animateClose();
|
||||||
|
|
@ -2625,16 +2638,7 @@ in
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: notifItem
|
id: notifItem
|
||||||
required property var modelData
|
required property var modelData
|
||||||
// Prefer the notification's image; fall back to a
|
readonly property string previewSource: bar.notifPreviewSource(notifItem.modelData)
|
||||||
// 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 "";
|
|
||||||
}
|
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: Math.max(notifPreview.visible ? 48 : 0, ncBody.height) + 16
|
height: Math.max(notifPreview.visible ? 48 : 0, ncBody.height) + 16
|
||||||
radius: Theme.radiusSmall
|
radius: Theme.radiusSmall
|
||||||
|
|
@ -2785,14 +2789,33 @@ in
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.margins: 6
|
anchors.margins: 6
|
||||||
height: toastCol.height + 16
|
height: Math.max(toastPreview.visible ? 48 : 0, toastCol.height) + 16
|
||||||
radius: Theme.radiusSmall
|
radius: Theme.radiusSmall
|
||||||
color: Theme.base02
|
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 {
|
NotifContent {
|
||||||
id: toastCol
|
id: toastCol
|
||||||
notif: toastItem.currentNotif
|
notif: toastItem.currentNotif
|
||||||
anchors.left: parent.left
|
anchors.left: toastPreview.visible ? toastPreview.right : parent.left
|
||||||
anchors.right: toastDismiss.left
|
anchors.right: toastDismiss.left
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.margins: 8
|
anchors.margins: 8
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue