Appearance › Show seconds (off by default) shows message times as HH:MM:SS
Browse files at this commita5cfbc89a740b4f0077ec2a41b80097dcf24944bParent: 09df64d- feat
- Appearance › Show seconds (off by default) shows message times as HH:MM:SS
- Settings::clock() picks the format
5 changed files +42 -4
- crates/client/lang/en/settings_page.txt +1 -0
- crates/client/lang/tr/settings_page.txt +1 -0
- crates/client/src/gui/chat.rs +6 -3
- crates/client/src/gui/settings_page.rs +19 -1
- crates/client/src/settings.rs +15 -0
crates/client/lang/en/settings_page.txtmodified+1 -0
| @@ -25,3 +25,4 @@ frame_rate = Frame rate | ||
| 25 | 25 | codec = Codec |
| 26 | 26 | share_audio = Share audio |
| 27 | 27 | back_esc = Back (esc) |
| 28 | +clock_seconds = Show seconds |
crates/client/lang/tr/settings_page.txtmodified+1 -0
| @@ -25,3 +25,4 @@ frame_rate = Kare hızı | ||
| 25 | 25 | codec = Kodek |
| 26 | 26 | share_audio = Sesi paylaş |
| 27 | 27 | back_esc = Geri (esc) |
| 28 | +clock_seconds = Saniyeleri göster |
crates/client/src/gui/chat.rsmodified+6 -3
| @@ -1,6 +1,5 @@ | ||
| 1 | 1 | use super::style::{self, radius, size, space, stroke, text}; |
| 2 | 2 | use super::text; |
| 3 | -use crate::gui::CLOCK; | |
| 4 | 3 | use crate::gui::glyph::Fill as _; |
| 5 | 4 | use crate::lang::w; |
| 6 | 5 | use std::{ |
| @@ -1945,6 +1944,7 @@ impl Yumush { | ||
| 1945 | 1944 | run, |
| 1946 | 1945 | &self.chat, |
| 1947 | 1946 | self.user.as_ref(), |
| 1947 | + self.settings.clock(), | |
| 1948 | 1948 | entity, |
| 1949 | 1949 | palette, |
| 1950 | 1950 | ); |
| @@ -3570,6 +3570,7 @@ fn render_message( | ||
| 3570 | 3570 | run: CallRun, |
| 3571 | 3571 | chat: &Chat, |
| 3572 | 3572 | me: Option<&User>, |
| 3573 | + clock: &'static str, | |
| 3573 | 3574 | entity: &Entity<Yumush>, |
| 3574 | 3575 | palette: Palette, |
| 3575 | 3576 | ) -> AnyElement { |
| @@ -3628,7 +3629,9 @@ fn render_message( | ||
| 3628 | 3629 | .min_w_0() |
| 3629 | 3630 | .hover(|style| style.bg(palette.hover)) |
| 3630 | 3631 | .when(chat.engaged(message.id), |this| this.bg(palette.hover)) |
| 3631 | - .when(message.deleted, |this| this.text_color(palette.tokens.faint())) | |
| 3632 | + .when(message.deleted, |this| { | |
| 3633 | + this.text_color(palette.tokens.faint()) | |
| 3634 | + }) | |
| 3632 | 3635 | .when(first && spaced && !selecting, |this| this.mt(px(space::LG))) |
| 3633 | 3636 | .when(highlighted, |this| this.bg(palette.tokens.press())) |
| 3634 | 3637 | .when(mentioned, |this| { |
| @@ -3660,7 +3663,7 @@ fn render_message( | ||
| 3660 | 3663 | div() |
| 3661 | 3664 | .text_size(text(text::CAPTION)) |
| 3662 | 3665 | .text_color(palette.muted) |
| 3663 | - .child(millis_time(message.created_at, CLOCK)), | |
| 3666 | + .child(millis_time(message.created_at, clock)), | |
| 3664 | 3667 | ), |
| 3665 | 3668 | ) |
| 3666 | 3669 | }) |
crates/client/src/gui/settings_page.rsmodified+19 -1
| @@ -36,7 +36,7 @@ pub(super) fn settings_titles() -> [&'static str; 4] { | ||
| 36 | 36 | [w.profile, w.voice, w.camera_share, w.appearance] |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | -pub(super) fn setting_rows() -> [(usize, &'static str); 23] { | |
| 39 | +pub(super) fn setting_rows() -> [(usize, &'static str); 24] { | |
| 40 | 40 | let s = &w().settings_page; |
| 41 | 41 | let v = &w().voice_settings; |
| 42 | 42 | [ |
| @@ -62,6 +62,7 @@ pub(super) fn setting_rows() -> [(usize, &'static str); 23] { | ||
| 62 | 62 | (3, s.font_size), |
| 63 | 63 | (3, s.language), |
| 64 | 64 | (3, s.close_to_tray), |
| 65 | + (3, s.clock_seconds), | |
| 65 | 66 | (3, s.your_hue), |
| 66 | 67 | ] |
| 67 | 68 | } |
| @@ -203,6 +204,18 @@ impl Yumush { | ||
| 203 | 204 | }, |
| 204 | 205 | ), |
| 205 | 206 | ), |
| 207 | + row( | |
| 208 | + w().settings_page.clock_seconds, | |
| 209 | + super::parts::toggle( | |
| 210 | + "clock_seconds_switch", | |
| 211 | + self.settings.clock_seconds, | |
| 212 | + palette.tokens, | |
| 213 | + { | |
| 214 | + let entity = entity.clone(); | |
| 215 | + move |_, cx| entity.update(cx, |yumush, cx| yumush.toggle_clock_seconds(cx)) | |
| 216 | + }, | |
| 217 | + ), | |
| 218 | + ), | |
| 206 | 219 | ]; |
| 207 | 220 | if let Some(user) = self.user.as_ref() { |
| 208 | 221 | appearance.push(row( |
| @@ -376,6 +389,11 @@ impl Yumush { | ||
| 376 | 389 | self.commit_settings(cx); |
| 377 | 390 | } |
| 378 | 391 | |
| 392 | + pub(super) fn toggle_clock_seconds(&mut self, cx: &mut Context<Self>) { | |
| 393 | + self.settings.clock_seconds = !self.settings.clock_seconds; | |
| 394 | + self.commit_settings(cx); | |
| 395 | + } | |
| 396 | + | |
| 379 | 397 | pub(super) fn commit_settings(&mut self, cx: &mut Context<Self>) { |
| 380 | 398 | settings::save(&self.settings); |
| 381 | 399 | self.network.set_voice_settings(&self.settings.voice); |
crates/client/src/settings.rsmodified+15 -0
| @@ -195,10 +195,21 @@ pub struct Settings { | ||
| 195 | 195 | pub voice: VoiceSettings, |
| 196 | 196 | pub share: ShareSettings, |
| 197 | 197 | pub close_to_tray: bool, |
| 198 | + pub clock_seconds: bool, | |
| 198 | 199 | pub jump_usage: BTreeMap<String, u32>, |
| 199 | 200 | pub last_chats: BTreeMap<Id, Id>, |
| 200 | 201 | } |
| 201 | 202 | |
| 203 | +impl Settings { | |
| 204 | + pub fn clock(&self) -> &'static str { | |
| 205 | + if self.clock_seconds { | |
| 206 | + crate::gui::CLOCK_SECONDS | |
| 207 | + } else { | |
| 208 | + crate::gui::CLOCK | |
| 209 | + } | |
| 210 | + } | |
| 211 | +} | |
| 212 | + | |
| 202 | 213 | impl Default for Settings { |
| 203 | 214 | fn default() -> Self { |
| 204 | 215 | Self { |
| @@ -208,6 +219,7 @@ impl Default for Settings { | ||
| 208 | 219 | voice: VoiceSettings::default(), |
| 209 | 220 | share: ShareSettings::default(), |
| 210 | 221 | close_to_tray: true, |
| 222 | + clock_seconds: false, | |
| 211 | 223 | jump_usage: BTreeMap::new(), |
| 212 | 224 | last_chats: BTreeMap::new(), |
| 213 | 225 | } |
| @@ -321,6 +333,8 @@ pub fn load() -> Settings { | ||
| 321 | 333 | share, |
| 322 | 334 | close_to_tray: text("close_to_tray") |
| 323 | 335 | .map_or(defaults.close_to_tray, |value| value != "false"), |
| 336 | + clock_seconds: text("clock_seconds") | |
| 337 | + .map_or(defaults.clock_seconds, |value| value == "true"), | |
| 324 | 338 | jump_usage: text("jump.usage") |
| 325 | 339 | .map(|value| { |
| 326 | 340 | value |
| @@ -360,6 +374,7 @@ pub fn save(settings: &Settings) { | ||
| 360 | 374 | line("font_size", settings.font_size.as_str()), |
| 361 | 375 | line("language", settings.language.as_str()), |
| 362 | 376 | line("close_to_tray", settings.close_to_tray), |
| 377 | + line("clock_seconds", settings.clock_seconds), | |
| 363 | 378 | line("voice.sensitivity", voice.sensitivity_db), |
| 364 | 379 | line("voice.input_volume", voice.input_volume), |
| 365 | 380 | line("voice.output_volume", voice.output_volume), |