BlueGit

ict rusty-teams

feat(settings): tray icon follows the app icon, own toggle to show it

- Replaces the tray icon choice from #66: the tray always shows the app icon
- Settings > General gets "Show icon in the tray"; off removes the tray, so closing the window quits the app
- "On close, keep the application running" only shows while the tray icon is on

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

metis Daniel Däschle · pushed by metis

Authored 2026-11-18 · 12 days ago

Hash
21da0e20bc1beee271cf8e299d1e9681692732d6
Parent
50da5d01
9 files changed +74 −181
crates/app-base/locales/app.yml +6 −12
@@ -464,6 +464,12 @@ settings:
464 464 open_in_background:
465 465 en: Open application in background
466 466 de: Anwendung im Hintergrund starten
467 show_in_tray:
468 en: Show icon in the tray
469 de: Symbol im Infobereich anzeigen
470 show_in_tray_detail:
471 en: In the macOS menu bar or the system tray. Without it, closing the window quits the app
472 de: In der macOS-Menüleiste oder im Infobereich der Taskleiste. Ohne Symbol beendet das Schliessen des Fensters die App
467 473 close_to_tray:
468 474 en: On close, keep the application running
469 475 de: Beim Schliessen Anwendung weiterlaufen lassen
@@ -613,18 +619,6 @@ settings:
613 619 app_icon_detail:
614 620 en: Shown in the title bar, taskbar and tray
615 621 de: In Titelleiste, Taskleiste und Infobereich
616 tray_icon:
617 en: Menu bar and tray icon
618 de: Symbol in Menüleiste und Infobereich
619 tray_icon_detail:
620 en: Shown in the macOS menu bar or the system tray. With None, closing the window quits the app
621 de: In der macOS-Menüleiste oder im Infobereich der Taskleiste. Mit Keines beendet das Schliessen des Fensters die App
622 tray_icon_same:
623 en: Same as app icon
624 de: Wie App-Symbol
625 tray_icon_none:
626 en: None
627 de: Keines
628 622 language:
629 623 title:
630 624 en: Language
@@ -464,6 +464,12 @@ settings:
464 open_in_background:
464 open_in_background:
465 en: Open application in background
465 en: Open application in background
466 de: Anwendung im Hintergrund starten
466 de: Anwendung im Hintergrund starten
467 show_in_tray:
468 en: Show icon in the tray
469 de: Symbol im Infobereich anzeigen
470 show_in_tray_detail:
471 en: In the macOS menu bar or the system tray. Without it, closing the window quits the app
472 de: In der macOS-Menüleiste oder im Infobereich der Taskleiste. Ohne Symbol beendet das Schliessen des Fensters die App
467 close_to_tray:
473 close_to_tray:
468 en: On close, keep the application running
474 en: On close, keep the application running
469 de: Beim Schliessen Anwendung weiterlaufen lassen
475 de: Beim Schliessen Anwendung weiterlaufen lassen
@@ -613,18 +619,6 @@ settings:
613 app_icon_detail:
619 app_icon_detail:
614 en: Shown in the title bar, taskbar and tray
620 en: Shown in the title bar, taskbar and tray
615 de: In Titelleiste, Taskleiste und Infobereich
621 de: In Titelleiste, Taskleiste und Infobereich
616 tray_icon:
617 en: Menu bar and tray icon
618 de: Symbol in Menüleiste und Infobereich
619 tray_icon_detail:
620 en: Shown in the macOS menu bar or the system tray. With None, closing the window quits the app
621 de: In der macOS-Menüleiste oder im Infobereich der Taskleiste. Mit Keines beendet das Schliessen des Fensters die App
622 tray_icon_same:
623 en: Same as app icon
624 de: Wie App-Symbol
625 tray_icon_none:
626 en: None
627 de: Keines
628 language:
622 language:
629 title:
623 title:
630 en: Language
624 en: Language
crates/app-base/src/appearance.rs +1 −68
@@ -5,7 +5,6 @@ use crate::theme::{self, ColorScheme, Shade};
5 5 const META_KEY: &str = "appearance.settings";
6 6 const COLOR_SCHEME_KEY: &str = "color_scheme";
7 7 const APP_ICON_KEY: &str = "app_icon";
8 const TRAY_ICON_KEY: &str = "tray_icon";
9 8 const THEME_KEY: &str = "theme";
10 9 const ZOOM_KEY: &str = "zoom";
11 10 pub const ZOOM_STEPS: [f32; 14] = [
@@ -52,39 +51,6 @@ impl AppIcon {
52 51 }
53 52 }
54 53
55 /// What the menu bar or system tray shows.
56 #[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
57 pub enum TrayIconChoice {
58 #[default]
59 SameAsApp,
60 Icon(AppIcon),
61 /// No tray entry at all, so closing the main window quits the app.
62 Hidden,
63 }
64
65 impl TrayIconChoice {
66 pub const ALL: [TrayIconChoice; 4] = [
67 TrayIconChoice::SameAsApp,
68 TrayIconChoice::Icon(AppIcon::RustyTeams),
69 TrayIconChoice::Icon(AppIcon::MicrosoftTeams),
70 TrayIconChoice::Hidden,
71 ];
72
73 pub fn key(self) -> &'static str {
74 match self {
75 TrayIconChoice::SameAsApp => "same-as-app",
76 TrayIconChoice::Icon(icon) => icon.key(),
77 TrayIconChoice::Hidden => "none",
78 }
79 }
80
81 pub fn from_key(key: &str) -> Option<TrayIconChoice> {
82 TrayIconChoice::ALL
83 .into_iter()
84 .find(|choice| choice.key() == key)
85 }
86 }
87
88 54 #[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
89 55 pub enum ThemeChoice {
90 56 FollowOperatingSystem,
@@ -148,28 +114,15 @@ pub struct SystemTheme {
148 114 pub struct AppearanceSettings {
149 115 pub color_scheme: &'static ColorScheme,
150 116 pub app_icon: AppIcon,
151 pub tray_icon: TrayIconChoice,
152 117 pub theme: ThemeChoice,
153 118 pub zoom: f32,
154 119 }
155 120
156 impl AppearanceSettings {
157 /// The icon the tray shows, `None` when the tray is switched off.
158 pub fn shown_tray_icon(&self) -> Option<AppIcon> {
159 match self.tray_icon {
160 TrayIconChoice::SameAsApp => Some(self.app_icon),
161 TrayIconChoice::Icon(icon) => Some(icon),
162 TrayIconChoice::Hidden => None,
163 }
164 }
165 }
166
167 121 impl Default for AppearanceSettings {
168 122 fn default() -> Self {
169 123 AppearanceSettings {
170 124 color_scheme: theme::default_scheme(),
171 125 app_icon: AppIcon::default(),
172 tray_icon: TrayIconChoice::default(),
173 126 theme: ThemeChoice::default(),
174 127 zoom: DEFAULT_ZOOM,
175 128 }
@@ -243,10 +196,9 @@ pub fn save(store: &Store, settings: &AppearanceSettings) {
243 196
244 197 fn serialize(settings: &AppearanceSettings) -> String {
245 198 format!(
246 "{COLOR_SCHEME_KEY}={}\n{APP_ICON_KEY}={}\n{TRAY_ICON_KEY}={}\n{THEME_KEY}={}\n{ZOOM_KEY}={}",
199 "{COLOR_SCHEME_KEY}={}\n{APP_ICON_KEY}={}\n{THEME_KEY}={}\n{ZOOM_KEY}={}",
247 200 settings.color_scheme.id,
248 201 settings.app_icon.key(),
249 settings.tray_icon.key(),
250 202 settings.theme.key(),
251 203 settings.zoom
252 204 )
@@ -266,11 +218,6 @@ fn parse(text: &str) -> AppearanceSettings {
266 218 settings.app_icon = icon;
267 219 }
268 220 }
269 Some((TRAY_ICON_KEY, value)) => {
270 if let Some(choice) = TrayIconChoice::from_key(value) {
271 settings.tray_icon = choice;
272 }
273 }
274 221 Some((THEME_KEY, value)) => {
275 222 if let Some(choice) = ThemeChoice::from_key(value) {
276 223 settings.theme = choice;
@@ -305,7 +252,6 @@ mod tests {
305 252 let settings = AppearanceSettings {
306 253 color_scheme: theme::SCHEMES[1],
307 254 app_icon: AppIcon::MicrosoftTeams,
308 tray_icon: TrayIconChoice::Icon(AppIcon::RustyTeams),
309 255 theme: ThemeChoice::FollowOperatingSystem,
310 256 zoom: 1.25,
311 257 };
@@ -328,7 +274,6 @@ mod tests {
328 274 let changed = AppearanceSettings {
329 275 color_scheme: theme::scheme_by_id("teams").unwrap(),
330 276 app_icon: AppIcon::MicrosoftTeams,
331 tray_icon: TrayIconChoice::Hidden,
332 277 theme: ThemeChoice::Light,
333 278 zoom: 0.9,
334 279 };
@@ -344,18 +289,6 @@ mod tests {
344 289 assert_eq!(parse("zoom=1.3").zoom, 1.25);
345 290 }
346 291
347 #[test]
348 fn the_tray_icon_follows_the_app_icon_until_one_is_chosen() {
349 let following = parse("app_icon=microsoft-teams");
350 assert_eq!(following.tray_icon, TrayIconChoice::SameAsApp);
351 assert_eq!(following.shown_tray_icon(), Some(AppIcon::MicrosoftTeams));
352 let chosen = parse("app_icon=microsoft-teams\ntray_icon=rusty-teams");
353 assert_eq!(chosen.shown_tray_icon(), Some(AppIcon::RustyTeams));
354 let hidden = parse("app_icon=microsoft-teams\ntray_icon=none");
355 assert_eq!(hidden.shown_tray_icon(), None);
356 assert_eq!(parse(&serialize(&hidden)), hidden);
357 }
358
359 292 #[test]
360 293 fn follow_os_takes_dark_light_and_forced_contrast_from_the_system() {
361 294 let follow = ThemeChoice::FollowOperatingSystem;
@@ -5,7 +5,6 @@ use crate::theme::{self, ColorScheme, Shade};
5const META_KEY: &str = "appearance.settings";
5const META_KEY: &str = "appearance.settings";
6const COLOR_SCHEME_KEY: &str = "color_scheme";
6const COLOR_SCHEME_KEY: &str = "color_scheme";
7const APP_ICON_KEY: &str = "app_icon";
7const APP_ICON_KEY: &str = "app_icon";
8const TRAY_ICON_KEY: &str = "tray_icon";
9const THEME_KEY: &str = "theme";
8const THEME_KEY: &str = "theme";
10const ZOOM_KEY: &str = "zoom";
9const ZOOM_KEY: &str = "zoom";
11pub const ZOOM_STEPS: [f32; 14] = [
10pub const ZOOM_STEPS: [f32; 14] = [
@@ -52,39 +51,6 @@ impl AppIcon {
52 }
51 }
53}
52}
54
53
55/// What the menu bar or system tray shows.
56#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
57pub enum TrayIconChoice {
58 #[default]
59 SameAsApp,
60 Icon(AppIcon),
61 /// No tray entry at all, so closing the main window quits the app.
62 Hidden,
63}
64
65impl TrayIconChoice {
66 pub const ALL: [TrayIconChoice; 4] = [
67 TrayIconChoice::SameAsApp,
68 TrayIconChoice::Icon(AppIcon::RustyTeams),
69 TrayIconChoice::Icon(AppIcon::MicrosoftTeams),
70 TrayIconChoice::Hidden,
71 ];
72
73 pub fn key(self) -> &'static str {
74 match self {
75 TrayIconChoice::SameAsApp => "same-as-app",
76 TrayIconChoice::Icon(icon) => icon.key(),
77 TrayIconChoice::Hidden => "none",
78 }
79 }
80
81 pub fn from_key(key: &str) -> Option<TrayIconChoice> {
82 TrayIconChoice::ALL
83 .into_iter()
84 .find(|choice| choice.key() == key)
85 }
86}
87
88#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
54#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
89pub enum ThemeChoice {
55pub enum ThemeChoice {
90 FollowOperatingSystem,
56 FollowOperatingSystem,
@@ -148,28 +114,15 @@ pub struct SystemTheme {
148pub struct AppearanceSettings {
114pub struct AppearanceSettings {
149 pub color_scheme: &'static ColorScheme,
115 pub color_scheme: &'static ColorScheme,
150 pub app_icon: AppIcon,
116 pub app_icon: AppIcon,
151 pub tray_icon: TrayIconChoice,
152 pub theme: ThemeChoice,
117 pub theme: ThemeChoice,
153 pub zoom: f32,
118 pub zoom: f32,
154}
119}
155
120
156impl AppearanceSettings {
157 /// The icon the tray shows, `None` when the tray is switched off.
158 pub fn shown_tray_icon(&self) -> Option<AppIcon> {
159 match self.tray_icon {
160 TrayIconChoice::SameAsApp => Some(self.app_icon),
161 TrayIconChoice::Icon(icon) => Some(icon),
162 TrayIconChoice::Hidden => None,
163 }
164 }
165}
166
167impl Default for AppearanceSettings {
121impl Default for AppearanceSettings {
168 fn default() -> Self {
122 fn default() -> Self {
169 AppearanceSettings {
123 AppearanceSettings {
170 color_scheme: theme::default_scheme(),
124 color_scheme: theme::default_scheme(),
171 app_icon: AppIcon::default(),
125 app_icon: AppIcon::default(),
172 tray_icon: TrayIconChoice::default(),
173 theme: ThemeChoice::default(),
126 theme: ThemeChoice::default(),
174 zoom: DEFAULT_ZOOM,
127 zoom: DEFAULT_ZOOM,
175 }
128 }
@@ -243,10 +196,9 @@ pub fn save(store: &Store, settings: &AppearanceSettings) {
243
196
244fn serialize(settings: &AppearanceSettings) -> String {
197fn serialize(settings: &AppearanceSettings) -> String {
245 format!(
198 format!(
246 "{COLOR_SCHEME_KEY}={}\n{APP_ICON_KEY}={}\n{TRAY_ICON_KEY}={}\n{THEME_KEY}={}\n{ZOOM_KEY}={}",
199 "{COLOR_SCHEME_KEY}={}\n{APP_ICON_KEY}={}\n{THEME_KEY}={}\n{ZOOM_KEY}={}",
247 settings.color_scheme.id,
200 settings.color_scheme.id,
248 settings.app_icon.key(),
201 settings.app_icon.key(),
249 settings.tray_icon.key(),
250 settings.theme.key(),
202 settings.theme.key(),
251 settings.zoom
203 settings.zoom
252 )
204 )
@@ -266,11 +218,6 @@ fn parse(text: &str) -> AppearanceSettings {
266 settings.app_icon = icon;
218 settings.app_icon = icon;
267 }
219 }
268 }
220 }
269 Some((TRAY_ICON_KEY, value)) => {
270 if let Some(choice) = TrayIconChoice::from_key(value) {
271 settings.tray_icon = choice;
272 }
273 }
274 Some((THEME_KEY, value)) => {
221 Some((THEME_KEY, value)) => {
275 if let Some(choice) = ThemeChoice::from_key(value) {
222 if let Some(choice) = ThemeChoice::from_key(value) {
276 settings.theme = choice;
223 settings.theme = choice;
@@ -305,7 +252,6 @@ mod tests {
305 let settings = AppearanceSettings {
252 let settings = AppearanceSettings {
306 color_scheme: theme::SCHEMES[1],
253 color_scheme: theme::SCHEMES[1],
307 app_icon: AppIcon::MicrosoftTeams,
254 app_icon: AppIcon::MicrosoftTeams,
308 tray_icon: TrayIconChoice::Icon(AppIcon::RustyTeams),
309 theme: ThemeChoice::FollowOperatingSystem,
255 theme: ThemeChoice::FollowOperatingSystem,
310 zoom: 1.25,
256 zoom: 1.25,
311 };
257 };
@@ -328,7 +274,6 @@ mod tests {
328 let changed = AppearanceSettings {
274 let changed = AppearanceSettings {
329 color_scheme: theme::scheme_by_id("teams").unwrap(),
275 color_scheme: theme::scheme_by_id("teams").unwrap(),
330 app_icon: AppIcon::MicrosoftTeams,
276 app_icon: AppIcon::MicrosoftTeams,
331 tray_icon: TrayIconChoice::Hidden,
332 theme: ThemeChoice::Light,
277 theme: ThemeChoice::Light,
333 zoom: 0.9,
278 zoom: 0.9,
334 };
279 };
@@ -344,18 +289,6 @@ mod tests {
344 assert_eq!(parse("zoom=1.3").zoom, 1.25);
289 assert_eq!(parse("zoom=1.3").zoom, 1.25);
345 }
290 }
346
291
347 #[test]
348 fn the_tray_icon_follows_the_app_icon_until_one_is_chosen() {
349 let following = parse("app_icon=microsoft-teams");
350 assert_eq!(following.tray_icon, TrayIconChoice::SameAsApp);
351 assert_eq!(following.shown_tray_icon(), Some(AppIcon::MicrosoftTeams));
352 let chosen = parse("app_icon=microsoft-teams\ntray_icon=rusty-teams");
353 assert_eq!(chosen.shown_tray_icon(), Some(AppIcon::RustyTeams));
354 let hidden = parse("app_icon=microsoft-teams\ntray_icon=none");
355 assert_eq!(hidden.shown_tray_icon(), None);
356 assert_eq!(parse(&serialize(&hidden)), hidden);
357 }
358
359 #[test]
292 #[test]
360 fn follow_os_takes_dark_light_and_forced_contrast_from_the_system() {
293 fn follow_os_takes_dark_light_and_forced_contrast_from_the_system() {
361 let follow = ThemeChoice::FollowOperatingSystem;
294 let follow = ThemeChoice::FollowOperatingSystem;
crates/app-state/src/notify/rules.rs +2 −0
@@ -75,6 +75,7 @@ pub struct Settings {
75 75 pub account: NotificationAccountSettings,
76 76 pub corner: Corner,
77 77 pub flash: bool,
78 pub show_in_tray: bool,
78 79 pub close_to_tray: bool,
79 80 pub mute_in_calls: bool,
80 81 pub sounds: SoundSettings,
@@ -86,6 +87,7 @@ impl Default for Settings {
86 87 account: NotificationAccountSettings::default(),
87 88 corner: Corner::BottomRight,
88 89 flash: true,
90 show_in_tray: true,
89 91 close_to_tray: true,
90 92 mute_in_calls: false,
91 93 sounds: SoundSettings::default(),
@@ -75,6 +75,7 @@ pub struct Settings {
75 pub account: NotificationAccountSettings,
75 pub account: NotificationAccountSettings,
76 pub corner: Corner,
76 pub corner: Corner,
77 pub flash: bool,
77 pub flash: bool,
78 pub show_in_tray: bool,
78 pub close_to_tray: bool,
79 pub close_to_tray: bool,
79 pub mute_in_calls: bool,
80 pub mute_in_calls: bool,
80 pub sounds: SoundSettings,
81 pub sounds: SoundSettings,
@@ -86,6 +87,7 @@ impl Default for Settings {
86 account: NotificationAccountSettings::default(),
87 account: NotificationAccountSettings::default(),
87 corner: Corner::BottomRight,
88 corner: Corner::BottomRight,
88 flash: true,
89 flash: true,
90 show_in_tray: true,
89 close_to_tray: true,
91 close_to_tray: true,
90 mute_in_calls: false,
92 mute_in_calls: false,
91 sounds: SoundSettings::default(),
93 sounds: SoundSettings::default(),
crates/app-state/src/notify/settings.rs +3 −0
@@ -48,6 +48,7 @@ fn serialize(settings: &Settings) -> String {
48 48 ),
49 49 ("corner".to_owned(), settings.corner.key().to_owned()),
50 50 ("taskbar_flash".to_owned(), settings.flash.to_string()),
51 ("show_in_tray".to_owned(), settings.show_in_tray.to_string()),
51 52 (
52 53 "close_to_tray".to_owned(),
53 54 settings.close_to_tray.to_string(),
@@ -81,6 +82,7 @@ fn parse(text: &str) -> Settings {
81 82 "sound_when_busy" => sounds.sound_when_busy = flag,
82 83 "corner" => settings.corner = Corner::from_key(value).unwrap_or_default(),
83 84 "taskbar_flash" => settings.flash = flag,
85 "show_in_tray" => settings.show_in_tray = flag,
84 86 "close_to_tray" => settings.close_to_tray = flag,
85 87 "mute_in_calls" => settings.mute_in_calls = flag,
86 88 _ => set_ringtone(&mut sounds.ringtones, key, value),
@@ -115,6 +117,7 @@ mod tests {
115 117 account: Default::default(),
116 118 corner: Corner::TopLeft,
117 119 flash: false,
120 show_in_tray: false,
118 121 close_to_tray: false,
119 122 mute_in_calls: true,
120 123 sounds: SoundSettings {
@@ -48,6 +48,7 @@ fn serialize(settings: &Settings) -> String {
48 ),
48 ),
49 ("corner".to_owned(), settings.corner.key().to_owned()),
49 ("corner".to_owned(), settings.corner.key().to_owned()),
50 ("taskbar_flash".to_owned(), settings.flash.to_string()),
50 ("taskbar_flash".to_owned(), settings.flash.to_string()),
51 ("show_in_tray".to_owned(), settings.show_in_tray.to_string()),
51 (
52 (
52 "close_to_tray".to_owned(),
53 "close_to_tray".to_owned(),
53 settings.close_to_tray.to_string(),
54 settings.close_to_tray.to_string(),
@@ -81,6 +82,7 @@ fn parse(text: &str) -> Settings {
81 "sound_when_busy" => sounds.sound_when_busy = flag,
82 "sound_when_busy" => sounds.sound_when_busy = flag,
82 "corner" => settings.corner = Corner::from_key(value).unwrap_or_default(),
83 "corner" => settings.corner = Corner::from_key(value).unwrap_or_default(),
83 "taskbar_flash" => settings.flash = flag,
84 "taskbar_flash" => settings.flash = flag,
85 "show_in_tray" => settings.show_in_tray = flag,
84 "close_to_tray" => settings.close_to_tray = flag,
86 "close_to_tray" => settings.close_to_tray = flag,
85 "mute_in_calls" => settings.mute_in_calls = flag,
87 "mute_in_calls" => settings.mute_in_calls = flag,
86 _ => set_ringtone(&mut sounds.ringtones, key, value),
88 _ => set_ringtone(&mut sounds.ringtones, key, value),
@@ -115,6 +117,7 @@ mod tests {
115 account: Default::default(),
117 account: Default::default(),
116 corner: Corner::TopLeft,
118 corner: Corner::TopLeft,
117 flash: false,
119 flash: false,
120 show_in_tray: false,
118 close_to_tray: false,
121 close_to_tray: false,
119 mute_in_calls: true,
122 mute_in_calls: true,
120 sounds: SoundSettings {
123 sounds: SoundSettings {
crates/app/src/active_appearance.rs +1 −12
@@ -1,9 +1,7 @@
1 1 use gpui_kit::*;
2 2 use store::Store;
3 3
4 use crate::appearance::{
5 self, AppIcon, AppearanceSettings, SystemTheme, ThemeChoice, TrayIconChoice,
6 };
4 use crate::appearance::{self, AppIcon, AppearanceSettings, SystemTheme, ThemeChoice};
7 5 use crate::theme::{self, ColorScheme};
8 6 use crate::zoom;
9 7
@@ -101,15 +99,6 @@ pub fn set_app_icon(icon: AppIcon, store: &Store, cx: &mut App) {
101 99 cx.refresh_windows();
102 100 }
103 101
104 pub fn set_tray_icon(choice: TrayIconChoice, store: &Store, cx: &mut App) {
105 let settings = AppearanceSettings {
106 tray_icon: choice,
107 ..current(cx)
108 };
109 store_settings(settings, store, cx);
110 cx.refresh_windows();
111 }
112
113 102 pub fn set_zoom(zoom: f32, store: &Store, cx: &mut App) -> bool {
114 103 let current = current(cx);
115 104 if (current.zoom - zoom).abs() < f32::EPSILON {
@@ -1,9 +1,7 @@
1use gpui_kit::*;
1use gpui_kit::*;
2use store::Store;
2use store::Store;
3
3
4use crate::appearance::{
4use crate::appearance::{self, AppIcon, AppearanceSettings, SystemTheme, ThemeChoice};
5 self, AppIcon, AppearanceSettings, SystemTheme, ThemeChoice, TrayIconChoice,
6};
7use crate::theme::{self, ColorScheme};
5use crate::theme::{self, ColorScheme};
8use crate::zoom;
6use crate::zoom;
9
7
@@ -101,15 +99,6 @@ pub fn set_app_icon(icon: AppIcon, store: &Store, cx: &mut App) {
101 cx.refresh_windows();
99 cx.refresh_windows();
102}
100}
103
101
104pub fn set_tray_icon(choice: TrayIconChoice, store: &Store, cx: &mut App) {
105 let settings = AppearanceSettings {
106 tray_icon: choice,
107 ..current(cx)
108 };
109 store_settings(settings, store, cx);
110 cx.refresh_windows();
111}
112
113pub fn set_zoom(zoom: f32, store: &Store, cx: &mut App) -> bool {
102pub fn set_zoom(zoom: f32, store: &Store, cx: &mut App) -> bool {
114 let current = current(cx);
103 let current = current(cx);
115 if (current.zoom - zoom).abs() < f32::EPSILON {
104 if (current.zoom - zoom).abs() < f32::EPSILON {
crates/app/src/notify/center.rs +21 −32
@@ -43,7 +43,7 @@ use crate::activity::ActivityCenter;
43 43 use crate::agent_api::{self, pending::PendingProposal};
44 44 use crate::agents::{AgentRun, AgentRunsEvent, RunState};
45 45 use crate::app_state::{AppEvent, AppState, selection_for};
46 use crate::appearance::{AppIcon, AppearanceSettings};
46 use crate::appearance::AppIcon;
47 47 use crate::autostart::{self, StartupSettings};
48 48 use crate::call::DemoScene;
49 49 use crate::data::{self, Directory, PresenceKind};
@@ -126,7 +126,6 @@ pub struct NotificationCenter {
126 126 desktop_avatar_cache: HashMap<String, (u64, NotificationImage)>,
127 127 last_tray_presence: Option<TrayPresence>,
128 128 app_icon: AppIcon,
129 tray_icon: Option<AppIcon>,
130 129 shown_badge: Option<Badge>,
131 130 shown_mention_dot: bool,
132 131 animations: bool,
@@ -149,19 +148,17 @@ impl NotificationCenter {
149 148 ) -> Self {
150 149 let mut settings = settings::load(&app.read(cx).store);
151 150 settings.account = app.read(cx).account_chat_settings().notifications;
152 let appearance = active_appearance::current(cx);
153 let app_icon = appearance.app_icon;
154 let tray_icon = appearance.shown_tray_icon();
151 let app_icon = active_appearance::current(cx).app_icon;
155 152 let initial_presence = tray_presence_from(&app.read(cx), false);
156 let tray = if app.read(cx).mode.demo {
153 let tray = if app.read(cx).mode.demo || !settings.show_in_tray {
157 154 None
158 155 } else {
159 tray_icon.and_then(|icon| Tray::new(initial_presence.clone(), icon.png()))
156 Tray::new(initial_presence.clone(), app_icon.png())
160 157 };
161 158 let last_tray_presence = tray.as_ref().map(|_| initial_presence);
162 159 platform::set_window_icon(window, app_icon.png());
163 160 let appearance_observation = cx.observe_global::<ActiveAppearance>(|this, cx| {
164 this.apply_icons(active_appearance::current(cx), cx)
161 this.apply_app_icon(active_appearance::current(cx).app_icon, cx)
165 162 });
166 163 let locale_observation = cx.observe_global::<ActiveLocale>(|this, cx| {
167 164 // Locale changes the presence title; force a tray sync.
@@ -224,7 +221,6 @@ impl NotificationCenter {
224 221 desktop_avatar_cache: HashMap::new(),
225 222 last_tray_presence,
226 223 app_icon,
227 tray_icon,
228 224 shown_badge: None,
229 225 shown_mention_dot: false,
230 226 animations: platform::animations_enabled(),
@@ -394,6 +390,7 @@ impl NotificationCenter {
394 390 let previous = self.settings.sounds.clone();
395 391 change(&mut self.settings);
396 392 settings::save(&self.app.read(cx).store, &self.settings);
393 self.show_in_tray(self.settings.show_in_tray, cx);
397 394 self.sync_tray(cx);
398 395 if self.settings.sounds != previous {
399 396 let updated = self.settings.sounds.clone();
@@ -1584,36 +1581,28 @@ impl NotificationCenter {
1584 1581 .ok();
1585 1582 }
1586 1583
1587 fn apply_icons(&mut self, appearance: AppearanceSettings, cx: &mut Context<Self>) {
1588 let tray_icon = appearance.shown_tray_icon();
1589 if tray_icon != self.tray_icon {
1590 self.tray_icon = tray_icon;
1591 self.show_tray_icon(tray_icon, cx);
1584 fn apply_app_icon(&mut self, icon: AppIcon, cx: &mut Context<Self>) {
1585 if icon == self.app_icon {
1586 return;
1592 1587 }
1593 let app_icon = appearance.app_icon;
1594 if app_icon != self.app_icon {
1595 self.app_icon = app_icon;
1596 let _ = self.main_window.update(cx, |_, window, _| {
1597 platform::set_window_icon(window, app_icon.png())
1598 });
1588 self.app_icon = icon;
1589 let mention = !self.unread_mentions.is_empty();
1590 if let Some(tray) = &mut self.tray {
1591 tray.set_app_icon(icon.png(), mention);
1599 1592 }
1593 let _ = self.main_window.update(cx, |_, window, _| {
1594 platform::set_window_icon(window, icon.png())
1595 });
1600 1596 }
1601 1597
1602 /// Removes the tray for `None` and creates it again when an icon comes back.
1603 fn show_tray_icon(&mut self, icon: Option<AppIcon>, cx: &mut Context<Self>) {
1604 let Some(icon) = icon else {
1598 fn show_in_tray(&mut self, shown: bool, cx: &mut Context<Self>) {
1599 if !shown {
1605 1600 self.tray = None;
1606 1601 self.last_tray_presence = None;
1607 return;
1608 };
1609 let mention = !self.unread_mentions.is_empty();
1610 if let Some(tray) = &mut self.tray {
1611 tray.set_app_icon(icon.png(), mention);
1612 } else if !self.demo_mode {
1613 let presence = tray_presence_from(self.app.read(cx), mention);
1614 self.tray = Tray::new(presence, icon.png());
1602 } else if self.tray.is_none() && !self.demo_mode {
1603 let presence = tray_presence_from(self.app.read(cx), !self.unread_mentions.is_empty());
1604 self.tray = Tray::new(presence, self.app_icon.png());
1615 1605 self.last_tray_presence = None;
1616 self.sync_tray(cx);
1617 1606 }
1618 1607 }
1619 1608
@@ -43,7 +43,7 @@ use crate::activity::ActivityCenter;
43use crate::agent_api::{self, pending::PendingProposal};
43use crate::agent_api::{self, pending::PendingProposal};
44use crate::agents::{AgentRun, AgentRunsEvent, RunState};
44use crate::agents::{AgentRun, AgentRunsEvent, RunState};
45use crate::app_state::{AppEvent, AppState, selection_for};
45use crate::app_state::{AppEvent, AppState, selection_for};
46use crate::appearance::{AppIcon, AppearanceSettings};
46use crate::appearance::AppIcon;
47use crate::autostart::{self, StartupSettings};
47use crate::autostart::{self, StartupSettings};
48use crate::call::DemoScene;
48use crate::call::DemoScene;
49use crate::data::{self, Directory, PresenceKind};
49use crate::data::{self, Directory, PresenceKind};
@@ -126,7 +126,6 @@ pub struct NotificationCenter {
126 desktop_avatar_cache: HashMap<String, (u64, NotificationImage)>,
126 desktop_avatar_cache: HashMap<String, (u64, NotificationImage)>,
127 last_tray_presence: Option<TrayPresence>,
127 last_tray_presence: Option<TrayPresence>,
128 app_icon: AppIcon,
128 app_icon: AppIcon,
129 tray_icon: Option<AppIcon>,
130 shown_badge: Option<Badge>,
129 shown_badge: Option<Badge>,
131 shown_mention_dot: bool,
130 shown_mention_dot: bool,
132 animations: bool,
131 animations: bool,
@@ -149,19 +148,17 @@ impl NotificationCenter {
149 ) -> Self {
148 ) -> Self {
150 let mut settings = settings::load(&app.read(cx).store);
149 let mut settings = settings::load(&app.read(cx).store);
151 settings.account = app.read(cx).account_chat_settings().notifications;
150 settings.account = app.read(cx).account_chat_settings().notifications;
152 let appearance = active_appearance::current(cx);
151 let app_icon = active_appearance::current(cx).app_icon;
153 let app_icon = appearance.app_icon;
154 let tray_icon = appearance.shown_tray_icon();
155 let initial_presence = tray_presence_from(&app.read(cx), false);
152 let initial_presence = tray_presence_from(&app.read(cx), false);
156 let tray = if app.read(cx).mode.demo {
153 let tray = if app.read(cx).mode.demo || !settings.show_in_tray {
157 None
154 None
158 } else {
155 } else {
159 tray_icon.and_then(|icon| Tray::new(initial_presence.clone(), icon.png()))
156 Tray::new(initial_presence.clone(), app_icon.png())
160 };
157 };
161 let last_tray_presence = tray.as_ref().map(|_| initial_presence);
158 let last_tray_presence = tray.as_ref().map(|_| initial_presence);
162 platform::set_window_icon(window, app_icon.png());
159 platform::set_window_icon(window, app_icon.png());
163 let appearance_observation = cx.observe_global::<ActiveAppearance>(|this, cx| {
160 let appearance_observation = cx.observe_global::<ActiveAppearance>(|this, cx| {
164 this.apply_icons(active_appearance::current(cx), cx)
161 this.apply_app_icon(active_appearance::current(cx).app_icon, cx)
165 });
162 });
166 let locale_observation = cx.observe_global::<ActiveLocale>(|this, cx| {
163 let locale_observation = cx.observe_global::<ActiveLocale>(|this, cx| {
167 // Locale changes the presence title; force a tray sync.
164 // Locale changes the presence title; force a tray sync.
@@ -224,7 +221,6 @@ impl NotificationCenter {
224 desktop_avatar_cache: HashMap::new(),
221 desktop_avatar_cache: HashMap::new(),
225 last_tray_presence,
222 last_tray_presence,
226 app_icon,
223 app_icon,
227 tray_icon,
228 shown_badge: None,
224 shown_badge: None,
229 shown_mention_dot: false,
225 shown_mention_dot: false,
230 animations: platform::animations_enabled(),
226 animations: platform::animations_enabled(),
@@ -394,6 +390,7 @@ impl NotificationCenter {
394 let previous = self.settings.sounds.clone();
390 let previous = self.settings.sounds.clone();
395 change(&mut self.settings);
391 change(&mut self.settings);
396 settings::save(&self.app.read(cx).store, &self.settings);
392 settings::save(&self.app.read(cx).store, &self.settings);
393 self.show_in_tray(self.settings.show_in_tray, cx);
397 self.sync_tray(cx);
394 self.sync_tray(cx);
398 if self.settings.sounds != previous {
395 if self.settings.sounds != previous {
399 let updated = self.settings.sounds.clone();
396 let updated = self.settings.sounds.clone();
@@ -1584,36 +1581,28 @@ impl NotificationCenter {
1584 .ok();
1581 .ok();
1585 }
1582 }
1586
1583
1587 fn apply_icons(&mut self, appearance: AppearanceSettings, cx: &mut Context<Self>) {
1584 fn apply_app_icon(&mut self, icon: AppIcon, cx: &mut Context<Self>) {
1588 let tray_icon = appearance.shown_tray_icon();
1585 if icon == self.app_icon {
1589 if tray_icon != self.tray_icon {
1586 return;
1590 self.tray_icon = tray_icon;
1591 self.show_tray_icon(tray_icon, cx);
1592 }
1587 }
1593 let app_icon = appearance.app_icon;
1588 self.app_icon = icon;
1594 if app_icon != self.app_icon {
1589 let mention = !self.unread_mentions.is_empty();
1595 self.app_icon = app_icon;
1590 if let Some(tray) = &mut self.tray {
1596 let _ = self.main_window.update(cx, |_, window, _| {
1591 tray.set_app_icon(icon.png(), mention);
1597 platform::set_window_icon(window, app_icon.png())
1598 });
1599 }
1592 }
1593 let _ = self.main_window.update(cx, |_, window, _| {
1594 platform::set_window_icon(window, icon.png())
1595 });
1600 }
1596 }
1601
1597
1602 /// Removes the tray for `None` and creates it again when an icon comes back.
1598 fn show_in_tray(&mut self, shown: bool, cx: &mut Context<Self>) {
1603 fn show_tray_icon(&mut self, icon: Option<AppIcon>, cx: &mut Context<Self>) {
1599 if !shown {
1604 let Some(icon) = icon else {
1605 self.tray = None;
1600 self.tray = None;
1606 self.last_tray_presence = None;
1601 self.last_tray_presence = None;
1607 return;
1602 } else if self.tray.is_none() && !self.demo_mode {
1608 };
1603 let presence = tray_presence_from(self.app.read(cx), !self.unread_mentions.is_empty());
1609 let mention = !self.unread_mentions.is_empty();
1604 self.tray = Tray::new(presence, self.app_icon.png());
1610 if let Some(tray) = &mut self.tray {
1611 tray.set_app_icon(icon.png(), mention);
1612 } else if !self.demo_mode {
1613 let presence = tray_presence_from(self.app.read(cx), mention);
1614 self.tray = Tray::new(presence, icon.png());
1615 self.last_tray_presence = None;
1605 self.last_tray_presence = None;
1616 self.sync_tray(cx);
1617 }
1606 }
1618 }
1607 }
1619
1608
crates/app/src/settings/appearance.rs +2 −37
@@ -6,7 +6,7 @@ use super::rows::{Choice, ROW_INSET, caption, control_row, select_with_width, ti
6 6 use crate::active_appearance;
7 7 use crate::active_locale;
8 8 use crate::app_state::AppState;
9 use crate::appearance::{AppIcon, ThemeChoice, TrayIconChoice};
9 use crate::appearance::{AppIcon, ThemeChoice};
10 10 use crate::i18n::tr;
11 11 use crate::theme::{self, Palette};
12 12 use crate::views::title_bar::app_icon_image;
@@ -81,30 +81,6 @@ pub fn render(app: &Entity<AppState>, cx: &App) -> Div {
81 81 active_appearance::set_app_icon(icon, &store, cx);
82 82 })
83 83 });
84 let tray_tiles = TrayIconChoice::ALL.into_iter().map(|choice| {
85 let app = app.clone();
86 let (label, preview) = match choice {
87 TrayIconChoice::SameAsApp => (
88 SharedString::from(tr("settings.appearance.tray_icon_same")),
89 icon_preview(current.app_icon),
90 ),
91 TrayIconChoice::Icon(icon) => (SharedString::from(icon.label()), icon_preview(icon)),
92 TrayIconChoice::Hidden => (
93 SharedString::from(tr("settings.appearance.tray_icon_none")),
94 preview_frame(theme::background()),
95 ),
96 };
97 tile(
98 SharedString::from(format!("settings-tray-icon-{}", choice.key())),
99 label,
100 choice == current.tray_icon,
101 preview,
102 )
103 .on_click(move |_, _, cx| {
104 let store = app.read(cx).store.clone();
105 active_appearance::set_tray_icon(choice, &store, cx);
106 })
107 });
108 84 let theme_choices = ThemeChoice::ALL
109 85 .into_iter()
110 86 .map(|choice| {
@@ -154,11 +130,6 @@ pub fn render(app: &Entity<AppState>, cx: &App) -> Div {
154 130 app_icon_detail(),
155 131 icon_tiles,
156 132 ))
157 .child(choice_group(
158 tr("settings.appearance.tray_icon"),
159 tr("settings.appearance.tray_icon_detail"),
160 tray_tiles,
161 ))
162 133 }
163 134
164 135 fn choice_group(
@@ -181,13 +152,7 @@ fn choice_group(
181 152 )
182 153 }
183 154
184 fn tile(
185 id: SharedString,
186 label: impl Into<SharedString>,
187 selected: bool,
188 preview: Div,
189 ) -> Stateful<Div> {
190 let label = label.into();
155 fn tile(id: SharedString, label: &'static str, selected: bool, preview: Div) -> Stateful<Div> {
191 156 v_flex()
192 157 .id(id)
193 158 .w(px(TILE_WIDTH))
@@ -6,7 +6,7 @@ use super::rows::{Choice, ROW_INSET, caption, control_row, select_with_width, ti
6use crate::active_appearance;
6use crate::active_appearance;
7use crate::active_locale;
7use crate::active_locale;
8use crate::app_state::AppState;
8use crate::app_state::AppState;
9use crate::appearance::{AppIcon, ThemeChoice, TrayIconChoice};
9use crate::appearance::{AppIcon, ThemeChoice};
10use crate::i18n::tr;
10use crate::i18n::tr;
11use crate::theme::{self, Palette};
11use crate::theme::{self, Palette};
12use crate::views::title_bar::app_icon_image;
12use crate::views::title_bar::app_icon_image;
@@ -81,30 +81,6 @@ pub fn render(app: &Entity<AppState>, cx: &App) -> Div {
81 active_appearance::set_app_icon(icon, &store, cx);
81 active_appearance::set_app_icon(icon, &store, cx);
82 })
82 })
83 });
83 });
84 let tray_tiles = TrayIconChoice::ALL.into_iter().map(|choice| {
85 let app = app.clone();
86 let (label, preview) = match choice {
87 TrayIconChoice::SameAsApp => (
88 SharedString::from(tr("settings.appearance.tray_icon_same")),
89 icon_preview(current.app_icon),
90 ),
91 TrayIconChoice::Icon(icon) => (SharedString::from(icon.label()), icon_preview(icon)),
92 TrayIconChoice::Hidden => (
93 SharedString::from(tr("settings.appearance.tray_icon_none")),
94 preview_frame(theme::background()),
95 ),
96 };
97 tile(
98 SharedString::from(format!("settings-tray-icon-{}", choice.key())),
99 label,
100 choice == current.tray_icon,
101 preview,
102 )
103 .on_click(move |_, _, cx| {
104 let store = app.read(cx).store.clone();
105 active_appearance::set_tray_icon(choice, &store, cx);
106 })
107 });
108 let theme_choices = ThemeChoice::ALL
84 let theme_choices = ThemeChoice::ALL
109 .into_iter()
85 .into_iter()
110 .map(|choice| {
86 .map(|choice| {
@@ -154,11 +130,6 @@ pub fn render(app: &Entity<AppState>, cx: &App) -> Div {
154 app_icon_detail(),
130 app_icon_detail(),
155 icon_tiles,
131 icon_tiles,
156 ))
132 ))
157 .child(choice_group(
158 tr("settings.appearance.tray_icon"),
159 tr("settings.appearance.tray_icon_detail"),
160 tray_tiles,
161 ))
162}
133}
163
134
164fn choice_group(
135fn choice_group(
@@ -181,13 +152,7 @@ fn choice_group(
181 )
152 )
182}
153}
183
154
184fn tile(
155fn tile(id: SharedString, label: &'static str, selected: bool, preview: Div) -> Stateful<Div> {
185 id: SharedString,
186 label: impl Into<SharedString>,
187 selected: bool,
188 preview: Div,
189) -> Stateful<Div> {
190 let label = label.into();
191 v_flex()
156 v_flex()
192 .id(id)
157 .id(id)
193 .w(px(TILE_WIDTH))
158 .w(px(TILE_WIDTH))
crates/app/src/settings/general.rs +36 −18
@@ -14,6 +14,7 @@ use super::rows::{Choice, caption, control_row, select, toggle_row};
14 14 use crate::app_state::AppState;
15 15 use crate::i18n::tr;
16 16 use crate::notify::NotificationCenter;
17 use crate::notify::rules::Settings;
17 18 use crate::theme;
18 19 use crate::views::widgets::icon;
19 20
@@ -56,28 +57,33 @@ fn startup_rows(center: &Entity<NotificationCenter>, cx: &App) -> [Stateful<Div>
56 57 }
57 58
58 59 pub fn render(center: &Entity<NotificationCenter>, app: &Entity<AppState>, cx: &App) -> Div {
59 let close_to_tray = center.read(cx).settings().close_to_tray;
60 let toggle_center = center.clone();
60 let settings = center.read(cx).settings();
61 61 v_flex()
62 62 .w_full()
63 63 .child(caption(tr("settings.caption.system")))
64 64 .children(startup_rows(center, cx))
65 .child(
66 toggle_row(
67 "settings-close-to-tray",
68 tr("settings.general.close_to_tray"),
69 tr("settings.general.close_to_tray_detail"),
70 theme::text_muted(),
71 close_to_tray,
72 )
73 .on_click(move |_, _, cx| {
74 toggle_center.update(cx, |center, cx| {
75 center.update_settings(cx, |settings| {
76 settings.close_to_tray = !settings.close_to_tray
77 })
78 })
79 }),
80 )
65 .child(settings_toggle(
66 center,
67 (
68 "settings-show-in-tray",
69 tr("settings.general.show_in_tray"),
70 tr("settings.general.show_in_tray_detail"),
71 ),
72 settings.show_in_tray,
73 |settings| settings.show_in_tray = !settings.show_in_tray,
74 ))
75 .when(settings.show_in_tray, |rows| {
76 rows.child(settings_toggle(
77 center,
78 (
79 "settings-close-to-tray",
80 tr("settings.general.close_to_tray"),
81 tr("settings.general.close_to_tray_detail"),
82 ),
83 settings.close_to_tray,
84 |settings| settings.close_to_tray = !settings.close_to_tray,
85 ))
86 })
81 87 .children(external_browser_rows(app, cx))
82 88 .children(install_rows(cx))
83 89 .child(caption(tr("settings.caption.compose_box")))
@@ -96,6 +102,18 @@ pub fn render(center: &Entity<NotificationCenter>, app: &Entity<AppState>, cx: &
96 102 .children(translation_rows(app, cx))
97 103 }
98 104
105 fn settings_toggle(
106 center: &Entity<NotificationCenter>,
107 (id, title, detail): (&'static str, String, String),
108 enabled: bool,
109 change: fn(&mut Settings),
110 ) -> Stateful<Div> {
111 let center = center.clone();
112 toggle_row(id, title, detail, theme::text_muted(), enabled).on_click(move |_, _, cx| {
113 center.update(cx, |center, cx| center.update_settings(cx, change))
114 })
115 }
116
99 117 /// Linux only: the application menu install, the install question and updates.
100 118 fn install_rows(cx: &App) -> Vec<AnyElement> {
101 119 #[cfg(not(target_os = "linux"))]
@@ -14,6 +14,7 @@ use super::rows::{Choice, caption, control_row, select, toggle_row};
14use crate::app_state::AppState;
14use crate::app_state::AppState;
15use crate::i18n::tr;
15use crate::i18n::tr;
16use crate::notify::NotificationCenter;
16use crate::notify::NotificationCenter;
17use crate::notify::rules::Settings;
17use crate::theme;
18use crate::theme;
18use crate::views::widgets::icon;
19use crate::views::widgets::icon;
19
20
@@ -56,28 +57,33 @@ fn startup_rows(center: &Entity<NotificationCenter>, cx: &App) -> [Stateful<Div>
56}
57}
57
58
58pub fn render(center: &Entity<NotificationCenter>, app: &Entity<AppState>, cx: &App) -> Div {
59pub fn render(center: &Entity<NotificationCenter>, app: &Entity<AppState>, cx: &App) -> Div {
59 let close_to_tray = center.read(cx).settings().close_to_tray;
60 let settings = center.read(cx).settings();
60 let toggle_center = center.clone();
61 v_flex()
61 v_flex()
62 .w_full()
62 .w_full()
63 .child(caption(tr("settings.caption.system")))
63 .child(caption(tr("settings.caption.system")))
64 .children(startup_rows(center, cx))
64 .children(startup_rows(center, cx))
65 .child(
65 .child(settings_toggle(
66 toggle_row(
66 center,
67 "settings-close-to-tray",
67 (
68 tr("settings.general.close_to_tray"),
68 "settings-show-in-tray",
69 tr("settings.general.close_to_tray_detail"),
69 tr("settings.general.show_in_tray"),
70 theme::text_muted(),
70 tr("settings.general.show_in_tray_detail"),
71 close_to_tray,
71 ),
72 )
72 settings.show_in_tray,
73 .on_click(move |_, _, cx| {
73 |settings| settings.show_in_tray = !settings.show_in_tray,
74 toggle_center.update(cx, |center, cx| {
74 ))
75 center.update_settings(cx, |settings| {
75 .when(settings.show_in_tray, |rows| {
76 settings.close_to_tray = !settings.close_to_tray
76 rows.child(settings_toggle(
77 })
77 center,
78 })
78 (
79 }),
79 "settings-close-to-tray",
80 )
80 tr("settings.general.close_to_tray"),
81 tr("settings.general.close_to_tray_detail"),
82 ),
83 settings.close_to_tray,
84 |settings| settings.close_to_tray = !settings.close_to_tray,
85 ))
86 })
81 .children(external_browser_rows(app, cx))
87 .children(external_browser_rows(app, cx))
82 .children(install_rows(cx))
88 .children(install_rows(cx))
83 .child(caption(tr("settings.caption.compose_box")))
89 .child(caption(tr("settings.caption.compose_box")))
@@ -96,6 +102,18 @@ pub fn render(center: &Entity<NotificationCenter>, app: &Entity<AppState>, cx: &
96 .children(translation_rows(app, cx))
102 .children(translation_rows(app, cx))
97}
103}
98
104
105fn settings_toggle(
106 center: &Entity<NotificationCenter>,
107 (id, title, detail): (&'static str, String, String),
108 enabled: bool,
109 change: fn(&mut Settings),
110) -> Stateful<Div> {
111 let center = center.clone();
112 toggle_row(id, title, detail, theme::text_muted(), enabled).on_click(move |_, _, cx| {
113 center.update(cx, |center, cx| center.update_settings(cx, change))
114 })
115}
116
99/// Linux only: the application menu install, the install question and updates.
117/// Linux only: the application menu install, the install question and updates.
100fn install_rows(cx: &App) -> Vec<AnyElement> {
118fn install_rows(cx: &App) -> Vec<AnyElement> {
101 #[cfg(not(target_os = "linux"))]
119 #[cfg(not(target_os = "linux"))]
crates/app/src/settings/nav.rs +2 −2
@@ -53,6 +53,7 @@ fn search_terms(section: SettingsSection) -> Vec<String> {
53 53 SettingsSection::General => vec![
54 54 tr("settings.general.auto_start"),
55 55 tr("settings.general.open_in_background"),
56 tr("settings.general.show_in_tray"),
56 57 tr("settings.general.close_to_tray"),
57 58 tr("settings.general.external_browser"),
58 59 tr("settings.general.up_arrow"),
@@ -80,7 +81,6 @@ fn search_terms(section: SettingsSection) -> Vec<String> {
80 81 tr("settings.appearance.theme"),
81 82 tr("settings.appearance.color_scheme"),
82 83 tr("settings.appearance.app_icon"),
83 tr("settings.appearance.tray_icon"),
84 84 ],
85 85 SettingsSection::Chats => vec![
86 86 tr("settings.chats.density"),
@@ -407,6 +407,7 @@ mod tests {
407 407 SettingsSection::General => &[
408 408 "settings.general.auto_start",
409 409 "settings.general.open_in_background",
410 "settings.general.show_in_tray",
410 411 "settings.general.close_to_tray",
411 412 "settings.general.up_arrow",
412 413 "settings.general.translate_into",
@@ -430,7 +431,6 @@ mod tests {
430 431 "settings.appearance.theme",
431 432 "settings.appearance.color_scheme",
432 433 "settings.appearance.app_icon",
433 "settings.appearance.tray_icon",
434 434 ],
435 435 SettingsSection::Chats => &[
436 436 "settings.chats.density",
@@ -53,6 +53,7 @@ fn search_terms(section: SettingsSection) -> Vec<String> {
53 SettingsSection::General => vec![
53 SettingsSection::General => vec![
54 tr("settings.general.auto_start"),
54 tr("settings.general.auto_start"),
55 tr("settings.general.open_in_background"),
55 tr("settings.general.open_in_background"),
56 tr("settings.general.show_in_tray"),
56 tr("settings.general.close_to_tray"),
57 tr("settings.general.close_to_tray"),
57 tr("settings.general.external_browser"),
58 tr("settings.general.external_browser"),
58 tr("settings.general.up_arrow"),
59 tr("settings.general.up_arrow"),
@@ -80,7 +81,6 @@ fn search_terms(section: SettingsSection) -> Vec<String> {
80 tr("settings.appearance.theme"),
81 tr("settings.appearance.theme"),
81 tr("settings.appearance.color_scheme"),
82 tr("settings.appearance.color_scheme"),
82 tr("settings.appearance.app_icon"),
83 tr("settings.appearance.app_icon"),
83 tr("settings.appearance.tray_icon"),
84 ],
84 ],
85 SettingsSection::Chats => vec![
85 SettingsSection::Chats => vec![
86 tr("settings.chats.density"),
86 tr("settings.chats.density"),
@@ -407,6 +407,7 @@ mod tests {
407 SettingsSection::General => &[
407 SettingsSection::General => &[
408 "settings.general.auto_start",
408 "settings.general.auto_start",
409 "settings.general.open_in_background",
409 "settings.general.open_in_background",
410 "settings.general.show_in_tray",
410 "settings.general.close_to_tray",
411 "settings.general.close_to_tray",
411 "settings.general.up_arrow",
412 "settings.general.up_arrow",
412 "settings.general.translate_into",
413 "settings.general.translate_into",
@@ -430,7 +431,6 @@ mod tests {
430 "settings.appearance.theme",
431 "settings.appearance.theme",
431 "settings.appearance.color_scheme",
432 "settings.appearance.color_scheme",
432 "settings.appearance.app_icon",
433 "settings.appearance.app_icon",
433 "settings.appearance.tray_icon",
434 ],
434 ],
435 SettingsSection::Chats => &[
435 SettingsSection::Chats => &[
436 "settings.chats.density",
436 "settings.chats.density",