3 Commits

Author SHA1 Message Date
Alexis Delhaie
257bc67f61 Main window frameless + Switching to MSVC2019 2020-08-28 14:47:21 +02:00
Alexis Delhaie
ff64fa14d3 Merge branch 'master' of https://github.com/alexlegarnd/Chronos 2020-08-10 22:54:47 +02:00
Alexis Delhaie
63bd4b15f4 beta 3 2020-08-10 22:54:24 +02:00
6 changed files with 950 additions and 58 deletions

View File

@@ -7,10 +7,10 @@ CONFIG += c++17
# remove possible other optimization flags
QMAKE_CXXFLAGS_RELEASE -= -O
QMAKE_CXXFLAGS_RELEASE -= -O1
QMAKE_CXXFLAGS_RELEASE -= -O2
QMAKE_CXXFLAGS_RELEASE *= -O2
# add the desired -O3 if not present
QMAKE_CXXFLAGS_RELEASE *= -O3
# add the desired -O3 if not present, MinGW only
# QMAKE_CXXFLAGS_RELEASE *= -O3
RC_ICONS = icon.ico

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.12.4, 2020-08-02T22:16:12. -->
<!-- Written by QtCreator 4.12.4, 2020-08-28T14:45:30. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
@@ -74,17 +74,17 @@
<data>
<variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.15.0 MinGW 64-bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.15.0 MinGW 64-bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.qt5.5150.win64_mingw81_kit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.15.0 MSVC2019 64bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.15.0 MSVC2019 64bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.qt5.5150.win64_msvc2019_64_kit</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">1</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="bool">true</value>
<value type="int" key="EnableQmlDebugging">0</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:\Users\robof\OneDrive\Documents\build-Chronos-Desktop_Qt_5_15_0_MinGW_64_bit-Debug</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">C:/Users/robof/OneDrive/Documents/build-Chronos-Desktop_Qt_5_15_0_MinGW_64_bit-Debug</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:\Users\robof\OneDrive\Documents\build-Chronos-Desktop_Qt_5_15_0_MSVC2019_64bit-Debug</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">C:/Users/robof/OneDrive/Documents/build-Chronos-Desktop_Qt_5_15_0_MSVC2019_64bit-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@@ -134,8 +134,8 @@
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="bool">true</value>
<value type="int" key="EnableQmlDebugging">2</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:\Users\robof\OneDrive\Documents\build-Chronos-Desktop_Qt_5_15_0_MinGW_64_bit-Release</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">C:/Users/robof/OneDrive/Documents/build-Chronos-Desktop_Qt_5_15_0_MinGW_64_bit-Release</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:\Users\robof\OneDrive\Documents\build-Chronos-Desktop_Qt_5_15_0_MSVC2019_64bit-Release</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">C:/Users/robof/OneDrive/Documents/build-Chronos-Desktop_Qt_5_15_0_MSVC2019_64bit-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@@ -185,8 +185,8 @@
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
<value type="bool">true</value>
<value type="int" key="EnableQmlDebugging">0</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:\Users\robof\OneDrive\Documents\build-Chronos-Desktop_Qt_5_15_0_MinGW_64_bit-Profile</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">C:/Users/robof/OneDrive/Documents/build-Chronos-Desktop_Qt_5_15_0_MinGW_64_bit-Profile</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:\Users\robof\OneDrive\Documents\build-Chronos-Desktop_Qt_5_15_0_MSVC2019_64bit-Profile</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">C:/Users/robof/OneDrive/Documents/build-Chronos-Desktop_Qt_5_15_0_MSVC2019_64bit-Profile</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@@ -320,7 +320,7 @@
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
<value type="QString" key="RunConfiguration.WorkingDirectory"></value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">C:/Users/robof/OneDrive/Documents/build-Chronos-Desktop_Qt_5_15_0_MinGW_64_bit-Release</value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">C:/Users/robof/OneDrive/Documents/build-Chronos-Desktop_Qt_5_15_0_MSVC2019_64bit-Release</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>

View File

@@ -6,9 +6,31 @@ MainWindow::MainWindow(QWidget *parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->window_title->setText(this->windowTitle());
this->setWindowFlags(Qt::FramelessWindowHint);
init();
}
void MainWindow::mousePressEvent(QMouseEvent *event) {
m_nMouseClick_X_Coordinate = event->x();
m_nMouseClick_Y_Coordinate = event->y();
}
void MainWindow::mouseMoveEvent(QMouseEvent *event) {
if (isWidgetIsTitleBar()) {
move(event->globalX() - m_nMouseClick_X_Coordinate ,
event->globalY() - m_nMouseClick_Y_Coordinate);
}
}
bool MainWindow::isWidgetIsTitleBar() {
return (m_nMouseClick_X_Coordinate >= xmin &&
m_nMouseClick_X_Coordinate < xmax &&
m_nMouseClick_Y_Coordinate >= ymin &&
m_nMouseClick_Y_Coordinate < ymax);
}
MainWindow::~MainWindow()
{
delete ui;
@@ -33,6 +55,10 @@ void MainWindow::init() {
objectId.insert(ui->wed_button->objectName(), Identifier::wed);
objectId.insert(ui->thu_button->objectName(), Identifier::thu);
objectId.insert(ui->fri_button->objectName(), Identifier::fri);
xmax = ui->window_title->x() + ui->window_title->width();
xmin = ui->window_title->x();
ymax = ui->window_title->x() + ui->window_title->height();
ymin = ui->window_title->y();
connect(ui->aboutButton, &QPushButton::clicked, this, &MainWindow::open_about);
connect(ui->template_settings_button, &QPushButton::clicked, this, &MainWindow::edit_template);
connect(ui->dateEdit, &QDateEdit::dateTimeChanged, this, &MainWindow::compute_week_number);
@@ -41,6 +67,9 @@ void MainWindow::init() {
connect(ui->wed_button, &QPushButton::clicked, this, &MainWindow::edit);
connect(ui->thu_button, &QPushButton::clicked, this, &MainWindow::edit);
connect(ui->fri_button, &QPushButton::clicked, this, &MainWindow::edit);
highlightDayOfWeek();
if (QFile::exists(get_save_file_path())) {
open_save();
} else {
@@ -52,6 +81,33 @@ void MainWindow::init() {
compute_time();
}
void MainWindow::highlightDayOfWeek() {
int dayOfWeek = QDate::currentDate().dayOfWeek();
switch (dayOfWeek) {
case 1: {
ui->monLabel->setText(QString("> %1 <").arg(ui->monLabel->text()));
break;
}
case 2: {
ui->tueLabel->setText(QString("> %1 <").arg(ui->tueLabel->text()));
break;
}
case 3: {
ui->wedLabel->setText(QString("> %1 <").arg(ui->wedLabel->text()));
break;
}
case 4: {
ui->thuLabel->setText(QString("> %1 <").arg(ui->thuLabel->text()));
break;
}
case 5: {
ui->friLabel->setText(QString("> %1 <").arg(ui->friLabel->text()));
break;
}
default: break;
}
}
void MainWindow::set_date_to_now() {
auto date = QDate::currentDate();
ui->dateEdit->setDate(date);
@@ -131,6 +187,9 @@ void MainWindow::compute_time() {
ui->thu_time_label->setText(Tools::double_to_string_time(current_week.getThu().get_total()));
ui->fri_time_label->setText(Tools::double_to_string_time(current_week.getFri().get_total()));
ui->total_time_label->setText(Tools::double_to_string_time(current_week.total()));
updateStartLabel();
updateBreakLabel();
updateEndLabel();
double late = 0.0;
double overtime = 0.0;
@@ -146,6 +205,30 @@ void MainWindow::compute_time() {
ui->overtime_time_label->setText(Tools::double_to_string_time((overtime > 0.0) ? overtime : 0.0));
}
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"));
ui->wedStartLabel->setText(current_week.getWed().get_start().toString("HH:mm"));
ui->thuStartLabel->setText(current_week.getThu().get_start().toString("HH:mm"));
ui->friStartLabel->setText(current_week.getFri().get_start().toString("HH:mm"));
}
void MainWindow::updateBreakLabel() {
ui->monBreakLabel->setText(QString("%1 min.").arg(current_week.getMon().get_time_break()));
ui->tueBreakLabel->setText(QString("%1 min.").arg(current_week.getTue().get_time_break()));
ui->wedBreakLabel->setText(QString("%1 min.").arg(current_week.getWed().get_time_break()));
ui->thuBreakLabel->setText(QString("%1 min.").arg(current_week.getThu().get_time_break()));
ui->friBreakLabel->setText(QString("%1 min.").arg(current_week.getFri().get_time_break()));
}
void MainWindow::updateEndLabel() {
ui->monEndLabel->setText(current_week.getMon().get_end().toString("HH:mm"));
ui->tueEndLabel->setText(current_week.getTue().get_end().toString("HH:mm"));
ui->wedEndLabel->setText(current_week.getWed().get_end().toString("HH:mm"));
ui->thuEndLabel->setText(current_week.getThu().get_end().toString("HH:mm"));
ui->friEndLabel->setText(current_week.getFri().get_end().toString("HH:mm"));
}
void MainWindow::edit() {
QString name = QObject::sender()->objectName();
switch (get_identifier(name)) {

View File

@@ -7,6 +7,8 @@
#define SAVE_FILE_VERSION 1
#define KEY_SAVE_FILE_VERSION "version"
#include <QMouseEvent>
#include <QGraphicsView>
#include <QJsonArray>
#include <QMainWindow>
#include <QDir>
@@ -43,6 +45,13 @@ private:
void init();
void open_save();
void save_to_file();
// UI Update
void updateStartLabel();
void updateBreakLabel();
void updateEndLabel();
void highlightDayOfWeek();
QString get_save_file_path();
Identifier get_identifier(QString objectName);
Day modify_value(Day);
@@ -52,6 +61,16 @@ private:
QMap<int, Week> weeks;
QMap<QString, Identifier> objectId;
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
int m_nMouseClick_X_Coordinate;
int m_nMouseClick_Y_Coordinate;
int xmax;
int xmin;
int ymax;
int ymin;
inline bool isWidgetIsTitleBar();
public slots:
void compute_week_number(const QDateTime &dt);
void compute_time();

View File

@@ -10,7 +10,7 @@
<x>0</x>
<y>0</y>
<width>707</width>
<height>363</height>
<height>381</height>
</rect>
</property>
<property name="minimumSize">
@@ -22,7 +22,7 @@
<property name="maximumSize">
<size>
<width>707</width>
<height>363</height>
<height>381</height>
</size>
</property>
<property name="windowTitle">
@@ -91,7 +91,7 @@
<string notr="true">font-size: 12px;</string>
</property>
<property name="text">
<string>Version: 1.0.0 (Beta 2)</string>
<string>Version: 1.0.0 (Beta 4)</string>
</property>
</widget>
<widget class="QLabel" name="label_3">
@@ -107,7 +107,7 @@
<string notr="true">font-size: 12px;</string>
</property>
<property name="text">
<string>Made with Qt 5.15.0 MinGW 64bit (C++17)</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Made with Qt 5.15.0 MSVC2019 64bit (C++17) (&lt;a href=&quot;https://github.com/alexlegarnd/Chronos&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;Source Github&lt;/span&gt;&lt;/a&gt;)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
<widget class="QTextEdit" name="textEdit">
@@ -122,6 +122,9 @@
<property name="accessibleDescription">
<string notr="true"/>
</property>
<property name="styleSheet">
<string notr="true">font-size: 12px;</string>
</property>
<property name="undoRedoEnabled">
<bool>false</bool>
</property>
@@ -132,7 +135,7 @@
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:7.5pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:12px; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:10pt;&quot;&gt;Application icon: Alexis Delhaie (me)&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:10pt;&quot;&gt;About box banner: Alexis Delhaie (me)&lt;/span&gt;&lt;/p&gt;
@@ -173,7 +176,23 @@ p, li { white-space: pre-wrap; }
<string notr="true">font-size: 12px;</string>
</property>
<property name="text">
<string>Installer/Updater made with Delphi 10.3 Community</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Installer made with Delphi 10.3 Community (&lt;a href=&quot;https://github.com/alexlegarnd/chronos-installer&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;Source Github&lt;/span&gt;&lt;/a&gt;)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
<widget class="QLabel" name="label_6">
<property name="geometry">
<rect>
<x>30</x>
<y>310</y>
<width>541</width>
<height>21</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">font-size: 12px;</string>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Installer Bootstrap made with Python 3 (&lt;a href=&quot;https://github.com/alexlegarnd/chronos-installer-bootstrap&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;Source Github&lt;/span&gt;&lt;/a&gt;)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</widget>

File diff suppressed because it is too large Load Diff