From 63e16428236904a8f84c1373e2a3267f11a614ed Mon Sep 17 00:00:00 2001 From: Exidex <16986685+exidex@users.noreply.github.com> Date: Tue, 7 Jan 2025 19:20:22 +0100 Subject: [PATCH] Prevent from changing theme settings if theme file exist --- rust/management_client/src/views/general.rs | 47 ++++++++++++++++----- rust/server/src/plugins/theme.rs | 2 +- 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/rust/management_client/src/views/general.rs b/rust/management_client/src/views/general.rs index a819ca24..084e0175 100644 --- a/rust/management_client/src/views/general.rs +++ b/rust/management_client/src/views/general.rs @@ -120,18 +120,43 @@ impl ManagementAppGeneralState { Some(self.shortcut_capture_after()) ); - let theme_items = [ - SettingsTheme::AutoDetect, - SettingsTheme::MacOSLight, - SettingsTheme::MacOSDark, - SettingsTheme::Legacy, - ]; - let theme_field: Element<_> = pick_list( - theme_items, - Some(self.theme.clone()), - move |item| ManagementAppGeneralMsgIn::ThemeChanged(item), - ).into(); + let theme_field = match &self.theme { + SettingsTheme::ThemeFile => { + let theme_field: Element<_> = text("Unable to change because theme config file is present ") + .shaping(Shaping::Advanced) + .align_x(Horizontal::Center) + .width(Length::Fill) + .into(); + + theme_field + } + SettingsTheme::Config => { + let theme_field: Element<_> = text("Unable to change because value is defined in config") + .shaping(Shaping::Advanced) + .align_x(Horizontal::Center) + .width(Length::Fill) + .into(); + + theme_field + } + _ => { + let theme_items = [ + SettingsTheme::AutoDetect, + SettingsTheme::MacOSLight, + SettingsTheme::MacOSDark, + SettingsTheme::Legacy, + ]; + + let theme_field: Element<_> = pick_list( + theme_items, + Some(self.theme.clone()), + move |item| ManagementAppGeneralMsgIn::ThemeChanged(item), + ).into(); + + theme_field + } + }; let theme_field: Element<_> = container(theme_field) .width(Length::Fill) diff --git a/rust/server/src/plugins/theme.rs b/rust/server/src/plugins/theme.rs index 0ba430d7..1cae1752 100644 --- a/rust/server/src/plugins/theme.rs +++ b/rust/server/src/plugins/theme.rs @@ -158,7 +158,7 @@ pub fn read_theme_file(theme_file: PathBuf) -> Option { match parse_theme(&value) { Ok(value) => Some(value), Err(err) => { - tracing::warn!("Unable to parse theme file: {:?} - {:?}", theme_file, err); + tracing::warn!("Unable to parse theme file: {:?} - {:#}", theme_file, err); None } }