From: Mikko Rasa Date: Sun, 29 Mar 2015 22:31:36 +0000 (+0300) Subject: Keep UI better in sync with the clock X-Git-Url: http://git.tdb.fi/?p=r2c2.git;a=commitdiff_plain;h=d6516b0d9faa26fe6c64000c34f8d820f91ac479 Keep UI better in sync with the clock --- diff --git a/source/engineer/clockdialog.cpp b/source/engineer/clockdialog.cpp index c156013..ba73a5e 100644 --- a/source/engineer/clockdialog.cpp +++ b/source/engineer/clockdialog.cpp @@ -34,10 +34,12 @@ ClockDialog::ClockDialog(Engineer &engineer): stack.arrange(*get_item(widgets, "placeholder")); add(*(new ClockWidget(clock))); - clock.signal_minute.connect(sigc::mem_fun(this, &ClockDialog::minute_changed)); + clock.signal_minute.connect(sigc::mem_fun(this, &ClockDialog::update_time)); + clock.signal_discontinuity.connect(sigc::mem_fun(this, &ClockDialog::update_time)); + update_time(); } -void ClockDialog::minute_changed() +void ClockDialog::update_time() { Time::TimeDelta time = clock.get_current_time(); unsigned hour = time/Time::hour; diff --git a/source/engineer/clockdialog.h b/source/engineer/clockdialog.h index f4fb54b..a1a1f72 100644 --- a/source/engineer/clockdialog.h +++ b/source/engineer/clockdialog.h @@ -22,7 +22,7 @@ public: ClockDialog(Engineer &); private: - void minute_changed(); + void update_time(); void set_rate(); void stop_clicked(); void set_time(); diff --git a/source/engineer/mainwindow.cpp b/source/engineer/mainwindow.cpp index 73188a2..51abbfd 100644 --- a/source/engineer/mainwindow.cpp +++ b/source/engineer/mainwindow.cpp @@ -40,7 +40,8 @@ MainWindow::MainWindow(Engineer &e): driver.signal_power.connect(sigc::mem_fun(this, &MainWindow::power_event)); driver.signal_halt.connect(sigc::mem_fun(this, &MainWindow::halt_event)); - engineer.get_layout().get_clock().signal_minute.connect(sigc::mem_fun(this, &MainWindow::clock_minute)); + engineer.get_layout().get_clock().signal_minute.connect(sigc::mem_fun(this, &MainWindow::update_clock)); + engineer.get_layout().get_clock().signal_discontinuity.connect(sigc::mem_fun(this, &MainWindow::update_clock)); } void MainWindow::set_status_text(const string &txt) @@ -98,7 +99,7 @@ void MainWindow::halt_event(bool h) ind_halt->set_active(h); } -void MainWindow::clock_minute() +void MainWindow::update_clock() { const Time::TimeDelta &time = engineer.get_layout().get_clock().get_current_time(); unsigned minute = time/Time::min; diff --git a/source/engineer/mainwindow.h b/source/engineer/mainwindow.h index f707111..d8e6c54 100644 --- a/source/engineer/mainwindow.h +++ b/source/engineer/mainwindow.h @@ -32,7 +32,7 @@ private: void clock_clicked(); void power_event(bool); void halt_event(bool); - void clock_minute(); + void update_clock(); }; #endif