Remove cx from ThemeSettings (#38836)

Before this change the active theme and icon theme were retrofitted onto
the ThemeSettings.

Now they're in their own new global (GlobalTheme::theme(cx) and
GlobalTheme::icon_theme(cx))

This lets us remove cx from the settings traits, and tidy up a few other
things along the way.

Release Notes:

- N/A
This commit is contained in:
Conrad Irwin
2025-10-06 23:06:50 +00:00
committed by GitHub
parent 4de13e06ec
commit a2a7bd139a
60 changed files with 360 additions and 423 deletions
+2 -2
View File
@@ -65,7 +65,7 @@ pub struct PreviewTabsSettings {
}
impl Settings for ItemSettings {
fn from_settings(content: &settings::SettingsContent, _cx: &mut App) -> Self {
fn from_settings(content: &settings::SettingsContent) -> Self {
let tabs = content.tabs.as_ref().unwrap();
Self {
git_status: tabs.git_status.unwrap(),
@@ -113,7 +113,7 @@ impl Settings for ItemSettings {
}
impl Settings for PreviewTabsSettings {
fn from_settings(content: &settings::SettingsContent, _cx: &mut App) -> Self {
fn from_settings(content: &settings::SettingsContent) -> Self {
let preview_tabs = content.preview_tabs.as_ref().unwrap();
Self {
enabled: preview_tabs.enabled.unwrap(),
+3 -3
View File
@@ -103,7 +103,7 @@ use std::{
time::Duration,
};
use task::{DebugScenario, SpawnInTerminal, TaskContext};
use theme::{ActiveTheme, SystemAppearance, ThemeSettings};
use theme::{ActiveTheme, GlobalTheme, SystemAppearance, ThemeSettings};
pub use toolbar::{Toolbar, ToolbarItemEvent, ToolbarItemLocation, ToolbarItemView};
pub use ui;
use ui::{Window, prelude::*};
@@ -1435,8 +1435,8 @@ impl Workspace {
*SystemAppearance::global_mut(cx) = SystemAppearance(window_appearance.into());
ThemeSettings::reload_current_theme(cx);
ThemeSettings::reload_current_icon_theme(cx);
GlobalTheme::reload_theme(cx);
GlobalTheme::reload_icon_theme(cx);
}),
cx.on_release(move |this, cx| {
this.app_state.workspace_store.update(cx, move |store, _| {
+3 -4
View File
@@ -2,7 +2,6 @@ use std::num::NonZeroUsize;
use crate::DockPosition;
use collections::HashMap;
use gpui::App;
use serde::Deserialize;
pub use settings::AutosaveSetting;
use settings::Settings;
@@ -62,7 +61,7 @@ pub struct TabBarSettings {
}
impl Settings for WorkspaceSettings {
fn from_settings(content: &settings::SettingsContent, _cx: &mut App) -> Self {
fn from_settings(content: &settings::SettingsContent) -> Self {
let workspace = &content.workspace;
Self {
active_pane_modifiers: ActivePanelModifiers {
@@ -197,7 +196,7 @@ impl Settings for WorkspaceSettings {
}
impl Settings for TabBarSettings {
fn from_settings(content: &settings::SettingsContent, _cx: &mut App) -> Self {
fn from_settings(content: &settings::SettingsContent) -> Self {
let tab_bar = content.tab_bar.clone().unwrap();
TabBarSettings {
show: tab_bar.show.unwrap(),
@@ -231,7 +230,7 @@ pub struct StatusBarSettings {
}
impl Settings for StatusBarSettings {
fn from_settings(content: &settings::SettingsContent, _cx: &mut App) -> Self {
fn from_settings(content: &settings::SettingsContent) -> Self {
let status_bar = content.status_bar.clone().unwrap();
StatusBarSettings {
show: status_bar.show.unwrap(),