startupfeedback: Handle case where same icon is used for opening

This commit is contained in:
Devin Lin 2023-11-18 18:27:43 -08:00
parent 4dddf9a46c
commit e0768d64c0

View file

@ -29,8 +29,7 @@ MouseArea { // use mousearea to ensure clicks don't go behind
background.scale = 0; background.scale = 0;
backgroundParent.x = -root.width/2 + x backgroundParent.x = -root.width/2 + x
backgroundParent.y = -root.height/2 + y backgroundParent.y = -root.height/2 + y
colorGenerator.resetColor(); updateIconSource(splashIcon);
icon.source = splashIcon;
if (ShellSettings.Settings.animationsEnabled) { if (ShellSettings.Settings.animationsEnabled) {
openAnimComplex.restart(); openAnimComplex.restart();
@ -66,13 +65,24 @@ MouseArea { // use mousearea to ensure clicks don't go behind
background.scale = 0.5; background.scale = 0.5;
backgroundParent.x = 0 backgroundParent.x = 0
backgroundParent.y = 0 backgroundParent.y = 0
colorGenerator.resetColor(); root.updateIconSource(iconName);
icon.source = iconName
openAnimComplex.restart(); 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 { Kirigami.ImageColors {
id: colorGenerator id: colorGenerator
source: icon.source source: icon.source
@ -84,9 +94,13 @@ MouseArea { // use mousearea to ensure clicks don't go behind
function resetColor() { function resetColor() {
colorToUse = 'transparent'; colorToUse = 'transparent';
} }
onPaletteChanged: { function updateColor() {
colorToUse = colorGenerator.dominant; colorToUse = colorGenerator.dominant;
} }
onPaletteChanged: {
// update color once palette has loaded
updateColor();
}
} }
// animation that moves the icon // animation that moves the icon