mirror of
https://github.com/slint-ui/slint.git
synced 2025-09-28 21:04:47 +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,15 +37,19 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void update_clock();
|
||||||
|
|
||||||
sixtyfps::Timer clock_update_timer;
|
sixtyfps::Timer clock_update_timer;
|
||||||
};
|
};
|
||||||
|
|
||||||
ClockWidget::ClockWidget()
|
ClockWidget::ClockWidget() : clock_update_timer(std::chrono::seconds(1), [=]() { update_clock() })
|
||||||
: clock_update_timer(std::chrono::seconds(1), [=]() {
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClockWidget::update_clock()
|
||||||
|
{
|
||||||
std::string current_time = fmt::format("{:%H:%M:%S}", fmt::localtime(std::time(nullptr)));
|
std::string current_time = fmt::format("{:%H:%M:%S}", fmt::localtime(std::time(nullptr)));
|
||||||
set_property("time", sixtyfps::SharedString(current_time));
|
set_property("time", sixtyfps::SharedString(current_time));
|
||||||
})
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue