diff --git a/crates/settings/src/settings_store.rs b/crates/settings/src/settings_store.rs index fe921112b8..238df0dda1 100644 --- a/crates/settings/src/settings_store.rs +++ b/crates/settings/src/settings_store.rs @@ -31,8 +31,9 @@ use util::{ pub type EditorconfigProperties = ec4rs::Properties; use crate::{ - ActiveSettingsProfileName, ParameterizedJsonSchema, SettingsJsonSchemaParams, VsCodeSettings, - WorktreeId, parse_json_with_comments, settings_ui::SettingsUI, update_value_in_json_text, + ActiveSettingsProfileName, ParameterizedJsonSchema, SettingsJsonSchemaParams, SettingsUIItem, + VsCodeSettings, WorktreeId, parse_json_with_comments, settings_ui::SettingsUI, + update_value_in_json_text, }; /// A value that can be defined as a user setting. @@ -272,6 +273,7 @@ trait AnySettingValue: 'static + Send + Sync { text: &mut String, edits: &mut Vec<(Range, String)>, ); + fn settings_ui_item(&self) -> SettingsUIItem; } struct DeserializedSetting(Box); @@ -604,6 +606,12 @@ impl SettingsStore { rx } + + pub fn settings_ui_items(&self) -> impl IntoIterator { + self.setting_values + .values() + .map(|item| item.settings_ui_item()) + } } impl SettingsStore { @@ -1498,6 +1506,10 @@ impl AnySettingValue for SettingValue { edits, ); } + + fn settings_ui_item(&self) -> SettingsUIItem { + T::ui_item() + } } #[cfg(test)] diff --git a/crates/settings_ui/src/settings_ui.rs b/crates/settings_ui/src/settings_ui.rs index 546f948d16..83c9514792 100644 --- a/crates/settings_ui/src/settings_ui.rs +++ b/crates/settings_ui/src/settings_ui.rs @@ -5,7 +5,8 @@ use std::any::TypeId; use command_palette_hooks::CommandPaletteFilter; use editor::EditorSettingsControls; use feature_flags::{FeatureFlag, FeatureFlagViewExt}; -use gpui::{App, Entity, EventEmitter, FocusHandle, Focusable, actions}; +use gpui::{App, Entity, EventEmitter, FocusHandle, Focusable, ReadGlobal, actions}; +use settings::SettingsStore; use ui::prelude::*; use workspace::item::{Item, ItemEvent}; use workspace::{Workspace, with_active_or_new_workspace}; @@ -72,7 +73,6 @@ pub fn init(cx: &mut App) { .detach(); }) .detach(); - } pub struct SettingsPage { @@ -121,6 +121,17 @@ impl Render for SettingsPage { .p_4() .size_full() .gap_4() + .children( + SettingsStore::global(cx) + .settings_ui_items() + .into_iter() + .flat_map(|item| match item.item { + settings::SettingsUIItemVariant::Group { path, group } => Some(path), + settings::SettingsUIItemVariant::Item { path, item } => todo!(), + settings::SettingsUIItemVariant::None => None, + }) + .map(|group_name| Label::new(group_name).size(LabelSize::Large)), + ) .child(Label::new("Settings").size(LabelSize::Large)) .child( v_flex().gap_1().child(Label::new("Appearance")).child( diff --git a/crates/title_bar/src/title_bar_settings.rs b/crates/title_bar/src/title_bar_settings.rs index 781900cea6..d674899370 100644 --- a/crates/title_bar/src/title_bar_settings.rs +++ b/crates/title_bar/src/title_bar_settings.rs @@ -1,9 +1,10 @@ use db::anyhow; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use settings::{SettingsUI, Settings, SettingsSources}; +use settings::{Settings, SettingsSources, SettingsUI}; #[derive(Copy, Clone, Deserialize, Debug, SettingsUI)] +#[settings_ui(group = "Title Bar")] pub struct TitleBarSettings { pub show_branch_icon: bool, pub show_onboarding_banner: bool,