]> git.tdb.fi Git - r2c2.git/commitdiff
Keep UI better in sync with the clock
authorMikko Rasa <tdb@tdb.fi>
Sun, 29 Mar 2015 22:31:36 +0000 (01:31 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sun, 29 Mar 2015 22:31:36 +0000 (01:31 +0300)
source/engineer/clockdialog.cpp
source/engineer/clockdialog.h
source/engineer/mainwindow.cpp
source/engineer/mainwindow.h

index c156013861e0e817dfc6e8eda5e84f50544bb864..ba73a5ec0fbc4ea8441134fae83080e4318c2a0e 100644 (file)
@@ -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;
index f4fb54b05196ac0fc7831adac307da9dd3f8bf4b..a1a1f724fd6e03ffcf0d519d1ad3f49ec9c99956 100644 (file)
@@ -22,7 +22,7 @@ public:
        ClockDialog(Engineer &);
 
 private:
-       void minute_changed();
+       void update_time();
        void set_rate();
        void stop_clicked();
        void set_time();
index 73188a207a56d935e774884de7ab8a3bd3165a4f..51abbfd771e2993075223329303970ed989ae6b3 100644 (file)
@@ -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;
index f707111275a40b0790b3068dbc4bcee20086e6dc..d8e6c54e76cf32c7e346622ea93381cc7865a633 100644 (file)
@@ -32,7 +32,7 @@ private:
        void clock_clicked();
        void power_event(bool);
        void halt_event(bool);
-       void clock_minute();
+       void update_clock();
 };
 
 #endif