forge
Explore
Log in

Don't you dare go Hollow

Appearance › Show seconds (off by default) shows message times as HH:MM:SS

Browse files at this commit

a5cfbc89a740b4f0077ec2a41b80097dcf24944bAhmet Kaan GümüşParent: 09df64d
  • feat
    • Appearance › Show seconds (off by default) shows message times as HH:MM:SS
    • Settings::clock() picks the format
Show full message
✨ feat: Appearance › Show seconds (off by default) shows message times as HH:MM:SS; Settings::clock() picks the format
crates/client/lang/en/settings_page.txtmodified+1 -0
@@ -25,3 +25,4 @@ frame_rate = Frame rate
25 codec = Codec25 codec = Codec
26 share_audio = Share audio26 share_audio = Share audio
27 back_esc = Back (esc)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 codec = Kodek25 codec = Kodek
26 share_audio = Sesi paylaş26 share_audio = Sesi paylaş
27 back_esc = Geri (esc)27 back_esc = Geri (esc)
28+clock_seconds = Saniyeleri göster
crates/client/src/gui/chat.rsmodified+6 -3
@@ -1,6 +1,5 @@
1 use super::style::{self, radius, size, space, stroke, text};1 use super::style::{self, radius, size, space, stroke, text};
2 use super::text;2 use super::text;
3-use crate::gui::CLOCK;
4 use crate::gui::glyph::Fill as _;3 use crate::gui::glyph::Fill as _;
5 use crate::lang::w;4 use crate::lang::w;
6 use std::{5 use std::{
@@ -1945,6 +1944,7 @@ impl Yumush {
1945 run,1944 run,
1946 &self.chat,1945 &self.chat,
1947 self.user.as_ref(),1946 self.user.as_ref(),
1947+ self.settings.clock(),
1948 entity,1948 entity,
1949 palette,1949 palette,
1950 );1950 );
@@ -3570,6 +3570,7 @@ fn render_message(
3570 run: CallRun,3570 run: CallRun,
3571 chat: &Chat,3571 chat: &Chat,
3572 me: Option<&User>,3572 me: Option<&User>,
3573+ clock: &'static str,
3573 entity: &Entity<Yumush>,3574 entity: &Entity<Yumush>,
3574 palette: Palette,3575 palette: Palette,
3575 ) -> AnyElement {3576 ) -> AnyElement {
@@ -3628,7 +3629,9 @@ fn render_message(
3628 .min_w_0()3629 .min_w_0()
3629 .hover(|style| style.bg(palette.hover))3630 .hover(|style| style.bg(palette.hover))
3630 .when(chat.engaged(message.id), |this| this.bg(palette.hover))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 .when(first && spaced && !selecting, |this| this.mt(px(space::LG)))3635 .when(first && spaced && !selecting, |this| this.mt(px(space::LG)))
3633 .when(highlighted, |this| this.bg(palette.tokens.press()))3636 .when(highlighted, |this| this.bg(palette.tokens.press()))
3634 .when(mentioned, |this| {3637 .when(mentioned, |this| {
@@ -3660,7 +3663,7 @@ fn render_message(
3660 div()3663 div()
3661 .text_size(text(text::CAPTION))3664 .text_size(text(text::CAPTION))
3662 .text_color(palette.muted)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 [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] {39+pub(super) fn setting_rows() -> [(usize, &'static str); 24] {
40 let s = &w().settings_page;40 let s = &w().settings_page;
41 let v = &w().voice_settings;41 let v = &w().voice_settings;
42 [42 [
@@ -62,6 +62,7 @@ pub(super) fn setting_rows() -> [(usize, &'static str); 23] {
62 (3, s.font_size),62 (3, s.font_size),
63 (3, s.language),63 (3, s.language),
64 (3, s.close_to_tray),64 (3, s.close_to_tray),
65+ (3, s.clock_seconds),
65 (3, s.your_hue),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 if let Some(user) = self.user.as_ref() {220 if let Some(user) = self.user.as_ref() {
208 appearance.push(row(221 appearance.push(row(
@@ -376,6 +389,11 @@ impl Yumush {
376 self.commit_settings(cx);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 pub(super) fn commit_settings(&mut self, cx: &mut Context<Self>) {397 pub(super) fn commit_settings(&mut self, cx: &mut Context<Self>) {
380 settings::save(&self.settings);398 settings::save(&self.settings);
381 self.network.set_voice_settings(&self.settings.voice);399 self.network.set_voice_settings(&self.settings.voice);
crates/client/src/settings.rsmodified+15 -0
@@ -195,10 +195,21 @@ pub struct Settings {
195 pub voice: VoiceSettings,195 pub voice: VoiceSettings,
196 pub share: ShareSettings,196 pub share: ShareSettings,
197 pub close_to_tray: bool,197 pub close_to_tray: bool,
198+ pub clock_seconds: bool,
198 pub jump_usage: BTreeMap<String, u32>,199 pub jump_usage: BTreeMap<String, u32>,
199 pub last_chats: BTreeMap<Id, Id>,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 impl Default for Settings {213 impl Default for Settings {
203 fn default() -> Self {214 fn default() -> Self {
204 Self {215 Self {
@@ -208,6 +219,7 @@ impl Default for Settings {
208 voice: VoiceSettings::default(),219 voice: VoiceSettings::default(),
209 share: ShareSettings::default(),220 share: ShareSettings::default(),
210 close_to_tray: true,221 close_to_tray: true,
222+ clock_seconds: false,
211 jump_usage: BTreeMap::new(),223 jump_usage: BTreeMap::new(),
212 last_chats: BTreeMap::new(),224 last_chats: BTreeMap::new(),
213 }225 }
@@ -321,6 +333,8 @@ pub fn load() -> Settings {
321 share,333 share,
322 close_to_tray: text("close_to_tray")334 close_to_tray: text("close_to_tray")
323 .map_or(defaults.close_to_tray, |value| value != "false"),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 jump_usage: text("jump.usage")338 jump_usage: text("jump.usage")
325 .map(|value| {339 .map(|value| {
326 value340 value
@@ -360,6 +374,7 @@ pub fn save(settings: &Settings) {
360 line("font_size", settings.font_size.as_str()),374 line("font_size", settings.font_size.as_str()),
361 line("language", settings.language.as_str()),375 line("language", settings.language.as_str()),
362 line("close_to_tray", settings.close_to_tray),376 line("close_to_tray", settings.close_to_tray),
377+ line("clock_seconds", settings.clock_seconds),
363 line("voice.sensitivity", voice.sensitivity_db),378 line("voice.sensitivity", voice.sensitivity_db),
364 line("voice.input_volume", voice.input_volume),379 line("voice.input_volume", voice.input_volume),
365 line("voice.output_volume", voice.output_volume),380 line("voice.output_volume", voice.output_volume),