fix(ui): 🐛 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
This commit is contained in:
Observer KRypt0n_ 2023-02-24 19:31:32 +02:00
parent 6024ef885e
commit b7e85b7a8f
No known key found for this signature in database
GPG key ID: 844DA47BA25FE1E2
2 changed files with 15 additions and 0 deletions

View file

@ -16,6 +16,8 @@ use super::finish::*;
pub static mut MAIN_WINDOW: Option<adw::Window> = None; pub static mut MAIN_WINDOW: Option<adw::Window> = None;
// TODO: add special page for launcher style selection
pub struct FirstRunApp { pub struct FirstRunApp {
welcome: AsyncController<WelcomeApp>, welcome: AsyncController<WelcomeApp>,
tos_warning: AsyncController<TosWarningApp>, tos_warning: AsyncController<TosWarningApp>,

View file

@ -532,6 +532,19 @@ impl SimpleAsyncComponent for GeneralApp {
#[allow(unused_must_use)] #[allow(unused_must_use)]
GeneralAppMsg::UpdateLauncherStyle(style) => { 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() { if let Ok(mut config) = config::get() {
config.launcher.style = style; config.launcher.style = style;