zed/crates/collab_ui/src/panel_settings.rs

80 lines
2.2 KiB
Rust
Raw Normal View History

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