fix
This commit is contained in:
@@ -37,15 +37,33 @@ Item {
|
||||
readonly property bool isExpanded: forceExpanded || contextOpen
|
||||
|
||||
function resolveIconSource(iconName) {
|
||||
const fallbackName = "deltarune-soul";
|
||||
const normalized = String(iconName || "").trim();
|
||||
if (normalized.length === 0)
|
||||
return "";
|
||||
return String(Quickshell.iconPath(fallbackName, true) || "");
|
||||
if (normalized.indexOf("/") >= 0 || normalized.indexOf("file://") === 0)
|
||||
return normalized;
|
||||
return String(Quickshell.iconPath(normalized) || "");
|
||||
|
||||
const primaryPath = String(Quickshell.iconPath(normalized, true) || "");
|
||||
if (primaryPath.length > 0)
|
||||
return primaryPath;
|
||||
|
||||
return String(Quickshell.iconPath(fallbackName, true) || "");
|
||||
}
|
||||
|
||||
function isNotifyToolName(value) {
|
||||
const normalized = String(value || "").trim().toLowerCase();
|
||||
if (normalized.length === 0)
|
||||
return false;
|
||||
return normalized === "notify-send" || normalized === "dunstify" || normalized === "notify-send.desktop" || normalized === "dunstify.desktop";
|
||||
}
|
||||
|
||||
readonly property bool preferSoulFallbackIcon: isNotifyToolName(notifAppName) || isNotifyToolName(notifDesktopEntry)
|
||||
|
||||
readonly property string appIconSource: {
|
||||
if (preferSoulFallbackIcon)
|
||||
return "";
|
||||
|
||||
const candidates = [];
|
||||
const desktopEntry = notifDesktopEntry.trim();
|
||||
const appName = notifAppName.trim();
|
||||
@@ -79,7 +97,9 @@ Item {
|
||||
|
||||
readonly property string customImageSource: notifImage
|
||||
readonly property string primaryIconSource: customImageSource.length > 0 ? customImageSource : appIconSource
|
||||
readonly property bool showBadgeIcon: customImageSource.length > 0 && appIconSource.length > 0
|
||||
property bool primaryIconReady: false
|
||||
property bool badgeIconReady: false
|
||||
readonly property bool showBadgeIcon: customImageSource.length > 0 && appIconSource.length > 0 && badgeIconReady
|
||||
readonly property int iconBoxSize: (theme ? theme.iconBox : 28) + 12
|
||||
|
||||
readonly property var notifActions: {
|
||||
@@ -114,22 +134,16 @@ Item {
|
||||
return items;
|
||||
}
|
||||
|
||||
function urgencyTimeoutMs() {
|
||||
function autoCloseTimeoutMs() {
|
||||
const fallbackTimeoutMs = 3000;
|
||||
if (!notifObject)
|
||||
return theme.fallbackNormalTimeoutMs;
|
||||
return fallbackTimeoutMs;
|
||||
|
||||
const rawTimeout = Number(notifObject.expireTimeout);
|
||||
if (Number.isFinite(rawTimeout) && rawTimeout > 0) {
|
||||
const normalizedTimeout = rawTimeout > 100 ? Math.round(rawTimeout) : Math.round(rawTimeout * 1000);
|
||||
return Math.max(theme ? theme.minimumTimeoutMs : 2000, normalizedTimeout);
|
||||
}
|
||||
const specifiedTimeoutMs = Number(notifObject.expireTimeout);
|
||||
if (Number.isFinite(specifiedTimeoutMs) && specifiedTimeoutMs > 0)
|
||||
return Math.max(1, Math.round(specifiedTimeoutMs));
|
||||
|
||||
const urgency = notifObject.urgency;
|
||||
if (urgency === NotificationUrgency.Critical)
|
||||
return theme.fallbackCriticalTimeoutMs;
|
||||
if (urgency === NotificationUrgency.Low)
|
||||
return theme.fallbackLowTimeoutMs;
|
||||
return theme.fallbackNormalTimeoutMs;
|
||||
return fallbackTimeoutMs;
|
||||
}
|
||||
|
||||
function relativeTime() {
|
||||
@@ -166,10 +180,16 @@ Item {
|
||||
}
|
||||
|
||||
function restartTimeout() {
|
||||
timeoutTimer.stop();
|
||||
if (closing || isExpanded || peekMode || hovered)
|
||||
return;
|
||||
timeoutTimer.interval = urgencyTimeoutMs();
|
||||
timeoutTimer.restart();
|
||||
|
||||
const timeoutMs = autoCloseTimeoutMs();
|
||||
if (!(timeoutMs > 0))
|
||||
return;
|
||||
|
||||
timeoutTimer.interval = timeoutMs;
|
||||
timeoutTimer.start();
|
||||
}
|
||||
|
||||
property string closeReason: ""
|
||||
@@ -232,7 +252,7 @@ Item {
|
||||
|
||||
Timer {
|
||||
id: timeoutTimer
|
||||
interval: root.urgencyTimeoutMs()
|
||||
interval: root.autoCloseTimeoutMs()
|
||||
repeat: false
|
||||
running: false
|
||||
onTriggered: root.beginClose("timeout")
|
||||
@@ -281,13 +301,15 @@ Item {
|
||||
IconImage {
|
||||
anchors.fill: parent
|
||||
source: root.primaryIconSource
|
||||
visible: root.primaryIconSource.length > 0
|
||||
visible: root.primaryIconReady
|
||||
asynchronous: true
|
||||
onSourceChanged: root.primaryIconReady = false
|
||||
onStatusChanged: root.primaryIconReady = status === Image.Ready
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
visible: root.primaryIconSource.length === 0
|
||||
visible: !root.primaryIconReady
|
||||
color: "#000000"
|
||||
border.width: 0
|
||||
border.color: "transparent"
|
||||
@@ -300,7 +322,7 @@ Item {
|
||||
width: parent.width - 2
|
||||
height: parent.height - 2
|
||||
source: "../Topbar/topbar/soul_small.png"
|
||||
visible: root.primaryIconSource.length === 0
|
||||
visible: !root.primaryIconReady
|
||||
smooth: false
|
||||
antialiasing: false
|
||||
fillMode: Image.PreserveAspectFit
|
||||
@@ -314,6 +336,8 @@ Item {
|
||||
x: parent.width - width
|
||||
y: parent.height - height
|
||||
asynchronous: true
|
||||
onSourceChanged: root.badgeIconReady = false
|
||||
onStatusChanged: root.badgeIconReady = status === Image.Ready
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user