diff --git a/Chronos.pro b/Chronos.pro index 639e8c8..f702758 100644 --- a/Chronos.pro +++ b/Chronos.pro @@ -108,7 +108,7 @@ HEADERS += \ sources/models/year.h FORMS += \ - sources/weekoption.ui \ + ui/weekoption.ui \ ui/configurationdialog.ui \ ui/breakdialog.ui \ ui/aboutbox.ui \ diff --git a/Chronos.pro.user b/Chronos.pro.user index d8e6d99..d120d41 100644 --- a/Chronos.pro.user +++ b/Chronos.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/sources/mainwindow.cpp b/sources/mainwindow.cpp index a6ecd5e..f9bcc38 100644 --- a/sources/mainwindow.cpp +++ b/sources/mainwindow.cpp @@ -188,6 +188,7 @@ void MainWindow::compute_time() { updateStartLabel(); updateBreakLabel(); updateEndLabel(); + updateWeekTime(); updateValidIcon(); updateWarningIcon(); @@ -222,6 +223,21 @@ void MainWindow::updateWarningIcon() { ui->fridayWarning->setVisible(current_week->getFri()->has_warning()); } +void MainWindow::updateWeekTime() +{ + double t = (current_week->total() + current_week->getTimeDeltaInHours()) - week_template->total(); + if (t > 0) { + ui->overtime_time_label_week->setText(Tools::double_to_string_time(t)); + ui->late_time_label_week->setText("0h"); + } else if(t < 0) { + ui->late_time_label_week->setText(Tools::double_to_string_time(-t)); + ui->overtime_time_label_week->setText("0h"); + } else { + ui->overtime_time_label_week->setText("0h"); + ui->late_time_label_week->setText("0h"); + } +} + void MainWindow::updateStartLabel() { ui->monStartLabel->setText(current_week->getMon()->get_start().toString("HH:mm")); ui->tueStartLabel->setText(current_week->getTue()->get_start().toString("HH:mm")); diff --git a/sources/mainwindow.h b/sources/mainwindow.h index fb07a4e..74e0e2e 100644 --- a/sources/mainwindow.h +++ b/sources/mainwindow.h @@ -58,6 +58,7 @@ private: void highlightDayOfWeek(); void updateValidIcon(); void updateWarningIcon(); + void updateWeekTime(); QString get_save_file_path(); Identifier get_identifier(QString objectName); diff --git a/sources/weekoption.cpp b/sources/weekoption.cpp index 6884e66..47e7be9 100644 --- a/sources/weekoption.cpp +++ b/sources/weekoption.cpp @@ -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)); } diff --git a/sources/weekoption.h b/sources/weekoption.h index ef88da2..c9ee6f4 100644 --- a/sources/weekoption.h +++ b/sources/weekoption.h @@ -4,6 +4,7 @@ #include #include "models/week.h" +#include "tools.h" namespace Ui { class WeekOption; @@ -24,6 +25,8 @@ private slots: private: Ui::WeekOption *ui; + void compute(); + int time_delta; }; diff --git a/ui/mainwindow.ui b/ui/mainwindow.ui index 8360806..cbb7559 100644 --- a/ui/mainwindow.ui +++ b/ui/mainwindow.ui @@ -38,224 +38,12 @@ false - - - - 230 - 9 - 20 - 81 - - - - Qt::Vertical - - - - - - 249 - 19 - 164 - 62 - - - - - - - - 59 - 59 - - - - - 59 - 59 - - - - border-image: url(:/clock/pictures/sport.png) 0 0 0 0 stretch stretch; - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - - - - font-size: 14px; - - - Retard (Total) - - - - - - - font-size: 28px; -color: white; - - - 0h - - - - - - - - - - - 13 - 19 - 227 - 62 - - - - - - - - 59 - 59 - - - - - 59 - 59 - - - - border-image: url(:/clock/pictures/clock-8-128.png) 0 0 0 0 stretch stretch; - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - - - - font-size: 14px; - - - Temps total (Semaine) - - - - - - - font-size: 28px; -color: white; - - - 0h - - - - - - - - - - - 440 - 20 - 168 - 62 - - - - - - - - 59 - 59 - - - - - 59 - 59 - - - - border-image: url(:/clock/pictures/calendar.png) 0 0 0 0 stretch stretch; - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - - - - font-size: 14px; - - - Avance (Total) - - - - - - - font-size: 28px; -color: white; - - - 0h - - - - - - - - - - - 420 - 10 - 20 - 81 - - - - Qt::Vertical - - - 670 + 640 530 - 261 + 291 31 @@ -267,7 +55,7 @@ color: white; 44 - 120 + 138 861 388 @@ -1698,7 +1486,7 @@ font-size: 22px; 800 10 111 - 90 + 111 @@ -1774,7 +1562,7 @@ font-size: 22px; 0 - 100 + 129 951 16 @@ -1786,7 +1574,7 @@ font-size: 22px; - 570 + 540 530 91 31 @@ -1796,6 +1584,253 @@ font-size: 22px; Options + + + + 13 + 7 + 771 + 133 + + + + + QLayout::SetFixedSize + + + + + + + + 59 + 59 + + + + + 59 + 59 + + + + border-image: url(:/clock/pictures/clock-8-128.png) 0 0 0 0 stretch stretch; + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + + font-size: 14px; + + + Temps total (Semaine) + + + + + + + font-size: 50px; +color: white; + + + 0h + + + + + + + + + + + Qt::Vertical + + + + + + + + + + 59 + 59 + + + + + 59 + 59 + + + + border-image: url(:/clock/pictures/sport.png) 0 0 0 0 stretch stretch; + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + + font-size: 14px; + + + Retard (Total) + + + + + + + font-size: 28px; +color: white; + + + 0h + + + + + + + Qt::Horizontal + + + + + + + font-size: 14px; + + + <html><head/><body><p>Retard (Semaine)</p></body></html> + + + + + + + font-size: 20px; +color: white; + + + 0h + + + + + + + + + + + Qt::Vertical + + + + + + + + + + 59 + 59 + + + + + 59 + 59 + + + + border-image: url(:/clock/pictures/calendar.png) 0 0 0 0 stretch stretch; + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + + font-size: 14px; + + + Avance (Total) + + + + + + + font-size: 28px; +color: white; + + + 0h + + + + + + + Qt::Horizontal + + + + + + + font-size: 14px; + + + <html><head/><body><p>Avance (Semaine)</p></body></html> + + + + + + + font-size: 20px; +color: white; + + + 0h + + + + + + + + + layoutWidget line layoutWidget diff --git a/sources/weekoption.ui b/ui/weekoption.ui similarity index 62% rename from sources/weekoption.ui rename to ui/weekoption.ui index f8c9743..be540cf 100644 --- a/sources/weekoption.ui +++ b/ui/weekoption.ui @@ -67,7 +67,7 @@ 10 44 - 131 + 161 18 @@ -91,10 +91,10 @@ - 142 - 55 - 131 - 16 + 172 + 52 + 101 + 20 @@ -120,6 +120,68 @@ Qt::Horizontal + + + + 10 + 90 + 156 + 62 + + + + + + + + 59 + 59 + + + + + 59 + 59 + + + + border-image: url(:/clock/pictures/clock-8-128.png) 0 0 0 0 stretch stretch; + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + + font-size: 14px; + + + Temps total + + + + + + + font-size: 28px; +color: white; + + + 0h + + + + + + +