Week late and overtime

This commit is contained in:
Aurélie Delhaie
2022-04-09 20:01:10 +02:00
parent deb49909d1
commit 92d0c14df7
8 changed files with 361 additions and 225 deletions

View File

@@ -8,6 +8,7 @@ WeekOption::WeekOption(Week *w, QWidget *parent) :
ui->setupUi(this);
this->time_delta = w->getTimeDelta();
ui->time_delta_spinbox->setValue(time_delta);
compute();
connect(ui->time_delta_spinbox, &QSpinBox::valueChanged, this, &WeekOption::set_time_delta);
}
@@ -24,4 +25,22 @@ int WeekOption::get_time_delta()
void WeekOption::set_time_delta(int value)
{
this->time_delta = value;
compute();
}
void WeekOption::compute()
{
int m = this->time_delta;
int h = 0;
while (m > 59) {
h++;
m -= 60;
}
QString minutes = "";
if (m >= 10) {
minutes = QString::number(m, 'g', 2);
} else {
minutes = QString("0%1").arg(QString::number(m, 'g', 2));
}
ui->total_label->setText(QString("%1h%2").arg(QString::number(h, 'g', 2), minutes));
}