Skip to content
This repository has been archived by the owner on Dec 17, 2017. It is now read-only.

Commit

Permalink
Panel WorldClock plugin: restart timer only if update interval is long
Browse files Browse the repository at this point in the history
  • Loading branch information
kuzmas committed Nov 28, 2012
1 parent 4f768c7 commit 5c234d1
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions razorqt-panel/plugin-worldclock/razorworldclock.cpp
Expand Up @@ -123,7 +123,7 @@ void RazorWorldClock::timeout(void)


UDate now = Calendar::getNow(); 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()); restartTimer(mTimer->interval());


mFormat->format(now, str, status); mFormat->format(now, str, status);
Expand Down Expand Up @@ -203,23 +203,14 @@ void RazorWorldClock::restartTimer(int timerInterval)
mTimer->stop(); mTimer->stop();
mTimer->setInterval(timerInterval); mTimer->setInterval(timerInterval);


switch (timerInterval) if (timerInterval < 1000)
{
case 1:
case 10:
case 100:
mTimer->start(); mTimer->start();
break; else

case 1000:
case 60000:
{ {
int delay = static_cast<int>((timerInterval + 100 - (static_cast<long long>(Calendar::getNow()) % timerInterval)) % timerInterval); int delay = static_cast<int>((timerInterval + 100 - (static_cast<long long>(Calendar::getNow()) % timerInterval)) % timerInterval);
QTimer::singleShot(delay, this, SLOT(timeout())); QTimer::singleShot(delay, this, SLOT(timeout()));
QTimer::singleShot(delay, mTimer, SLOT(start())); QTimer::singleShot(delay, mTimer, SLOT(start()));
} }
break;
}
} }


void RazorWorldClock::updateTimezone(void) void RazorWorldClock::updateTimezone(void)
Expand Down

0 comments on commit 5c234d1

Please sign in to comment.