1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-04-03 20:32:07 -04:00

fix: Animated Image warnings

This commit is contained in:
purian23
2026-02-23 23:18:02 -05:00
committed by bbedward
parent 07a0ac4b7d
commit fae4944845

View File

@@ -10,8 +10,9 @@ Rectangle {
property string fallbackIcon: "notifications" property string fallbackIcon: "notifications"
property string fallbackText: "" property string fallbackText: ""
property bool hasImage: imageSource !== "" property bool hasImage: imageSource !== ""
readonly property bool shouldProbe: imageSource !== "" && !imageSource.startsWith("image://")
// Probe with AnimatedImage first; once loaded, check frameCount to decide. // Probe with AnimatedImage first; once loaded, check frameCount to decide.
readonly property bool isAnimated: probe.status === Image.Ready && probe.frameCount > 1 readonly property bool isAnimated: shouldProbe && probe.status === Image.Ready && probe.frameCount > 1
readonly property var activeImage: isAnimated ? probe : staticImage readonly property var activeImage: isAnimated ? probe : staticImage
property int imageStatus: activeImage.status property int imageStatus: activeImage.status
@@ -44,7 +45,7 @@ Rectangle {
mipmap: true mipmap: true
cache: true cache: true
visible: false visible: false
source: root.imageSource source: root.shouldProbe ? root.imageSource : ""
} }
// Static fallback: used once probe confirms the image is not animated. // Static fallback: used once probe confirms the image is not animated.
@@ -58,13 +59,15 @@ Rectangle {
mipmap: true mipmap: true
cache: true cache: true
visible: false visible: false
source: "" source: !root.shouldProbe ? root.imageSource : ""
} }
// Once the probe loads, if not animated, hand off to Image and unload probe. // Once the probe loads, if not animated, hand off to Image and unload probe.
Connections { Connections {
target: probe target: probe
function onStatusChanged() { function onStatusChanged() {
if (!root.shouldProbe)
return;
switch (probe.status) { switch (probe.status) {
case Image.Ready: case Image.Ready:
if (probe.frameCount <= 1) { if (probe.frameCount <= 1) {
@@ -82,8 +85,13 @@ Rectangle {
// If imageSource changes, reset: re-probe with AnimatedImage. // If imageSource changes, reset: re-probe with AnimatedImage.
onImageSourceChanged: { onImageSourceChanged: {
staticImage.source = ""; if (root.shouldProbe) {
probe.source = root.imageSource; staticImage.source = "";
probe.source = root.imageSource;
} else {
probe.source = "";
staticImage.source = root.imageSource;
}
} }
MultiEffect { MultiEffect {