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:
parent
5f3ddb80c6
commit
726d67bc30
1 changed files with 11 additions and 3 deletions
|
|
@ -355,10 +355,18 @@ void MainWindow::updateTimer()
|
||||||
std::chrono::duration<float, std::milli> diff = nu - m_startTime;
|
std::chrono::duration<float, std::milli> diff = nu - m_startTime;
|
||||||
m_timeElapsedLabel->setText(msfloatToHumanReadableString(diff.count()));
|
m_timeElapsedLabel->setText(msfloatToHumanReadableString(diff.count()));
|
||||||
|
|
||||||
|
|
||||||
if (m_timer) {
|
if (m_timer) {
|
||||||
int interval = int(diff.count()) / 25;
|
int ms = diff.count();
|
||||||
interval = std::max(interval, 18);
|
int interval = 18;
|
||||||
interval = std::min(interval, 1000);
|
if (ms >= 10000) {
|
||||||
|
int rem = ms % 1000;
|
||||||
|
interval = 1000 - rem;
|
||||||
|
}
|
||||||
|
else if (ms >= 1000) {
|
||||||
|
interval = 100;
|
||||||
|
}
|
||||||
|
|
||||||
m_timer->start(interval);
|
m_timer->start(interval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue