added hours to display

This commit is contained in:
2019-10-14 15:19:21 +02:00
parent d9f9d24165
commit b6592b6963
2 changed files with 8 additions and 6 deletions

View File

@@ -94,18 +94,20 @@ void MainWindow::shutdown()
void MainWindow::updateTime()
{
if (mTimeLeft == 0) {
ui->lbl_timer->setText("00:00");
ui->lbl_timer->setText("0:00:00");
shutdown();
mTimer.stop();
return;
}
QString m = QString::number(mTimeLeft / 60);
QString h = QString::number(mTimeLeft / 3600);
QString m = QString::number((mTimeLeft / 60) % 60);
QString s = QString::number(mTimeLeft % 60);
if (s.length() == 1) s = "0" + s;
if (m.length() == 1) m = "0" + m;
ui->lbl_timer->setText(m + ":" + s);
ui->lbl_timer->setText(h + ":" + m + ":" + s);
mTimeLeft--;
}
@@ -122,7 +124,7 @@ void MainWindow::timerToggled() {
} else {
mTimeLeft = -1;
mTimer.stop();
ui->lbl_timer->setText("-- : --");
ui->lbl_timer->setText("--:--:--");
ui->stackedWidget->setCurrentIndex(0);
}
}

View File

@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>279</width>
<width>281</width>
<height>118</height>
</rect>
</property>
@@ -145,7 +145,7 @@
<enum>QFrame::Sunken</enum>
</property>
<property name="text">
<string>-- : --</string>
<string>--:--:--</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>