Skip to content

Commit

Permalink
Prevent from changing theme settings if theme file exist
Browse files Browse the repository at this point in the history
  • Loading branch information
Exidex committed Jan 7, 2025
1 parent 6b0e3fa commit 63e1642
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 12 deletions.
47 changes: 36 additions & 11 deletions rust/management_client/src/views/general.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion rust/server/src/plugins/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ pub fn read_theme_file(theme_file: PathBuf) -> Option<UiTheme> {
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
}
}
Expand Down

0 comments on commit 63e1642

Please sign in to comment.