panel_settings.rs

  1use gpui::Pixels;
  2use schemars::JsonSchema;
  3use serde::{Deserialize, Serialize};
  4use settings::{Settings, SettingsKey, SettingsSources, SettingsUi};
  5use workspace::dock::DockPosition;
  6
  7#[derive(Deserialize, Debug)]
  8pub struct CollaborationPanelSettings {
  9    pub button: bool,
 10    pub dock: DockPosition,
 11    pub default_width: Pixels,
 12}
 13
 14#[derive(Clone, Copy, Default, Serialize, Deserialize, JsonSchema, Debug)]
 15#[serde(rename_all = "snake_case")]
 16pub enum ChatPanelButton {
 17    Never,
 18    Always,
 19    #[default]
 20    WhenInCall,
 21}
 22
 23#[derive(Deserialize, Debug)]
 24pub struct ChatPanelSettings {
 25    pub button: ChatPanelButton,
 26    pub dock: DockPosition,
 27    pub default_width: Pixels,
 28}
 29
 30#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, Debug, SettingsUi, SettingsKey)]
 31#[settings_key(key = "chat_panel")]
 32pub struct ChatPanelSettingsContent {
 33    /// When to show the panel button in the status bar.
 34    ///
 35    /// Default: only when in a call
 36    pub button: Option<ChatPanelButton>,
 37    /// Where to dock the panel.
 38    ///
 39    /// Default: right
 40    pub dock: Option<DockPosition>,
 41    /// Default width of the panel in pixels.
 42    ///
 43    /// Default: 240
 44    pub default_width: Option<f32>,
 45}
 46
 47#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, Debug, SettingsUi, SettingsKey)]
 48#[settings_key(key = "collaboration_panel")]
 49pub struct PanelSettingsContent {
 50    /// Whether to show the panel button in the status bar.
 51    ///
 52    /// Default: true
 53    pub button: Option<bool>,
 54    /// Where to dock the panel.
 55    ///
 56    /// Default: left
 57    pub dock: Option<DockPosition>,
 58    /// Default width of the panel in pixels.
 59    ///
 60    /// Default: 240
 61    pub default_width: Option<f32>,
 62}
 63
 64#[derive(Deserialize, Debug)]
 65pub struct NotificationPanelSettings {
 66    pub button: bool,
 67    pub dock: DockPosition,
 68    pub default_width: Pixels,
 69}
 70
 71#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, Debug, SettingsUi, SettingsKey)]
 72#[settings_key(key = "notification_panel")]
 73pub struct NotificationPanelSettingsContent {
 74    /// Whether to show the panel button in the status bar.
 75    ///
 76    /// Default: true
 77    pub button: Option<bool>,
 78    /// Where to dock the panel.
 79    ///
 80    /// Default: right
 81    pub dock: Option<DockPosition>,
 82    /// Default width of the panel in pixels.
 83    ///
 84    /// Default: 300
 85    pub default_width: Option<f32>,
 86}
 87
 88#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, Debug, SettingsUi, SettingsKey)]
 89#[settings_key(key = "message_editor")]
 90pub struct MessageEditorSettings {
 91    /// Whether to automatically replace emoji shortcodes with emoji characters.
 92    /// For example: typing `:wave:` gets replaced with `👋`.
 93    ///
 94    /// Default: false
 95    pub auto_replace_emoji_shortcode: Option<bool>,
 96}
 97
 98impl Settings for CollaborationPanelSettings {
 99    type FileContent = PanelSettingsContent;
100
101    fn load(
102        sources: SettingsSources<Self::FileContent>,
103        _: &mut gpui::App,
104    ) -> anyhow::Result<Self> {
105        sources.json_merge()
106    }
107
108    fn import_from_vscode(_vscode: &settings::VsCodeSettings, _current: &mut Self::FileContent) {}
109}
110
111impl Settings for ChatPanelSettings {
112    type FileContent = ChatPanelSettingsContent;
113
114    fn load(
115        sources: SettingsSources<Self::FileContent>,
116        _: &mut gpui::App,
117    ) -> anyhow::Result<Self> {
118        sources.json_merge()
119    }
120
121    fn import_from_vscode(_vscode: &settings::VsCodeSettings, _current: &mut Self::FileContent) {}
122}
123
124impl Settings for NotificationPanelSettings {
125    type FileContent = NotificationPanelSettingsContent;
126
127    fn load(
128        sources: SettingsSources<Self::FileContent>,
129        _: &mut gpui::App,
130    ) -> anyhow::Result<Self> {
131        sources.json_merge()
132    }
133
134    fn import_from_vscode(_vscode: &settings::VsCodeSettings, _current: &mut Self::FileContent) {}
135}
136
137impl Settings for MessageEditorSettings {
138    type FileContent = MessageEditorSettings;
139
140    fn load(
141        sources: SettingsSources<Self::FileContent>,
142        _: &mut gpui::App,
143    ) -> anyhow::Result<Self> {
144        sources.json_merge()
145    }
146
147    fn import_from_vscode(_vscode: &settings::VsCodeSettings, _current: &mut Self::FileContent) {}
148}