Permalink
Browse files

Panel WorldClock plugin: restart timer only if update interval is long

  • Loading branch information...
1 parent 4f768c7 commit 5c234d164e2cfd6c8d8b68a432d56110fd60bee2 @kuzmas kuzmas committed Nov 28, 2012
Showing with 3 additions and 12 deletions.
  1. +3 −12 razorqt-panel/plugin-worldclock/razorworldclock.cpp
@@ -123,7 +123,7 @@ void RazorWorldClock::timeout(void)
UDate now = Calendar::getNow();
- if ((static_cast<long long>(now) % 1000) > 200)
+ if ((mTimer->interval() >= 1000) && ((static_cast<long long>(now) % 1000) > 200))
restartTimer(mTimer->interval());
mFormat->format(now, str, status);
@@ -203,23 +203,14 @@ void RazorWorldClock::restartTimer(int timerInterval)
mTimer->stop();
mTimer->setInterval(timerInterval);
- switch (timerInterval)
- {
- case 1:
- case 10:
- case 100:
+ if (timerInterval < 1000)
mTimer->start();
- break;
-
- case 1000:
- case 60000:
+ else
{
int delay = static_cast<int>((timerInterval + 100 - (static_cast<long long>(Calendar::getNow()) % timerInterval)) % timerInterval);
QTimer::singleShot(delay, this, SLOT(timeout()));
QTimer::singleShot(delay, mTimer, SLOT(start()));
}
- break;
- }
}
void RazorWorldClock::updateTimezone(void)

0 comments on commit 5c234d1

Please sign in to comment.