settings: Remove auxiliary Content types where possible (#16744)
Release Notes: - N/A
This commit is contained in:
parent
8f28445612
commit
ccf6f27b8f
49 changed files with 843 additions and 696 deletions
|
@ -1108,7 +1108,7 @@ impl Panel for ChatPanel {
|
|||
settings::update_settings_file::<ChatPanelSettings>(
|
||||
self.fs.clone(),
|
||||
cx,
|
||||
move |settings, _| settings.dock = Some(position),
|
||||
move |settings, _| settings.dock = position,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -113,9 +113,7 @@ impl MessageEditor {
|
|||
editor.set_show_indent_guides(false, cx);
|
||||
editor.set_completion_provider(Box::new(MessageEditorCompletionProvider(this)));
|
||||
editor.set_auto_replace_emoji_shortcode(
|
||||
MessageEditorSettings::get_global(cx)
|
||||
.auto_replace_emoji_shortcode
|
||||
.unwrap_or_default(),
|
||||
MessageEditorSettings::get_global(cx).auto_replace_emoji_shortcode,
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -130,9 +128,7 @@ impl MessageEditor {
|
|||
cx.observe_global::<settings::SettingsStore>(|view, cx| {
|
||||
view.editor.update(cx, |editor, cx| {
|
||||
editor.set_auto_replace_emoji_shortcode(
|
||||
MessageEditorSettings::get_global(cx)
|
||||
.auto_replace_emoji_shortcode
|
||||
.unwrap_or_default(),
|
||||
MessageEditorSettings::get_global(cx).auto_replace_emoji_shortcode,
|
||||
)
|
||||
})
|
||||
})
|
||||
|
|
|
@ -2813,7 +2813,7 @@ impl Panel for CollabPanel {
|
|||
settings::update_settings_file::<CollaborationPanelSettings>(
|
||||
self.fs.clone(),
|
||||
cx,
|
||||
move |settings, _| settings.dock = Some(position),
|
||||
move |settings, _| settings.dock = position,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -672,7 +672,7 @@ impl Panel for NotificationPanel {
|
|||
settings::update_settings_file::<NotificationPanelSettings>(
|
||||
self.fs.clone(),
|
||||
cx,
|
||||
move |settings, _| settings.dock = Some(position),
|
||||
move |settings, _| settings.dock = position,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,58 +2,84 @@ use gpui::Pixels;
|
|||
use schemars::JsonSchema;
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use settings::{Settings, SettingsSources};
|
||||
use ui::px;
|
||||
use workspace::dock::DockPosition;
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
#[derive(Clone, Deserialize, Debug, JsonSchema, Serialize)]
|
||||
#[serde(default)]
|
||||
pub struct CollaborationPanelSettings {
|
||||
pub button: bool,
|
||||
pub dock: DockPosition,
|
||||
pub default_width: Pixels,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
pub struct ChatPanelSettings {
|
||||
pub button: bool,
|
||||
pub dock: DockPosition,
|
||||
pub default_width: Pixels,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
pub struct NotificationPanelSettings {
|
||||
pub button: bool,
|
||||
pub dock: DockPosition,
|
||||
pub default_width: Pixels,
|
||||
}
|
||||
|
||||
#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, Debug)]
|
||||
pub struct PanelSettingsContent {
|
||||
/// Whether to show the panel button in the status bar.
|
||||
///
|
||||
/// Default: true
|
||||
pub button: Option<bool>,
|
||||
pub button: bool,
|
||||
/// Where to dock the panel.
|
||||
///
|
||||
/// Default: left
|
||||
pub dock: Option<DockPosition>,
|
||||
pub dock: DockPosition,
|
||||
/// Default width of the panel in pixels.
|
||||
///
|
||||
/// Default: 240
|
||||
pub default_width: Option<f32>,
|
||||
pub default_width: Pixels,
|
||||
}
|
||||
|
||||
impl Default for CollaborationPanelSettings {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
button: true,
|
||||
dock: DockPosition::Left,
|
||||
default_width: px(240.),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize, Debug, JsonSchema, Serialize)]
|
||||
#[serde(default)]
|
||||
pub struct ChatPanelSettings {
|
||||
/// Whether to show the panel button in the status bar.
|
||||
pub button: bool,
|
||||
/// Where to dock the panel.
|
||||
pub dock: DockPosition,
|
||||
/// Default width of the panel in pixels.
|
||||
pub default_width: Pixels,
|
||||
}
|
||||
|
||||
impl Default for ChatPanelSettings {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
button: true,
|
||||
dock: DockPosition::Right,
|
||||
default_width: px(240.),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize, Debug, JsonSchema, Serialize)]
|
||||
#[serde(default)]
|
||||
pub struct NotificationPanelSettings {
|
||||
/// Whether to show the panel button in the status bar.
|
||||
pub button: bool,
|
||||
/// Where to dock the panel.
|
||||
pub dock: DockPosition,
|
||||
/// Default width of the panel in pixels.
|
||||
pub default_width: Pixels,
|
||||
}
|
||||
|
||||
impl Default for NotificationPanelSettings {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
button: true,
|
||||
dock: DockPosition::Right,
|
||||
default_width: px(380.),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, Debug)]
|
||||
#[serde(default)]
|
||||
pub struct MessageEditorSettings {
|
||||
/// Whether to automatically replace emoji shortcodes with emoji characters.
|
||||
/// For example: typing `:wave:` gets replaced with `👋`.
|
||||
///
|
||||
/// Default: false
|
||||
pub auto_replace_emoji_shortcode: Option<bool>,
|
||||
pub auto_replace_emoji_shortcode: bool,
|
||||
}
|
||||
|
||||
impl Settings for CollaborationPanelSettings {
|
||||
const KEY: Option<&'static str> = Some("collaboration_panel");
|
||||
|
||||
type FileContent = PanelSettingsContent;
|
||||
type FileContent = Self;
|
||||
|
||||
fn load(
|
||||
sources: SettingsSources<Self::FileContent>,
|
||||
|
@ -66,7 +92,7 @@ impl Settings for CollaborationPanelSettings {
|
|||
impl Settings for ChatPanelSettings {
|
||||
const KEY: Option<&'static str> = Some("chat_panel");
|
||||
|
||||
type FileContent = PanelSettingsContent;
|
||||
type FileContent = Self;
|
||||
|
||||
fn load(
|
||||
sources: SettingsSources<Self::FileContent>,
|
||||
|
@ -79,7 +105,7 @@ impl Settings for ChatPanelSettings {
|
|||
impl Settings for NotificationPanelSettings {
|
||||
const KEY: Option<&'static str> = Some("notification_panel");
|
||||
|
||||
type FileContent = PanelSettingsContent;
|
||||
type FileContent = Self;
|
||||
|
||||
fn load(
|
||||
sources: SettingsSources<Self::FileContent>,
|
||||
|
@ -92,7 +118,7 @@ impl Settings for NotificationPanelSettings {
|
|||
impl Settings for MessageEditorSettings {
|
||||
const KEY: Option<&'static str> = Some("message_editor");
|
||||
|
||||
type FileContent = MessageEditorSettings;
|
||||
type FileContent = Self;
|
||||
|
||||
fn load(
|
||||
sources: SettingsSources<Self::FileContent>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue