aboutsummaryrefslogtreecommitdiff
path: root/src/aoclocklabel.cpp
diff options
context:
space:
mode:
authoroldmud0 <oldmud0@users.noreply.github.com>2021-03-06 15:01:54 -0600
committerGitHub <noreply@github.com>2021-03-07 00:01:54 +0300
commit2cbb5c95ef276f14759e41af22c8363d7afb0194 (patch)
tree1427e9eabad63cec6ed3ce46bc1c739bacc0907b /src/aoclocklabel.cpp
parent08fd15acda49bef91c02bdf3a8744db597494d10 (diff)
Fix timer using 32-bit ints instead of 64-bit ints (#487)
Diffstat (limited to 'src/aoclocklabel.cpp')
-rw-r--r--src/aoclocklabel.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/aoclocklabel.cpp b/src/aoclocklabel.cpp
index 4c9c4819..67a82fe5 100644
--- a/src/aoclocklabel.cpp
+++ b/src/aoclocklabel.cpp
@@ -7,24 +7,25 @@ void AOClockLabel::start()
timer.start(1000 / 60, this);
}
-void AOClockLabel::start(int msecs)
+void AOClockLabel::start(qint64 msecs)
{
this->set(msecs);
this->start();
}
-void AOClockLabel::set(int msecs, bool update_text)
+void AOClockLabel::set(qint64 msecs, bool update_text)
{
- target_time = QTime::currentTime().addMSecs(msecs);
+ target_time = QDateTime::currentDateTime().addMSecs(msecs);
if (update_text)
{
- if (QTime::currentTime() >= target_time)
+ if (QDateTime::currentDateTime() >= target_time)
{
this->setText("00:00:00.000");
}
else
{
- QTime timeleft = QTime(0,0).addMSecs(QTime::currentTime().msecsTo(target_time));
+ qint64 ms_left = QDateTime::currentDateTime().msecsTo(target_time);
+ QTime timeleft = QTime(0, 0).addMSecs(ms_left % (1000 * 3600 * 24));
QString timestring = timeleft.toString("hh:mm:ss.zzz");
this->setText(timestring);
}
@@ -45,12 +46,13 @@ void AOClockLabel::stop()
void AOClockLabel::timerEvent(QTimerEvent *event)
{
if (event->timerId() == timer.timerId()) {
- if (QTime::currentTime() >= target_time)
+ if (QDateTime::currentDateTime() >= target_time)
{
this->stop();
return;
}
- QTime timeleft = QTime(0,0).addMSecs(QTime::currentTime().msecsTo(target_time));
+ qint64 ms_left = QDateTime::currentDateTime().msecsTo(target_time);
+ QTime timeleft = QTime(0, 0).addMSecs(ms_left % (1000 * 3600 * 24));
QString timestring = timeleft.toString("hh:mm:ss.zzz");
this->setText(timestring);
} else {