diff --git a/crates/client/lang/en/jump.txt b/crates/client/lang/en/jump.txt index c6baedc..09bf928 100644 --- a/crates/client/lang/en/jump.txt +++ b/crates/client/lang/en/jump.txt @@ -17,3 +17,5 @@ new_community = New community expand_sidebar = Expand sidebar collapse_sidebar = Collapse sidebar log_out = Log out +on = on +off = off diff --git a/crates/client/lang/tr/jump.txt b/crates/client/lang/tr/jump.txt index 4293c98..c2d68f4 100644 --- a/crates/client/lang/tr/jump.txt +++ b/crates/client/lang/tr/jump.txt @@ -17,3 +17,5 @@ new_community = Yeni topluluk expand_sidebar = Kenar çubuğunu genişlet collapse_sidebar = Kenar çubuğunu daralt log_out = Çıkış yap +on = açık +off = kapalı diff --git a/crates/client/src/gui/jump.rs b/crates/client/src/gui/jump.rs index c2dc32e..c3fd2c2 100644 --- a/crates/client/src/gui/jump.rs +++ b/crates/client/src/gui/jump.rs @@ -1,4 +1,5 @@ -use crate::lang::{Label as _, w}; +use crate::lang::{Label as _, Lang, w}; +use crate::settings::{Activation, FontSize}; use common::model::{Community, CommunityKind, Id, Presence, User}; use gpui_kit::{ Context, Div, Entity, FontWeight, InteractiveElement, KeyDownEvent, ParentElement, @@ -17,7 +18,8 @@ use super::{ community_icon, community_name, parts::{Ink, Text, band, words}, presence_avatar, - settings_page::{SETTINGS_IDS, settings_titles}, + settings_page::{SETTINGS_IDS, setting_rows, settings_titles}, + voice_settings::modes, style::{Theme, Tokens, my_hue, radius, size, space, stroke, text}, widget::bare_input, }; @@ -31,9 +33,14 @@ pub(super) enum Place { Notes, Friends, Settings(usize), + Setting(usize), Builder(BuilderTab), NewCommunity, Theme(Theme), + FontSize(FontSize), + Language(Lang), + VoiceMode(Activation), + CloseToTray, Presence(Presence), Sidebar, Mute, @@ -90,9 +97,14 @@ impl Place { Place::Notes => "notes".into(), Place::Friends => "friends".into(), Place::Settings(index) => format!("settings:{}", SETTINGS_IDS[index]), + Place::Setting(index) => format!("setting:{index}"), Place::Builder(tab) => format!("builder:{}", tab.id()), Place::NewCommunity => "new_community".into(), Place::Theme(theme) => format!("theme:{}", theme.as_str()), + Place::FontSize(size) => format!("font_size:{}", size.as_str()), + Place::Language(lang) => format!("language:{}", lang.as_str()), + Place::VoiceMode(mode) => format!("voice_mode:{}", mode.as_str()), + Place::CloseToTray => "close_to_tray".into(), Place::Presence(presence) => format!("presence:{}", presence.as_str()), Place::Sidebar => "sidebar".into(), Place::Mute => "mute".into(), @@ -184,6 +196,19 @@ impl Yumush { .hinted(w().jump.hint_settings) }), ) + .chain( + setting_rows() + .into_iter() + .enumerate() + .map(|(index, (section, label))| { + Row::new( + Place::Setting(index), + label.to_string(), + Glyph::Icon(IconName::Settings2), + ) + .hinted(settings_titles()[section]) + }), + ) .chain( BuilderTab::ALL .into_iter() @@ -274,6 +299,32 @@ impl Yumush { ) .hinted(w().jump.hint_theme) })) + .chain(FontSize::ALL.into_iter().map(|size| { + Row::new(Place::FontSize(size), size.label(), Glyph::Icon(IconName::Type)) + .hinted(w().settings_page.font_size) + })) + .chain(Lang::ALL.into_iter().map(|lang| { + Row::new( + Place::Language(lang), + lang.words().common.language, + Glyph::Icon(IconName::MessageSquare), + ) + .hinted(w().settings_page.language) + })) + .chain(modes().into_iter().map(|(mode, label)| { + Row::new(Place::VoiceMode(mode), label, Glyph::Icon(IconName::Mic)) + .hinted(w().voice_settings.mode) + })) + .chain([Row::new( + Place::CloseToTray, + w().settings_page.close_to_tray, + Glyph::Icon(IconName::Minimize), + ) + .hinted(if self.settings.close_to_tray { + w().jump.on + } else { + w().jump.off + })]) .chain(Presence::ALL.into_iter().map(|presence| { Row::new( Place::Presence(presence), @@ -361,12 +412,20 @@ impl Yumush { self.show_view(View::Settings, window, cx); self.chat.section = index; } + Place::Setting(index) => { + self.show_view(View::Settings, window, cx); + self.chat.section = setting_rows()[index].0; + } Place::Builder(tab) => { self.show_view(View::Builder, window, cx); self.select_builder_tab(tab, window, cx); } Place::NewCommunity => self.new_community(window, cx), Place::Theme(theme) => self.set_theme(theme, cx), + Place::FontSize(size) => self.set_font_size(size, cx), + Place::Language(lang) => self.set_language(lang, cx), + Place::VoiceMode(mode) => self.set_voice_mode(mode, cx), + Place::CloseToTray => self.toggle_close_to_tray(cx), Place::Presence(presence) => self.set_presence(presence, window, cx), Place::Sidebar => self.toggle_sidebar(), Place::Mute => self.toggle_mute(window, cx), diff --git a/crates/client/src/gui/settings_page.rs b/crates/client/src/gui/settings_page.rs index 86ec56d..9de2c4d 100644 --- a/crates/client/src/gui/settings_page.rs +++ b/crates/client/src/gui/settings_page.rs @@ -36,6 +36,36 @@ pub(super) fn settings_titles() -> [&'static str; 4] { [w.profile, w.voice, w.camera_share, w.appearance] } +pub(super) fn setting_rows() -> [(usize, &'static str); 23] { + let s = &w().settings_page; + let v = &w().voice_settings; + [ + (0, s.name), + (0, s.status), + (0, s.presence), + (0, s.change_picture), + (0, s.delete_account), + (1, v.input_device), + (1, v.output_device), + (1, v.input_volume), + (1, v.output_volume), + (1, v.mode), + (1, v.hear_yourself), + (1, v.play_sound), + (1, v.sensitivity), + (1, v.key), + (2, s.camera), + (2, s.screen_share), + (2, s.codec), + (2, s.share_audio), + (3, s.theme), + (3, s.font_size), + (3, s.language), + (3, s.close_to_tray), + (3, s.your_hue), + ] +} + impl Yumush { pub(super) fn settings_page( &self, @@ -169,12 +199,7 @@ impl Yumush { palette.tokens, { let entity = entity.clone(); - move |_, cx| { - entity.update(cx, |yumush, cx| { - yumush.settings.close_to_tray = !yumush.settings.close_to_tray; - yumush.commit_settings(cx); - }) - } + move |_, cx| entity.update(cx, |yumush, cx| yumush.toggle_close_to_tray(cx)) }, ), ), @@ -346,6 +371,11 @@ impl Yumush { cx.refresh_windows(); } + pub(super) fn toggle_close_to_tray(&mut self, cx: &mut Context) { + self.settings.close_to_tray = !self.settings.close_to_tray; + self.commit_settings(cx); + } + pub(super) fn commit_settings(&mut self, cx: &mut Context) { settings::save(&self.settings); self.network.set_voice_settings(&self.settings.voice); diff --git a/crates/client/src/gui/voice_settings.rs b/crates/client/src/gui/voice_settings.rs index 58708b6..1d5afaf 100644 --- a/crates/client/src/gui/voice_settings.rs +++ b/crates/client/src/gui/voice_settings.rs @@ -28,7 +28,7 @@ use crate::{ }; const LEVEL_INTERVAL: Duration = Duration::from_millis(50); -fn modes() -> [(Activation, &'static str); 2] { +pub(super) fn modes() -> [(Activation, &'static str); 2] { [ (Activation::VoiceActivity, w().voice_settings.voice_activity), (Activation::PushToTalk, w().voice_settings.push_to_talk),