diff --git a/Userland/Applications/ClockSettings/ClockSettingsWidget.cpp b/Userland/Applications/ClockSettings/ClockSettingsWidget.cpp index 9c8dc78eb52..f344c6d910a 100644 --- a/Userland/Applications/ClockSettings/ClockSettingsWidget.cpp +++ b/Userland/Applications/ClockSettings/ClockSettingsWidget.cpp @@ -7,6 +7,7 @@ #include "ClockSettingsWidget.h" #include #include +#include #include #include @@ -16,6 +17,7 @@ ClockSettingsWidget::ClockSettingsWidget() m_24_hour_radio = *find_descendant_of_type_named("24hour_radio"); auto& twelve_hour_radio = *find_descendant_of_type_named("12hour_radio"); + m_show_seconds_checkbox = *find_descendant_of_type_named("seconds_checkbox"); auto& custom_radio = *find_descendant_of_type_named("custom_radio"); custom_radio.set_checked(true); @@ -23,16 +25,23 @@ ClockSettingsWidget::ClockSettingsWidget() m_custom_format_input->set_text(Config::read_string("Taskbar", "Clock", "TimeFormat")); m_24_hour_radio->on_checked = [&](bool) { + m_show_seconds_checkbox->set_enabled(true); m_custom_format_input->set_enabled(false); - m_custom_format_input->set_text("%T"); + update_time_format_string(); }; twelve_hour_radio.on_checked = [&](bool) { + m_show_seconds_checkbox->set_enabled(true); m_custom_format_input->set_enabled(false); - m_custom_format_input->set_text("%I:%M %p"); + update_time_format_string(); + }; + + m_show_seconds_checkbox->on_checked = [&](bool) { + update_time_format_string(); }; custom_radio.on_checked = [&](bool) { + m_show_seconds_checkbox->set_enabled(false); m_custom_format_input->set_enabled(true); }; } @@ -45,5 +54,15 @@ void ClockSettingsWidget::apply_settings() void ClockSettingsWidget::reset_default_values() { m_24_hour_radio->set_checked(true); + m_show_seconds_checkbox->set_checked(true); Config::write_string("Taskbar", "Clock", "TimeFormat", "%T"); } + +void ClockSettingsWidget::update_time_format_string() +{ + bool show_seconds = m_show_seconds_checkbox->is_checked(); + if (m_24_hour_radio->is_checked()) + m_custom_format_input->set_text(show_seconds ? "%T" : "%R"); + else + m_custom_format_input->set_text(show_seconds ? "%r" : "%I:%M %p"); +} diff --git a/Userland/Applications/ClockSettings/ClockSettingsWidget.gml b/Userland/Applications/ClockSettings/ClockSettingsWidget.gml index f6f66dc92db..6697bc6f190 100644 --- a/Userland/Applications/ClockSettings/ClockSettingsWidget.gml +++ b/Userland/Applications/ClockSettings/ClockSettingsWidget.gml @@ -8,7 +8,7 @@ @GUI::GroupBox { title: "Time Format" shrink_to_fit: false - fixed_height: 160 + fixed_height: 200 layout: @GUI::VerticalBoxLayout { margins: [16, 8, 8] } @@ -26,14 +26,21 @@ @GUI::RadioButton { name: "24hour_radio" - text: "24-hour (12:34:56)" + text: "24-hour" } @GUI::RadioButton { name: "12hour_radio" - text: "12-hour (12:34 a.m)" + text: "12-hour" } + @GUI::CheckBox { + name: "seconds_checkbox" + text: "Show seconds" + } + + @GUI::HorizontalSeparator {} + @GUI::RadioButton { name: "custom_radio" text: "Custom:" diff --git a/Userland/Applications/ClockSettings/ClockSettingsWidget.h b/Userland/Applications/ClockSettings/ClockSettingsWidget.h index 35f5becc62b..3017b489e66 100644 --- a/Userland/Applications/ClockSettings/ClockSettingsWidget.h +++ b/Userland/Applications/ClockSettings/ClockSettingsWidget.h @@ -18,7 +18,10 @@ private: virtual void apply_settings() override; virtual void reset_default_values() override; + void update_time_format_string(); + RefPtr m_24_hour_radio; + RefPtr m_show_seconds_checkbox; RefPtr m_custom_format_input; String m_date_format;