panel_settings.rs

  1use gpui::Pixels;
  2use schemars::JsonSchema;
  3use serde::{Deserialize, Serialize};
  4use settings::{Settings, SettingsSources};
  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)]
 31pub struct ChatPanelSettingsContent {
 32    /// When to show the panel button in the status bar.
 33    ///
 34    /// Default: only when in a call
 35    pub button: Option<ChatPanelButton>,
 36    /// Where to dock the panel.
 37    ///
 38    /// Default: right
 39    pub dock: Option<DockPosition>,
 40    /// Default width of the panel in pixels.
 41    ///
 42    /// Default: 240
 43    pub default_width: Option<f32>,
 44}
 45
 46#[derive(Deserialize, Debug)]
 47pub struct NotificationPanelSettings {
 48    pub button: bool,
 49    pub dock: DockPosition,
 50    pub default_width: Pixels,
 51}
 52
 53#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, Debug)]
 54pub struct PanelSettingsContent {
 55    /// Whether to show the panel button in the status bar.
 56    ///
 57    /// Default: true
 58    pub button: Option<bool>,
 59    /// Where to dock the panel.
 60    ///
 61    /// Default: left
 62    pub dock: Option<DockPosition>,
 63    /// Default width of the panel in pixels.
 64    ///
 65    /// Default: 240
 66    pub default_width: Option<f32>,
 67}
 68
 69#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, Debug)]
 70pub struct MessageEditorSettings {
 71    /// Whether to automatically replace emoji shortcodes with emoji characters.
 72    /// For example: typing `:wave:` gets replaced with `👋`.
 73    ///
 74    /// Default: false
 75    pub auto_replace_emoji_shortcode: Option<bool>,
 76}
 77
 78impl Settings for CollaborationPanelSettings {
 79    const KEY: Option<&'static str> = Some("collaboration_panel");
 80
 81    type FileContent = PanelSettingsContent;
 82
 83    fn load(
 84        sources: SettingsSources<Self::FileContent>,
 85        _: &mut gpui::App,
 86    ) -> anyhow::Result<Self> {
 87        sources.json_merge()
 88    }
 89}
 90
 91impl Settings for ChatPanelSettings {
 92    const KEY: Option<&'static str> = Some("chat_panel");
 93
 94    type FileContent = ChatPanelSettingsContent;
 95
 96    fn load(
 97        sources: SettingsSources<Self::FileContent>,
 98        _: &mut gpui::App,
 99    ) -> anyhow::Result<Self> {
100        sources.json_merge()
101    }
102}
103
104impl Settings for NotificationPanelSettings {
105    const KEY: Option<&'static str> = Some("notification_panel");
106
107    type FileContent = PanelSettingsContent;
108
109    fn load(
110        sources: SettingsSources<Self::FileContent>,
111        _: &mut gpui::App,
112    ) -> anyhow::Result<Self> {
113        sources.json_merge()
114    }
115}
116
117impl Settings for MessageEditorSettings {
118    const KEY: Option<&'static str> = Some("message_editor");
119
120    type FileContent = MessageEditorSettings;
121
122    fn load(
123        sources: SettingsSources<Self::FileContent>,
124        _: &mut gpui::App,
125    ) -> anyhow::Result<Self> {
126        sources.json_merge()
127    }
128}