mirror of
https://github.com/slint-ui/slint.git
synced 2025-09-28 04:45:13 +00:00
Clean up the clock code a little bit
This commit is contained in:
parent
50d2fa88c7
commit
760a6ef6c5
1 changed files with 9 additions and 5 deletions
|
@ -37,17 +37,21 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
void update_clock();
|
||||
|
||||
sixtyfps::Timer clock_update_timer;
|
||||
};
|
||||
|
||||
ClockWidget::ClockWidget()
|
||||
: clock_update_timer(std::chrono::seconds(1), [=]() {
|
||||
std::string current_time = fmt::format("{:%H:%M:%S}", fmt::localtime(std::time(nullptr)));
|
||||
set_property("time", sixtyfps::SharedString(current_time));
|
||||
})
|
||||
ClockWidget::ClockWidget() : clock_update_timer(std::chrono::seconds(1), [=]() { update_clock() })
|
||||
{
|
||||
}
|
||||
|
||||
void ClockWidget::update_clock()
|
||||
{
|
||||
std::string current_time = fmt::format("{:%H:%M:%S}", fmt::localtime(std::time(nullptr)));
|
||||
set_property("time", sixtyfps::SharedString(current_time));
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
DashboardBuilder builder;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue