From e0768d64c0173467d5e00340a547f03d3e191992 Mon Sep 17 00:00:00 2001 From: Devin Lin Date: Sat, 18 Nov 2023 18:27:43 -0800 Subject: [PATCH] startupfeedback: Handle case where same icon is used for opening --- .../qml/components/StartupFeedback.qml | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/components/mobileshell/qml/components/StartupFeedback.qml b/components/mobileshell/qml/components/StartupFeedback.qml index 36f45a9a..9e4c3099 100644 --- a/components/mobileshell/qml/components/StartupFeedback.qml +++ b/components/mobileshell/qml/components/StartupFeedback.qml @@ -29,8 +29,7 @@ MouseArea { // use mousearea to ensure clicks don't go behind background.scale = 0; backgroundParent.x = -root.width/2 + x backgroundParent.y = -root.height/2 + y - colorGenerator.resetColor(); - icon.source = splashIcon; + updateIconSource(splashIcon); if (ShellSettings.Settings.animationsEnabled) { openAnimComplex.restart(); @@ -66,13 +65,24 @@ MouseArea { // use mousearea to ensure clicks don't go behind background.scale = 0.5; backgroundParent.x = 0 backgroundParent.y = 0 - colorGenerator.resetColor(); - icon.source = iconName + root.updateIconSource(iconName); openAnimComplex.restart(); } } } + function updateIconSource(source) { + if (icon.source !== source) { + // the colors are generated async from the icon, so we need to ensure we don't display an old color + // for a moment when an app opens + colorGenerator.resetColor(); + } else { + // case where we set the same icon, ensure the color is set + colorGenerator.updateColor(); + } + icon.source = source; + } + Kirigami.ImageColors { id: colorGenerator source: icon.source @@ -84,9 +94,13 @@ MouseArea { // use mousearea to ensure clicks don't go behind function resetColor() { colorToUse = 'transparent'; } - onPaletteChanged: { + function updateColor() { colorToUse = colorGenerator.dominant; } + onPaletteChanged: { + // update color once palette has loaded + updateColor(); + } } // animation that moves the icon