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)]
22// todo! are these settings even relevant any more?
23pub struct MessageEditorSettings {
24 /// Whether to automatically replace emoji shortcodes with emoji characters.
25 /// For example: typing `:wave:` gets replaced with `👋`.
26 ///
27 /// Default: false
28 pub auto_replace_emoji_shortcode: bool,
29}
30
31impl Settings for CollaborationPanelSettings {
32 fn from_defaults(content: &settings::SettingsContent, _cx: &mut ui::App) -> Self {
33 let panel = content.collaboration_panel.as_ref().unwrap();
34
35 Self {
36 button: panel.button.unwrap(),
37 dock: panel.dock.unwrap().into(),
38 default_width: panel.default_width.map(px).unwrap(),
39 }
40 }
41
42 fn refine(&mut self, content: &settings::SettingsContent, _cx: &mut ui::App) {
43 if let Some(panel) = content.collaboration_panel.as_ref() {
44 self.button.merge_from(&panel.button);
45 self.default_width
46 .merge_from(&panel.default_width.map(Pixels::from));
47 self.dock.merge_from(&panel.dock.map(Into::into));
48 }
49 }
50
51 fn import_from_vscode(
52 _vscode: &settings::VsCodeSettings,
53 _content: &mut settings::SettingsContent,
54 ) {
55 }
56}
57
58impl Settings for NotificationPanelSettings {
59 fn from_defaults(content: &settings::SettingsContent, _cx: &mut ui::App) -> Self {
60 let panel = content.notification_panel.as_ref().unwrap();
61 return Self {
62 button: panel.button.unwrap(),
63 dock: panel.dock.unwrap().into(),
64 default_width: panel.default_width.map(px).unwrap(),
65 };
66 }
67
68 fn refine(&mut self, content: &settings::SettingsContent, _cx: &mut ui::App) {
69 let Some(panel) = content.notification_panel.as_ref() else {
70 return;
71 };
72 self.button.merge_from(&panel.button);
73 self.dock.merge_from(&panel.dock.map(Into::into));
74 self.default_width.merge_from(&panel.default_width.map(px));
75 }
76
77 fn import_from_vscode(
78 _vscode: &settings::VsCodeSettings,
79 _current: &mut settings::SettingsContent,
80 ) {
81 }
82}
83
84impl Settings for MessageEditorSettings {
85 fn from_defaults(content: &settings::SettingsContent, _cx: &mut ui::App) -> Self {
86 let messages = content.message_editor.as_ref().unwrap();
87 Self {
88 auto_replace_emoji_shortcode: messages.auto_replace_emoji_shortcode.unwrap(),
89 }
90 }
91
92 fn refine(&mut self, content: &settings::SettingsContent, _cx: &mut ui::App) {
93 let Some(messages) = content.message_editor.as_ref() else {
94 return;
95 };
96 self.auto_replace_emoji_shortcode
97 .merge_from(&messages.auto_replace_emoji_shortcode);
98 }
99
100 fn import_from_vscode(
101 _vscode: &settings::VsCodeSettings,
102 _current: &mut settings::SettingsContent,
103 ) {
104 }
105}