Fallback to app icon if there's nothing else
This commit is contained in:
@@ -44,6 +44,14 @@ BarWidget {
|
|||||||
.replace(/^\s*(?:https?:\/\/|www\.)?(?:[a-z0-9-]+\.)+[a-z]{2,}(?::\d+)?(?:\/\S*)?\s+/i, "")
|
.replace(/^\s*(?:https?:\/\/|www\.)?(?:[a-z0-9-]+\.)+[a-z]{2,}(?::\d+)?(?:\/\S*)?\s+/i, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function notificationIconSource(icon) {
|
||||||
|
var value = String(icon || "")
|
||||||
|
if (value.length === 0) return ""
|
||||||
|
if (value.indexOf("file://") === 0 || value.indexOf("image://") === 0) return value
|
||||||
|
if (value.charAt(0) === "/") return Util.fileUrl(value)
|
||||||
|
return Quickshell.iconPath(value, true)
|
||||||
|
}
|
||||||
|
|
||||||
readonly property int pendingCount: notificationService ? notificationService.pendingModel.count : 0
|
readonly property int pendingCount: notificationService ? notificationService.pendingModel.count : 0
|
||||||
readonly property int pastCount: notificationService ? notificationService.pastModel.count : 0
|
readonly property int pastCount: notificationService ? notificationService.pastModel.count : 0
|
||||||
readonly property bool dnd: notificationService ? notificationService.doNotDisturb : false
|
readonly property bool dnd: notificationService ? notificationService.doNotDisturb : false
|
||||||
@@ -284,7 +292,7 @@ BarWidget {
|
|||||||
|
|
||||||
readonly property bool hasMedia: image.length > 0 && (
|
readonly property bool hasMedia: image.length > 0 && (
|
||||||
image.indexOf("image://icon//") === 0 || image.indexOf("file://") === 0)
|
image.indexOf("image://icon//") === 0 || image.indexOf("file://") === 0)
|
||||||
readonly property string smallIconSource: image.length > 0 ? image : appIcon
|
readonly property string smallIconSource: image.length > 0 ? image : root.notificationIconSource(appIcon)
|
||||||
readonly property bool hasIcon: !hasMedia && smallIconSource.length > 0
|
readonly property bool hasIcon: !hasMedia && smallIconSource.length > 0
|
||||||
readonly property string sanitizedBody: root.sanitizeBody(body, app, appIcon)
|
readonly property string sanitizedBody: root.sanitizeBody(body, app, appIcon)
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
|
import Quickshell
|
||||||
import qs.Commons
|
import qs.Commons
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
@@ -31,13 +32,9 @@ Rectangle {
|
|||||||
|
|
||||||
signal closeRequested()
|
signal closeRequested()
|
||||||
signal cardClicked()
|
signal cardClicked()
|
||||||
// Use only what the notification explicitly carries — no themed-icon
|
// Prefer per-notification media/avatar data, then fall back to the app icon.
|
||||||
// theme-lookup fallback because Quickshell's icon image provider returns
|
// The `check` flag avoids Qt's missing-texture placeholder for unknown names.
|
||||||
// a placeholder for missing names (rather than erroring), which means
|
readonly property string smallIconSource: image.length > 0 ? image : iconSource(appIcon)
|
||||||
// we'd render Qt's pink "broken image" pattern for any unknown app.
|
|
||||||
// Apps that send their own icon via `image` (image-data hint) or
|
|
||||||
// `appIcon` (-i flag) still get one.
|
|
||||||
readonly property string smallIconSource: image.length > 0 ? image : appIcon
|
|
||||||
readonly property bool hasGlyph: glyph.length > 0
|
readonly property bool hasGlyph: glyph.length > 0
|
||||||
readonly property bool hasSmallIcon: smallIconSource.length > 0 || hasGlyph
|
readonly property bool hasSmallIcon: smallIconSource.length > 0 || hasGlyph
|
||||||
readonly property bool summaryStartsWithGlyph: /^\s*\S\s{2,}/.test(summary)
|
readonly property bool summaryStartsWithGlyph: /^\s*\S\s{2,}/.test(summary)
|
||||||
@@ -67,6 +64,14 @@ Rectangle {
|
|||||||
.replace(/^\s*(?:https?:\/\/|www\.)?(?:[a-z0-9-]+\.)+[a-z]{2,}(?::\d+)?(?:\/\S*)?\s+/i, "")
|
.replace(/^\s*(?:https?:\/\/|www\.)?(?:[a-z0-9-]+\.)+[a-z]{2,}(?::\d+)?(?:\/\S*)?\s+/i, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function iconSource(icon) {
|
||||||
|
var value = String(icon || "")
|
||||||
|
if (value.length === 0) return ""
|
||||||
|
if (value.indexOf("file://") === 0 || value.indexOf("image://") === 0) return value
|
||||||
|
if (value.charAt(0) === "/") return Util.fileUrl(value)
|
||||||
|
return Quickshell.iconPath(value, true)
|
||||||
|
}
|
||||||
|
|
||||||
implicitWidth: Style.space(380)
|
implicitWidth: Style.space(380)
|
||||||
// Add 2 * border.width so mainColumn (inset by border.width on top/left/right)
|
// Add 2 * border.width so mainColumn (inset by border.width on top/left/right)
|
||||||
// doesn't push content under the bottom edge.
|
// doesn't push content under the bottom edge.
|
||||||
|
|||||||
Reference in New Issue
Block a user