When more then 10 seconds has elapsed the timers switches to a self adjusting

algorithm so it keeps ticking at exactly once a second.
This commit is contained in:
Eelke Klein 2017-01-08 19:59:55 +01:00
parent 5f3ddb80c6
commit 726d67bc30

View file

@ -355,10 +355,18 @@ void MainWindow::updateTimer()
std::chrono::duration<float, std::milli> diff = nu - m_startTime;
m_timeElapsedLabel->setText(msfloatToHumanReadableString(diff.count()));
if (m_timer) {
int interval = int(diff.count()) / 25;
interval = std::max(interval, 18);
interval = std::min(interval, 1000);
int ms = diff.count();
int interval = 18;
if (ms >= 10000) {
int rem = ms % 1000;
interval = 1000 - rem;
}
else if (ms >= 1000) {
interval = 100;
}
m_timer->start(interval);
}
}