From b7e85b7a8f6306c3220b76e64ab492ffd9629ba7 Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Fri, 24 Feb 2023 19:31:32 +0200 Subject: [PATCH] fix(ui): :bug: added background downloading on style's change from settings Previously launcher wasn't downloading background picture if the style was changed from the settings. This lead to situation when the window size and components position is updated, but background is fully transparent. With this change launcher will try to download picture if default background file doesn't exist. Not that launcher won't try to update this picture and this will happen only after restart, which is not an issue, I think --- src/ui/first_run/main.rs | 2 ++ src/ui/preferences/general.rs | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/ui/first_run/main.rs b/src/ui/first_run/main.rs index 8d28c93..b7851b7 100644 --- a/src/ui/first_run/main.rs +++ b/src/ui/first_run/main.rs @@ -16,6 +16,8 @@ use super::finish::*; pub static mut MAIN_WINDOW: Option = None; +// TODO: add special page for launcher style selection + pub struct FirstRunApp { welcome: AsyncController, tos_warning: AsyncController, diff --git a/src/ui/preferences/general.rs b/src/ui/preferences/general.rs index f5e788d..5603262 100644 --- a/src/ui/preferences/general.rs +++ b/src/ui/preferences/general.rs @@ -532,6 +532,19 @@ impl SimpleAsyncComponent for GeneralApp { #[allow(unused_must_use)] GeneralAppMsg::UpdateLauncherStyle(style) => { + if style == LauncherStyle::Classic && !BACKGROUND_FILE.exists() { + if let Err(err) = crate::background::download_background() { + tracing::error!("Failed to download background picture"); + + sender.input(GeneralAppMsg::Toast { + title: tr("background-downloading-failed"), + description: Some(err.to_string()) + }); + + return; + } + } + if let Ok(mut config) = config::get() { config.launcher.style = style;