@@ -7,24 +7,25 @@ void AOClockLabel::start()
77 timer.start (1000 / 60 , this );
88}
99
10- void AOClockLabel::start (int msecs)
10+ void AOClockLabel::start (qint64 msecs)
1111{
1212 this ->set (msecs);
1313 this ->start ();
1414}
1515
16- void AOClockLabel::set (int msecs, bool update_text)
16+ void AOClockLabel::set (qint64 msecs, bool update_text)
1717{
18- target_time = QTime::currentTime ().addMSecs (msecs);
18+ target_time = QDateTime::currentDateTime ().addMSecs (msecs);
1919 if (update_text)
2020 {
21- if (QTime::currentTime () >= target_time)
21+ if (QDateTime::currentDateTime () >= target_time)
2222 {
2323 this ->setText (" 00:00:00.000" );
2424 }
2525 else
2626 {
27- QTime timeleft = QTime (0 ,0 ).addMSecs (QTime::currentTime ().msecsTo (target_time));
27+ qint64 ms_left = QDateTime::currentDateTime ().msecsTo (target_time);
28+ QTime timeleft = QTime (0 , 0 ).addMSecs (ms_left % (1000 * 3600 * 24 ));
2829 QString timestring = timeleft.toString (" hh:mm:ss.zzz" );
2930 this ->setText (timestring);
3031 }
@@ -45,12 +46,13 @@ void AOClockLabel::stop()
4546void AOClockLabel::timerEvent (QTimerEvent *event)
4647{
4748 if (event->timerId () == timer.timerId ()) {
48- if (QTime::currentTime () >= target_time)
49+ if (QDateTime::currentDateTime () >= target_time)
4950 {
5051 this ->stop ();
5152 return ;
5253 }
53- QTime timeleft = QTime (0 ,0 ).addMSecs (QTime::currentTime ().msecsTo (target_time));
54+ qint64 ms_left = QDateTime::currentDateTime ().msecsTo (target_time);
55+ QTime timeleft = QTime (0 , 0 ).addMSecs (ms_left % (1000 * 3600 * 24 ));
5456 QString timestring = timeleft.toString (" hh:mm:ss.zzz" );
5557 this ->setText (timestring);
5658 } else {
0 commit comments