1use gpui::Pixels;
2use settings::Settings;
3use ui::px;
4use util::MergeFrom as _;
5use workspace::dock::DockPosition;
6
7#[derive(Debug)]
8pub struct CollaborationPanelSettings {
9 pub button: bool,
10 pub dock: DockPosition,
11 pub default_width: Pixels,
12}
13
14#[derive(Debug)]
15pub struct NotificationPanelSettings {
16 pub button: bool,
17 pub dock: DockPosition,
18 pub default_width: Pixels,
19}
20
21#[derive(Clone, Default, Debug)]
22pub struct MessageEditorSettings {
23 /// Whether to automatically replace emoji shortcodes with emoji characters.
24 /// For example: typing `:wave:` gets replaced with `👋`.
25 ///
26 /// Default: false
27 pub auto_replace_emoji_shortcode: bool,
28}
29
30impl Settings for CollaborationPanelSettings {
31 fn from_defaults(content: &settings::SettingsContent, _cx: &mut ui::App) -> Self {
32 let panel = content.collaboration_panel.as_ref().unwrap();
33
34 Self {
35 button: panel.button.unwrap(),
36 dock: panel.dock.unwrap().into(),
37 default_width: panel.default_width.map(px).unwrap(),
38 }
39 }
40
41 fn refine(&mut self, content: &settings::SettingsContent, _cx: &mut ui::App) {
42 if let Some(panel) = content.collaboration_panel.as_ref() {
43 self.button.merge_from(&panel.button);
44 self.default_width
45 .merge_from(&panel.default_width.map(Pixels::from));
46 self.dock.merge_from(&panel.dock.map(Into::into));
47 }
48 }
49
50 fn import_from_vscode(
51 _vscode: &settings::VsCodeSettings,
52 _content: &mut settings::SettingsContent,
53 ) {
54 }
55}
56
57impl Settings for NotificationPanelSettings {
58 fn from_defaults(content: &settings::SettingsContent, _cx: &mut ui::App) -> Self {
59 let panel = content.notification_panel.as_ref().unwrap();
60 return Self {
61 button: panel.button.unwrap(),
62 dock: panel.dock.unwrap().into(),
63 default_width: panel.default_width.map(px).unwrap(),
64 };
65 }
66
67 fn refine(&mut self, content: &settings::SettingsContent, _cx: &mut ui::App) {
68 let Some(panel) = content.notification_panel.as_ref() else {
69 return;
70 };
71 self.button.merge_from(&panel.button);
72 self.dock.merge_from(&panel.dock.map(Into::into));
73 self.default_width.merge_from(&panel.default_width.map(px));
74 }
75
76 fn import_from_vscode(
77 _vscode: &settings::VsCodeSettings,
78 _current: &mut settings::SettingsContent,
79 ) {
80 }
81}
82
83impl Settings for MessageEditorSettings {
84 fn from_defaults(content: &settings::SettingsContent, _cx: &mut ui::App) -> Self {
85 let messages = content.message_editor.as_ref().unwrap();
86 Self {
87 auto_replace_emoji_shortcode: messages.auto_replace_emoji_shortcode.unwrap(),
88 }
89 }
90
91 fn refine(&mut self, content: &settings::SettingsContent, _cx: &mut ui::App) {
92 let Some(messages) = content.message_editor.as_ref() else {
93 return;
94 };
95 self.auto_replace_emoji_shortcode
96 .merge_from(&messages.auto_replace_emoji_shortcode);
97 }
98
99 fn import_from_vscode(
100 _vscode: &settings::VsCodeSettings,
101 _current: &mut settings::SettingsContent,
102 ) {
103 }
104}