Ctrl+K finds every settings row (opens its section, section shown as hint) and sets font size, language, voice mode and close-to-tray directly
Browse files at this commitcf2498f2f9c0c2f5d5f2ad18973135fa762c1921Parent: 699221c- feat
- Ctrl+K finds every settings row (opens its section, section shown as hint) and sets font size, language, voice mode and close-to-tray directly
5 changed files +102 -9
- crates/client/lang/en/jump.txt +2 -0
- crates/client/lang/tr/jump.txt +2 -0
- crates/client/src/gui/jump.rs +61 -2
- crates/client/src/gui/settings_page.rs +36 -6
- crates/client/src/gui/voice_settings.rs +1 -1
crates/client/lang/en/jump.txtmodified+2 -0
| @@ -17,3 +17,5 @@ new_community = New community | |||
| 17 | expand_sidebar = Expand sidebar | 17 | expand_sidebar = Expand sidebar |
| 18 | collapse_sidebar = Collapse sidebar | 18 | collapse_sidebar = Collapse sidebar |
| 19 | log_out = Log out | 19 | log_out = Log out |
| 20 | +on = on | ||
| 21 | +off = off | ||
crates/client/lang/tr/jump.txtmodified+2 -0
| @@ -17,3 +17,5 @@ new_community = Yeni topluluk | |||
| 17 | expand_sidebar = Kenar çubuğunu genişlet | 17 | expand_sidebar = Kenar çubuğunu genişlet |
| 18 | collapse_sidebar = Kenar çubuğunu daralt | 18 | collapse_sidebar = Kenar çubuğunu daralt |
| 19 | log_out = Çıkış yap | 19 | log_out = Çıkış yap |
| 20 | +on = açık | ||
| 21 | +off = kapalı | ||
crates/client/src/gui/jump.rsmodified+61 -2
| @@ -1,4 +1,5 @@ | |||
| 1 | -use crate::lang::{Label as _, w}; | 1 | +use crate::lang::{Label as _, Lang, w}; |
| 2 | +use crate::settings::{Activation, FontSize}; | ||
| 2 | use common::model::{Community, CommunityKind, Id, Presence, User}; | 3 | use common::model::{Community, CommunityKind, Id, Presence, User}; |
| 3 | use gpui_kit::{ | 4 | use gpui_kit::{ |
| 4 | Context, Div, Entity, FontWeight, InteractiveElement, KeyDownEvent, ParentElement, | 5 | Context, Div, Entity, FontWeight, InteractiveElement, KeyDownEvent, ParentElement, |
| @@ -17,7 +18,8 @@ use super::{ | |||
| 17 | community_icon, community_name, | 18 | community_icon, community_name, |
| 18 | parts::{Ink, Text, band, words}, | 19 | parts::{Ink, Text, band, words}, |
| 19 | presence_avatar, | 20 | presence_avatar, |
| 20 | - settings_page::{SETTINGS_IDS, settings_titles}, | 21 | + settings_page::{SETTINGS_IDS, setting_rows, settings_titles}, |
| 22 | + voice_settings::modes, | ||
| 21 | style::{Theme, Tokens, my_hue, radius, size, space, stroke, text}, | 23 | style::{Theme, Tokens, my_hue, radius, size, space, stroke, text}, |
| 22 | widget::bare_input, | 24 | widget::bare_input, |
| 23 | }; | 25 | }; |
| @@ -31,9 +33,14 @@ pub(super) enum Place { | |||
| 31 | Notes, | 33 | Notes, |
| 32 | Friends, | 34 | Friends, |
| 33 | Settings(usize), | 35 | Settings(usize), |
| 36 | + Setting(usize), | ||
| 34 | Builder(BuilderTab), | 37 | Builder(BuilderTab), |
| 35 | NewCommunity, | 38 | NewCommunity, |
| 36 | Theme(Theme), | 39 | Theme(Theme), |
| 40 | + FontSize(FontSize), | ||
| 41 | + Language(Lang), | ||
| 42 | + VoiceMode(Activation), | ||
| 43 | + CloseToTray, | ||
| 37 | Presence(Presence), | 44 | Presence(Presence), |
| 38 | Sidebar, | 45 | Sidebar, |
| 39 | Mute, | 46 | Mute, |
| @@ -90,9 +97,14 @@ impl Place { | |||
| 90 | Place::Notes => "notes".into(), | 97 | Place::Notes => "notes".into(), |
| 91 | Place::Friends => "friends".into(), | 98 | Place::Friends => "friends".into(), |
| 92 | Place::Settings(index) => format!("settings:{}", SETTINGS_IDS[index]), | 99 | Place::Settings(index) => format!("settings:{}", SETTINGS_IDS[index]), |
| 100 | + Place::Setting(index) => format!("setting:{index}"), | ||
| 93 | Place::Builder(tab) => format!("builder:{}", tab.id()), | 101 | Place::Builder(tab) => format!("builder:{}", tab.id()), |
| 94 | Place::NewCommunity => "new_community".into(), | 102 | Place::NewCommunity => "new_community".into(), |
| 95 | Place::Theme(theme) => format!("theme:{}", theme.as_str()), | 103 | Place::Theme(theme) => format!("theme:{}", theme.as_str()), |
| 104 | + Place::FontSize(size) => format!("font_size:{}", size.as_str()), | ||
| 105 | + Place::Language(lang) => format!("language:{}", lang.as_str()), | ||
| 106 | + Place::VoiceMode(mode) => format!("voice_mode:{}", mode.as_str()), | ||
| 107 | + Place::CloseToTray => "close_to_tray".into(), | ||
| 96 | Place::Presence(presence) => format!("presence:{}", presence.as_str()), | 108 | Place::Presence(presence) => format!("presence:{}", presence.as_str()), |
| 97 | Place::Sidebar => "sidebar".into(), | 109 | Place::Sidebar => "sidebar".into(), |
| 98 | Place::Mute => "mute".into(), | 110 | Place::Mute => "mute".into(), |
| @@ -184,6 +196,19 @@ impl Yumush { | |||
| 184 | .hinted(w().jump.hint_settings) | 196 | .hinted(w().jump.hint_settings) |
| 185 | }), | 197 | }), |
| 186 | ) | 198 | ) |
| 199 | + .chain( | ||
| 200 | + setting_rows() | ||
| 201 | + .into_iter() | ||
| 202 | + .enumerate() | ||
| 203 | + .map(|(index, (section, label))| { | ||
| 204 | + Row::new( | ||
| 205 | + Place::Setting(index), | ||
| 206 | + label.to_string(), | ||
| 207 | + Glyph::Icon(IconName::Settings2), | ||
| 208 | + ) | ||
| 209 | + .hinted(settings_titles()[section]) | ||
| 210 | + }), | ||
| 211 | + ) | ||
| 187 | .chain( | 212 | .chain( |
| 188 | BuilderTab::ALL | 213 | BuilderTab::ALL |
| 189 | .into_iter() | 214 | .into_iter() |
| @@ -274,6 +299,32 @@ impl Yumush { | |||
| 274 | ) | 299 | ) |
| 275 | .hinted(w().jump.hint_theme) | 300 | .hinted(w().jump.hint_theme) |
| 276 | })) | 301 | })) |
| 302 | + .chain(FontSize::ALL.into_iter().map(|size| { | ||
| 303 | + Row::new(Place::FontSize(size), size.label(), Glyph::Icon(IconName::Type)) | ||
| 304 | + .hinted(w().settings_page.font_size) | ||
| 305 | + })) | ||
| 306 | + .chain(Lang::ALL.into_iter().map(|lang| { | ||
| 307 | + Row::new( | ||
| 308 | + Place::Language(lang), | ||
| 309 | + lang.words().common.language, | ||
| 310 | + Glyph::Icon(IconName::MessageSquare), | ||
| 311 | + ) | ||
| 312 | + .hinted(w().settings_page.language) | ||
| 313 | + })) | ||
| 314 | + .chain(modes().into_iter().map(|(mode, label)| { | ||
| 315 | + Row::new(Place::VoiceMode(mode), label, Glyph::Icon(IconName::Mic)) | ||
| 316 | + .hinted(w().voice_settings.mode) | ||
| 317 | + })) | ||
| 318 | + .chain([Row::new( | ||
| 319 | + Place::CloseToTray, | ||
| 320 | + w().settings_page.close_to_tray, | ||
| 321 | + Glyph::Icon(IconName::Minimize), | ||
| 322 | + ) | ||
| 323 | + .hinted(if self.settings.close_to_tray { | ||
| 324 | + w().jump.on | ||
| 325 | + } else { | ||
| 326 | + w().jump.off | ||
| 327 | + })]) | ||
| 277 | .chain(Presence::ALL.into_iter().map(|presence| { | 328 | .chain(Presence::ALL.into_iter().map(|presence| { |
| 278 | Row::new( | 329 | Row::new( |
| 279 | Place::Presence(presence), | 330 | Place::Presence(presence), |
| @@ -361,12 +412,20 @@ impl Yumush { | |||
| 361 | self.show_view(View::Settings, window, cx); | 412 | self.show_view(View::Settings, window, cx); |
| 362 | self.chat.section = index; | 413 | self.chat.section = index; |
| 363 | } | 414 | } |
| 415 | + Place::Setting(index) => { | ||
| 416 | + self.show_view(View::Settings, window, cx); | ||
| 417 | + self.chat.section = setting_rows()[index].0; | ||
| 418 | + } | ||
| 364 | Place::Builder(tab) => { | 419 | Place::Builder(tab) => { |
| 365 | self.show_view(View::Builder, window, cx); | 420 | self.show_view(View::Builder, window, cx); |
| 366 | self.select_builder_tab(tab, window, cx); | 421 | self.select_builder_tab(tab, window, cx); |
| 367 | } | 422 | } |
| 368 | Place::NewCommunity => self.new_community(window, cx), | 423 | Place::NewCommunity => self.new_community(window, cx), |
| 369 | Place::Theme(theme) => self.set_theme(theme, cx), | 424 | Place::Theme(theme) => self.set_theme(theme, cx), |
| 425 | + Place::FontSize(size) => self.set_font_size(size, cx), | ||
| 426 | + Place::Language(lang) => self.set_language(lang, cx), | ||
| 427 | + Place::VoiceMode(mode) => self.set_voice_mode(mode, cx), | ||
| 428 | + Place::CloseToTray => self.toggle_close_to_tray(cx), | ||
| 370 | Place::Presence(presence) => self.set_presence(presence, window, cx), | 429 | Place::Presence(presence) => self.set_presence(presence, window, cx), |
| 371 | Place::Sidebar => self.toggle_sidebar(), | 430 | Place::Sidebar => self.toggle_sidebar(), |
| 372 | Place::Mute => self.toggle_mute(window, cx), | 431 | Place::Mute => self.toggle_mute(window, cx), |
crates/client/src/gui/settings_page.rsmodified+36 -6
| @@ -36,6 +36,36 @@ pub(super) fn settings_titles() -> [&'static str; 4] { | |||
| 36 | [w.profile, w.voice, w.camera_share, w.appearance] | 36 | [w.profile, w.voice, w.camera_share, w.appearance] |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | +pub(super) fn setting_rows() -> [(usize, &'static str); 23] { | ||
| 40 | + let s = &w().settings_page; | ||
| 41 | + let v = &w().voice_settings; | ||
| 42 | + [ | ||
| 43 | + (0, s.name), | ||
| 44 | + (0, s.status), | ||
| 45 | + (0, s.presence), | ||
| 46 | + (0, s.change_picture), | ||
| 47 | + (0, s.delete_account), | ||
| 48 | + (1, v.input_device), | ||
| 49 | + (1, v.output_device), | ||
| 50 | + (1, v.input_volume), | ||
| 51 | + (1, v.output_volume), | ||
| 52 | + (1, v.mode), | ||
| 53 | + (1, v.hear_yourself), | ||
| 54 | + (1, v.play_sound), | ||
| 55 | + (1, v.sensitivity), | ||
| 56 | + (1, v.key), | ||
| 57 | + (2, s.camera), | ||
| 58 | + (2, s.screen_share), | ||
| 59 | + (2, s.codec), | ||
| 60 | + (2, s.share_audio), | ||
| 61 | + (3, s.theme), | ||
| 62 | + (3, s.font_size), | ||
| 63 | + (3, s.language), | ||
| 64 | + (3, s.close_to_tray), | ||
| 65 | + (3, s.your_hue), | ||
| 66 | + ] | ||
| 67 | +} | ||
| 68 | + | ||
| 39 | impl Yumush { | 69 | impl Yumush { |
| 40 | pub(super) fn settings_page( | 70 | pub(super) fn settings_page( |
| 41 | &self, | 71 | &self, |
| @@ -169,12 +199,7 @@ impl Yumush { | |||
| 169 | palette.tokens, | 199 | palette.tokens, |
| 170 | { | 200 | { |
| 171 | let entity = entity.clone(); | 201 | let entity = entity.clone(); |
| 172 | - move |_, cx| { | 202 | + move |_, cx| entity.update(cx, |yumush, cx| yumush.toggle_close_to_tray(cx)) |
| 173 | - entity.update(cx, |yumush, cx| { | ||
| 174 | - yumush.settings.close_to_tray = !yumush.settings.close_to_tray; | ||
| 175 | - yumush.commit_settings(cx); | ||
| 176 | - }) | ||
| 177 | - } | ||
| 178 | }, | 203 | }, |
| 179 | ), | 204 | ), |
| 180 | ), | 205 | ), |
| @@ -346,6 +371,11 @@ impl Yumush { | |||
| 346 | cx.refresh_windows(); | 371 | cx.refresh_windows(); |
| 347 | } | 372 | } |
| 348 | 373 | ||
| 374 | + pub(super) fn toggle_close_to_tray(&mut self, cx: &mut Context<Self>) { | ||
| 375 | + self.settings.close_to_tray = !self.settings.close_to_tray; | ||
| 376 | + self.commit_settings(cx); | ||
| 377 | + } | ||
| 378 | + | ||
| 349 | pub(super) fn commit_settings(&mut self, cx: &mut Context<Self>) { | 379 | pub(super) fn commit_settings(&mut self, cx: &mut Context<Self>) { |
| 350 | settings::save(&self.settings); | 380 | settings::save(&self.settings); |
| 351 | self.network.set_voice_settings(&self.settings.voice); | 381 | self.network.set_voice_settings(&self.settings.voice); |
crates/client/src/gui/voice_settings.rsmodified+1 -1
| @@ -28,7 +28,7 @@ use crate::{ | |||
| 28 | }; | 28 | }; |
| 29 | 29 | ||
| 30 | const LEVEL_INTERVAL: Duration = Duration::from_millis(50); | 30 | const LEVEL_INTERVAL: Duration = Duration::from_millis(50); |
| 31 | -fn modes() -> [(Activation, &'static str); 2] { | 31 | +pub(super) fn modes() -> [(Activation, &'static str); 2] { |
| 32 | [ | 32 | [ |
| 33 | (Activation::VoiceActivity, w().voice_settings.voice_activity), | 33 | (Activation::VoiceActivity, w().voice_settings.voice_activity), |
| 34 | (Activation::PushToTalk, w().voice_settings.push_to_talk), | 34 | (Activation::PushToTalk, w().voice_settings.push_to_talk), |