Rename 'cycle theme mode' to 'toggle theme mode' and toggle only between light and dark
This commit is contained in:
parent
427f799018
commit
e9c2796034
3 changed files with 15 additions and 9 deletions
|
@ -40,9 +40,9 @@ pub fn init(cx: &mut App) {
|
||||||
toggle_icon_theme_selector(workspace, &action, window, cx);
|
toggle_icon_theme_selector(workspace, &action, window, cx);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
cx.on_action(|_: &zed_actions::theme_selector::CycleMode, cx| {
|
cx.on_action(|_: &zed_actions::theme_selector::ToggleMode, cx| {
|
||||||
with_active_or_new_workspace(cx, |workspace, window, cx| {
|
with_active_or_new_workspace(cx, |workspace, window, cx| {
|
||||||
cycle_theme_mode(workspace, window, cx);
|
toggle_theme_mode(workspace, window, cx);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -83,15 +83,21 @@ fn toggle_icon_theme_selector(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cycle_theme_mode(workspace: &mut Workspace, _window: &mut Window, cx: &mut Context<Workspace>) {
|
fn toggle_theme_mode(workspace: &mut Workspace, _window: &mut Window, cx: &mut Context<Workspace>) {
|
||||||
let current_settings = ThemeSettings::get_global(cx);
|
let current_settings = ThemeSettings::get_global(cx);
|
||||||
let current_selection = current_settings.theme_selection.as_ref();
|
let current_selection = current_settings.theme_selection.as_ref();
|
||||||
|
|
||||||
let new_mode = match current_selection {
|
let new_mode = match current_selection {
|
||||||
Some(ThemeSelection::Dynamic { mode, .. }) => match mode {
|
Some(ThemeSelection::Dynamic { mode, .. }) => match mode {
|
||||||
ThemeMode::Light => ThemeMode::Dark,
|
ThemeMode::Light => ThemeMode::Dark,
|
||||||
ThemeMode::Dark => ThemeMode::System,
|
ThemeMode::Dark => ThemeMode::Light,
|
||||||
ThemeMode::System => ThemeMode::Light,
|
ThemeMode::System => {
|
||||||
|
if cx.theme().appearance().is_light() {
|
||||||
|
ThemeMode::Dark
|
||||||
|
} else {
|
||||||
|
ThemeMode::Light
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
Some(ThemeSelection::Static(_)) => ThemeMode::Light,
|
Some(ThemeSelection::Static(_)) => ThemeMode::Light,
|
||||||
None => ThemeMode::Light,
|
None => ThemeMode::Light,
|
||||||
|
|
|
@ -33,8 +33,8 @@ pub fn app_menus() -> Vec<Menu> {
|
||||||
zed_actions::theme_selector::Toggle::default(),
|
zed_actions::theme_selector::Toggle::default(),
|
||||||
),
|
),
|
||||||
MenuItem::action(
|
MenuItem::action(
|
||||||
"Cycle Theme Mode",
|
"Toggle Theme Mode",
|
||||||
zed_actions::theme_selector::CycleMode,
|
zed_actions::theme_selector::ToggleMode,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -244,11 +244,11 @@ pub mod theme_selector {
|
||||||
pub themes_filter: Option<Vec<String>>,
|
pub themes_filter: Option<Vec<String>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Cycles between light, dark, and system theme modes.
|
/// Toggles between light and dark theme modes.
|
||||||
#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
|
#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
|
||||||
#[action(namespace = theme_selector)]
|
#[action(namespace = theme_selector)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
pub struct CycleMode;
|
pub struct ToggleMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod icon_theme_selector {
|
pub mod icon_theme_selector {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue