2023-07-19 01:55:54 +00:00
|
|
|
use anyhow;
|
2024-01-03 18:30:52 +00:00
|
|
|
use gpui::Pixels;
|
2023-07-19 01:55:54 +00:00
|
|
|
use schemars::JsonSchema;
|
|
|
|
use serde_derive::{Deserialize, Serialize};
|
2024-01-03 18:30:52 +00:00
|
|
|
use settings::Settings;
|
2023-09-08 20:28:19 +00:00
|
|
|
use workspace::dock::DockPosition;
|
2023-07-19 01:55:54 +00:00
|
|
|
|
2023-09-08 20:28:19 +00:00
|
|
|
#[derive(Deserialize, Debug)]
|
|
|
|
pub struct CollaborationPanelSettings {
|
|
|
|
pub button: bool,
|
|
|
|
pub dock: DockPosition,
|
2024-01-03 18:30:52 +00:00
|
|
|
pub default_width: Pixels,
|
2023-07-19 01:55:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Deserialize, Debug)]
|
2023-09-08 20:28:19 +00:00
|
|
|
pub struct ChatPanelSettings {
|
2023-08-07 23:27:47 +00:00
|
|
|
pub button: bool,
|
2023-09-08 20:28:19 +00:00
|
|
|
pub dock: DockPosition,
|
2024-01-03 18:30:52 +00:00
|
|
|
pub default_width: Pixels,
|
2023-07-19 01:55:54 +00:00
|
|
|
}
|
|
|
|
|
2023-10-06 19:56:18 +00:00
|
|
|
#[derive(Deserialize, Debug)]
|
|
|
|
pub struct NotificationPanelSettings {
|
|
|
|
pub button: bool,
|
|
|
|
pub dock: DockPosition,
|
2024-01-03 18:30:52 +00:00
|
|
|
pub default_width: Pixels,
|
2023-10-06 19:56:18 +00:00
|
|
|
}
|
|
|
|
|
2023-07-19 01:55:54 +00:00
|
|
|
#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, Debug)]
|
2023-09-08 20:28:19 +00:00
|
|
|
pub struct PanelSettingsContent {
|
2024-01-08 18:30:18 +00:00
|
|
|
/// Whether to show the panel button in the status bar.
|
|
|
|
///
|
|
|
|
/// Default: true
|
2023-08-07 23:27:47 +00:00
|
|
|
pub button: Option<bool>,
|
2024-01-08 18:30:18 +00:00
|
|
|
/// Where to dock the panel.
|
|
|
|
///
|
|
|
|
/// Default: left
|
2023-09-08 20:28:19 +00:00
|
|
|
pub dock: Option<DockPosition>,
|
2024-01-08 18:30:18 +00:00
|
|
|
/// Default width of the panel in pixels.
|
|
|
|
///
|
|
|
|
/// Default: 240
|
2023-07-19 01:55:54 +00:00
|
|
|
pub default_width: Option<f32>,
|
|
|
|
}
|
|
|
|
|
2024-01-03 18:30:52 +00:00
|
|
|
impl Settings for CollaborationPanelSettings {
|
2023-08-07 23:27:47 +00:00
|
|
|
const KEY: Option<&'static str> = Some("collaboration_panel");
|
2023-09-08 20:28:19 +00:00
|
|
|
type FileContent = PanelSettingsContent;
|
|
|
|
fn load(
|
|
|
|
default_value: &Self::FileContent,
|
|
|
|
user_values: &[&Self::FileContent],
|
2024-01-03 18:30:52 +00:00
|
|
|
_: &mut gpui::AppContext,
|
2023-09-08 20:28:19 +00:00
|
|
|
) -> anyhow::Result<Self> {
|
|
|
|
Self::load_via_json_merge(default_value, user_values)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-03 18:30:52 +00:00
|
|
|
impl Settings for ChatPanelSettings {
|
2023-09-08 20:28:19 +00:00
|
|
|
const KEY: Option<&'static str> = Some("chat_panel");
|
|
|
|
type FileContent = PanelSettingsContent;
|
2023-10-06 19:56:18 +00:00
|
|
|
fn load(
|
|
|
|
default_value: &Self::FileContent,
|
|
|
|
user_values: &[&Self::FileContent],
|
2024-01-03 18:30:52 +00:00
|
|
|
_: &mut gpui::AppContext,
|
2023-10-06 19:56:18 +00:00
|
|
|
) -> anyhow::Result<Self> {
|
|
|
|
Self::load_via_json_merge(default_value, user_values)
|
|
|
|
}
|
|
|
|
}
|
2023-07-19 01:55:54 +00:00
|
|
|
|
2024-01-03 18:30:52 +00:00
|
|
|
impl Settings for NotificationPanelSettings {
|
2023-10-06 19:56:18 +00:00
|
|
|
const KEY: Option<&'static str> = Some("notification_panel");
|
|
|
|
type FileContent = PanelSettingsContent;
|
2023-07-19 01:55:54 +00:00
|
|
|
fn load(
|
|
|
|
default_value: &Self::FileContent,
|
|
|
|
user_values: &[&Self::FileContent],
|
2024-01-03 18:30:52 +00:00
|
|
|
_: &mut gpui::AppContext,
|
2023-07-19 01:55:54 +00:00
|
|
|
) -> anyhow::Result<Self> {
|
|
|
|
Self::load_via_json_merge(default_value, user_values)
|
|
|
|
}
|
|
|
|
}
|