mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:47:44 +00:00
ClockSettings+Taskbar: Add settings for taskbar clock format
This commit is contained in:
parent
36b6356ce5
commit
5bb0b6ba7a
13 changed files with 334 additions and 179 deletions
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
#include "ClockWidget.h"
|
||||
#include <LibConfig/Client.h>
|
||||
#include <LibCore/Process.h>
|
||||
#include <LibGUI/Painter.h>
|
||||
#include <LibGUI/SeparatorWidget.h>
|
||||
|
@ -20,9 +21,7 @@ ClockWidget::ClockWidget()
|
|||
set_frame_shadow(Gfx::FrameShadow::Sunken);
|
||||
set_frame_thickness(1);
|
||||
|
||||
m_time_width = font().width("22:22:22");
|
||||
|
||||
set_fixed_size(m_time_width + 20, 21);
|
||||
update_format(Config::read_string("Taskbar", "Clock", "TimeFormat", "%T"));
|
||||
|
||||
m_timer = add<Core::Timer>(1000, [this] {
|
||||
static time_t last_update_time;
|
||||
|
@ -159,10 +158,17 @@ ClockWidget::ClockWidget()
|
|||
};
|
||||
}
|
||||
|
||||
void ClockWidget::update_format(String const& format)
|
||||
{
|
||||
m_time_format = format;
|
||||
m_time_width = font().width(Core::DateTime::create(122, 2, 22, 22, 22, 22).to_string(format));
|
||||
set_fixed_size(m_time_width + 20, 21);
|
||||
}
|
||||
|
||||
void ClockWidget::paint_event(GUI::PaintEvent& event)
|
||||
{
|
||||
GUI::Frame::paint_event(event);
|
||||
auto time_text = Core::DateTime::now().to_string("%T");
|
||||
auto time_text = Core::DateTime::now().to_string(m_time_format);
|
||||
GUI::Painter painter(*this);
|
||||
painter.add_clip_rect(frame_inner_rect());
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue