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(Deserialize, Debug, SettingsKey)]
 48#[settings_key(key = "notification_panel")]
 49pub struct NotificationPanelSettings {
 50    pub button: bool,
 51    pub dock: DockPosition,
 52    pub default_width: Pixels,
 53}
 54
 55#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, Debug, SettingsUi, SettingsKey)]
 56#[settings_key(key = "collaboration_panel")]
 57pub struct PanelSettingsContent {
 58    /// Whether to show the panel button in the status bar.
 59    ///
 60    /// Default: true
 61    pub button: Option<bool>,
 62    /// Where to dock the panel.
 63    ///
 64    /// Default: left
 65    pub dock: Option<DockPosition>,
 66    /// Default width of the panel in pixels.
 67    ///
 68    /// Default: 240
 69    pub default_width: Option<f32>,
 70}
 71
 72#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, Debug, SettingsUi, SettingsKey)]
 73#[settings_key(key = "message_editor")]
 74pub struct MessageEditorSettings {
 75    /// Whether to automatically replace emoji shortcodes with emoji characters.
 76    /// For example: typing `:wave:` gets replaced with `👋`.
 77    ///
 78    /// Default: false
 79    pub auto_replace_emoji_shortcode: Option<bool>,
 80}
 81
 82impl Settings for CollaborationPanelSettings {
 83    type FileContent = PanelSettingsContent;
 84
 85    fn load(
 86        sources: SettingsSources<Self::FileContent>,
 87        _: &mut gpui::App,
 88    ) -> anyhow::Result<Self> {
 89        sources.json_merge()
 90    }
 91
 92    fn import_from_vscode(_vscode: &settings::VsCodeSettings, _current: &mut Self::FileContent) {}
 93}
 94
 95impl Settings for ChatPanelSettings {
 96    type FileContent = ChatPanelSettingsContent;
 97
 98    fn load(
 99        sources: SettingsSources<Self::FileContent>,
100        _: &mut gpui::App,
101    ) -> anyhow::Result<Self> {
102        sources.json_merge()
103    }
104
105    fn import_from_vscode(_vscode: &settings::VsCodeSettings, _current: &mut Self::FileContent) {}
106}
107
108impl Settings for NotificationPanelSettings {
109    type FileContent = PanelSettingsContent;
110
111    fn load(
112        sources: SettingsSources<Self::FileContent>,
113        _: &mut gpui::App,
114    ) -> anyhow::Result<Self> {
115        sources.json_merge()
116    }
117
118    fn import_from_vscode(_vscode: &settings::VsCodeSettings, _current: &mut Self::FileContent) {}
119}
120
121impl Settings for MessageEditorSettings {
122    type FileContent = MessageEditorSettings;
123
124    fn load(
125        sources: SettingsSources<Self::FileContent>,
126        _: &mut gpui::App,
127    ) -> anyhow::Result<Self> {
128        sources.json_merge()
129    }
130
131    fn import_from_vscode(_vscode: &settings::VsCodeSettings, _current: &mut Self::FileContent) {}
132}