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

@@ -108,7 +108,7 @@ HEADERS += \
sources/models/year.h sources/models/year.h
FORMS += \ FORMS += \
sources/weekoption.ui \ ui/weekoption.ui \
ui/configurationdialog.ui \ ui/configurationdialog.ui \
ui/breakdialog.ui \ ui/breakdialog.ui \
ui/aboutbox.ui \ ui/aboutbox.ui \

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject> <!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 6.0.2, 2022-04-09T13:59:03. --> <!-- Written by QtCreator 6.0.2, 2022-04-09T20:00:14. -->
<qtcreator> <qtcreator>
<data> <data>
<variable>EnvironmentId</variable> <variable>EnvironmentId</variable>

View File

@@ -188,6 +188,7 @@ void MainWindow::compute_time() {
updateStartLabel(); updateStartLabel();
updateBreakLabel(); updateBreakLabel();
updateEndLabel(); updateEndLabel();
updateWeekTime();
updateValidIcon(); updateValidIcon();
updateWarningIcon(); updateWarningIcon();
@@ -222,6 +223,21 @@ void MainWindow::updateWarningIcon() {
ui->fridayWarning->setVisible(current_week->getFri()->has_warning()); 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() { void MainWindow::updateStartLabel() {
ui->monStartLabel->setText(current_week->getMon()->get_start().toString("HH:mm")); ui->monStartLabel->setText(current_week->getMon()->get_start().toString("HH:mm"));
ui->tueStartLabel->setText(current_week->getTue()->get_start().toString("HH:mm")); ui->tueStartLabel->setText(current_week->getTue()->get_start().toString("HH:mm"));

View File

@@ -58,6 +58,7 @@ private:
void highlightDayOfWeek(); void highlightDayOfWeek();
void updateValidIcon(); void updateValidIcon();
void updateWarningIcon(); void updateWarningIcon();
void updateWeekTime();
QString get_save_file_path(); QString get_save_file_path();
Identifier get_identifier(QString objectName); Identifier get_identifier(QString objectName);

View File

@@ -8,6 +8,7 @@ WeekOption::WeekOption(Week *w, QWidget *parent) :
ui->setupUi(this); ui->setupUi(this);
this->time_delta = w->getTimeDelta(); this->time_delta = w->getTimeDelta();
ui->time_delta_spinbox->setValue(time_delta); ui->time_delta_spinbox->setValue(time_delta);
compute();
connect(ui->time_delta_spinbox, &QSpinBox::valueChanged, this, &WeekOption::set_time_delta); 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) void WeekOption::set_time_delta(int value)
{ {
this->time_delta = 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));
} }

View File

@@ -4,6 +4,7 @@
#include <QDialog> #include <QDialog>
#include "models/week.h" #include "models/week.h"
#include "tools.h"
namespace Ui { namespace Ui {
class WeekOption; class WeekOption;
@@ -24,6 +25,8 @@ private slots:
private: private:
Ui::WeekOption *ui; Ui::WeekOption *ui;
void compute();
int time_delta; int time_delta;
}; };

View File

@@ -38,224 +38,12 @@
<bool>false</bool> <bool>false</bool>
</property> </property>
<widget class="QWidget" name="centralwidget"> <widget class="QWidget" name="centralwidget">
<widget class="Line" name="line">
<property name="geometry">
<rect>
<x>230</x>
<y>9</y>
<width>20</width>
<height>81</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>249</x>
<y>19</y>
<width>164</width>
<height>62</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QFrame" name="frame_2">
<property name="minimumSize">
<size>
<width>59</width>
<height>59</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>59</width>
<height>59</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/clock/pictures/sport.png) 0 0 0 0 stretch stretch;</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="label_4">
<property name="styleSheet">
<string notr="true">font-size: 14px;</string>
</property>
<property name="text">
<string>Retard (Total)</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="late_time_label">
<property name="styleSheet">
<string notr="true">font-size: 28px;
color: white;</string>
</property>
<property name="text">
<string>0h</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>13</x>
<y>19</y>
<width>227</width>
<height>62</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QFrame" name="frame">
<property name="minimumSize">
<size>
<width>59</width>
<height>59</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>59</width>
<height>59</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/clock/pictures/clock-8-128.png) 0 0 0 0 stretch stretch;</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_2">
<property name="styleSheet">
<string notr="true">font-size: 14px;</string>
</property>
<property name="text">
<string>Temps total (Semaine)</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="total_time_label">
<property name="styleSheet">
<string notr="true">font-size: 28px;
color: white;</string>
</property>
<property name="text">
<string>0h</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="layoutWidget_2">
<property name="geometry">
<rect>
<x>440</x>
<y>20</y>
<width>168</width>
<height>62</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QFrame" name="frame_3">
<property name="minimumSize">
<size>
<width>59</width>
<height>59</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>59</width>
<height>59</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/clock/pictures/calendar.png) 0 0 0 0 stretch stretch;</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QLabel" name="label_6">
<property name="styleSheet">
<string notr="true">font-size: 14px;</string>
</property>
<property name="text">
<string>Avance (Total)</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="overtime_time_label">
<property name="styleSheet">
<string notr="true">font-size: 28px;
color: white;</string>
</property>
<property name="text">
<string>0h</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="Line" name="line_2">
<property name="geometry">
<rect>
<x>420</x>
<y>10</y>
<width>20</width>
<height>81</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
<widget class="QPushButton" name="template_settings_button"> <widget class="QPushButton" name="template_settings_button">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>670</x> <x>640</x>
<y>530</y> <y>530</y>
<width>261</width> <width>291</width>
<height>31</height> <height>31</height>
</rect> </rect>
</property> </property>
@@ -267,7 +55,7 @@ color: white;</string>
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>44</x> <x>44</x>
<y>120</y> <y>138</y>
<width>861</width> <width>861</width>
<height>388</height> <height>388</height>
</rect> </rect>
@@ -1698,7 +1486,7 @@ font-size: 22px;</string>
<x>800</x> <x>800</x>
<y>10</y> <y>10</y>
<width>111</width> <width>111</width>
<height>90</height> <height>111</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
@@ -1774,7 +1562,7 @@ font-size: 22px;</string>
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>100</y> <y>129</y>
<width>951</width> <width>951</width>
<height>16</height> <height>16</height>
</rect> </rect>
@@ -1786,7 +1574,7 @@ font-size: 22px;</string>
<widget class="QPushButton" name="week_options_button"> <widget class="QPushButton" name="week_options_button">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>570</x> <x>540</x>
<y>530</y> <y>530</y>
<width>91</width> <width>91</width>
<height>31</height> <height>31</height>
@@ -1796,6 +1584,253 @@ font-size: 22px;</string>
<string>Options</string> <string>Options</string>
</property> </property>
</widget> </widget>
<widget class="QWidget" name="">
<property name="geometry">
<rect>
<x>13</x>
<y>7</y>
<width>771</width>
<height>133</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="sizeConstraint">
<enum>QLayout::SetFixedSize</enum>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QFrame" name="frame">
<property name="minimumSize">
<size>
<width>59</width>
<height>59</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>59</width>
<height>59</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/clock/pictures/clock-8-128.png) 0 0 0 0 stretch stretch;</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_2">
<property name="styleSheet">
<string notr="true">font-size: 14px;</string>
</property>
<property name="text">
<string>Temps total (Semaine)</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="total_time_label">
<property name="styleSheet">
<string notr="true">font-size: 50px;
color: white;</string>
</property>
<property name="text">
<string>0h</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QFrame" name="frame_2">
<property name="minimumSize">
<size>
<width>59</width>
<height>59</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>59</width>
<height>59</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/clock/pictures/sport.png) 0 0 0 0 stretch stretch;</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="label_4">
<property name="styleSheet">
<string notr="true">font-size: 14px;</string>
</property>
<property name="text">
<string>Retard (Total)</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="late_time_label">
<property name="styleSheet">
<string notr="true">font-size: 28px;
color: white;</string>
</property>
<property name="text">
<string>0h</string>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_29">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_8">
<property name="styleSheet">
<string notr="true">font-size: 14px;</string>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Retard (Semaine)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="late_time_label_week">
<property name="styleSheet">
<string notr="true">font-size: 20px;
color: white;</string>
</property>
<property name="text">
<string>0h</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QFrame" name="frame_3">
<property name="minimumSize">
<size>
<width>59</width>
<height>59</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>59</width>
<height>59</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/clock/pictures/calendar.png) 0 0 0 0 stretch stretch;</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QLabel" name="label_6">
<property name="styleSheet">
<string notr="true">font-size: 14px;</string>
</property>
<property name="text">
<string>Avance (Total)</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="overtime_time_label">
<property name="styleSheet">
<string notr="true">font-size: 28px;
color: white;</string>
</property>
<property name="text">
<string>0h</string>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_28">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_9">
<property name="styleSheet">
<string notr="true">font-size: 14px;</string>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Avance (Semaine)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="overtime_time_label_week">
<property name="styleSheet">
<string notr="true">font-size: 20px;
color: white;</string>
</property>
<property name="text">
<string>0h</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<zorder>layoutWidget</zorder> <zorder>layoutWidget</zorder>
<zorder>line</zorder> <zorder>line</zorder>
<zorder>layoutWidget</zorder> <zorder>layoutWidget</zorder>

View File

@@ -67,7 +67,7 @@
<rect> <rect>
<x>10</x> <x>10</x>
<y>44</y> <y>44</y>
<width>131</width> <width>161</width>
<height>18</height> <height>18</height>
</rect> </rect>
</property> </property>
@@ -91,10 +91,10 @@
<widget class="Line" name="line"> <widget class="Line" name="line">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>142</x> <x>172</x>
<y>55</y> <y>52</y>
<width>131</width> <width>101</width>
<height>16</height> <height>20</height>
</rect> </rect>
</property> </property>
<property name="lineWidth"> <property name="lineWidth">
@@ -120,6 +120,68 @@
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
</widget> </widget>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>90</y>
<width>156</width>
<height>62</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QFrame" name="frame">
<property name="minimumSize">
<size>
<width>59</width>
<height>59</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>59</width>
<height>59</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/clock/pictures/clock-8-128.png) 0 0 0 0 stretch stretch;</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_4">
<property name="styleSheet">
<string notr="true">font-size: 14px;</string>
</property>
<property name="text">
<string>Temps total</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="total_label">
<property name="styleSheet">
<string notr="true">font-size: 28px;
color: white;</string>
</property>
<property name="text">
<string>0h</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget> </widget>
<resources/> <resources/>
<connections> <connections>