Main window frameless + Switching to MSVC2019

This commit is contained in:
Alexis Delhaie
2020-08-28 14:47:21 +02:00
parent ff64fa14d3
commit 257bc67f61
6 changed files with 169 additions and 30 deletions

View File

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

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 4.12.4, 2020-08-10T22:47:23. --> <!-- Written by QtCreator 4.12.4, 2020-08-28T14:45:30. -->
<qtcreator> <qtcreator>
<data> <data>
<variable>EnvironmentId</variable> <variable>EnvironmentId</variable>
@@ -74,17 +74,17 @@
<data> <data>
<variable>ProjectExplorer.Project.Target.0</variable> <variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap"> <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.DefaultDisplayName">Desktop Qt 5.15.0 MSVC2019 64bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.15.0 MinGW 64-bit</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_mingw81_kit</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.ActiveBuildConfiguration">1</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value> <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value> <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0"> <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="bool">true</value> <value type="bool">true</value>
<value type="int" key="EnableQmlDebugging">0</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">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_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_MSVC2019_64bit-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@@ -134,8 +134,8 @@
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1"> <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="bool">true</value> <value type="bool">true</value>
<value type="int" key="EnableQmlDebugging">2</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">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_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_MSVC2019_64bit-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@@ -185,8 +185,8 @@
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2"> <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
<value type="bool">true</value> <value type="bool">true</value>
<value type="int" key="EnableQmlDebugging">0</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">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_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_MSVC2019_64bit-Profile</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> <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.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value> <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
<value type="QString" key="RunConfiguration.WorkingDirectory"></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> </valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value> <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap> </valuemap>

View File

@@ -6,9 +6,31 @@ MainWindow::MainWindow(QWidget *parent)
, ui(new Ui::MainWindow) , ui(new Ui::MainWindow)
{ {
ui->setupUi(this); ui->setupUi(this);
ui->window_title->setText(this->windowTitle());
this->setWindowFlags(Qt::FramelessWindowHint);
init(); 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() MainWindow::~MainWindow()
{ {
delete ui; delete ui;
@@ -33,6 +55,10 @@ void MainWindow::init() {
objectId.insert(ui->wed_button->objectName(), Identifier::wed); objectId.insert(ui->wed_button->objectName(), Identifier::wed);
objectId.insert(ui->thu_button->objectName(), Identifier::thu); objectId.insert(ui->thu_button->objectName(), Identifier::thu);
objectId.insert(ui->fri_button->objectName(), Identifier::fri); 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->aboutButton, &QPushButton::clicked, this, &MainWindow::open_about);
connect(ui->template_settings_button, &QPushButton::clicked, this, &MainWindow::edit_template); connect(ui->template_settings_button, &QPushButton::clicked, this, &MainWindow::edit_template);
connect(ui->dateEdit, &QDateEdit::dateTimeChanged, this, &MainWindow::compute_week_number); connect(ui->dateEdit, &QDateEdit::dateTimeChanged, this, &MainWindow::compute_week_number);

View File

@@ -7,6 +7,8 @@
#define SAVE_FILE_VERSION 1 #define SAVE_FILE_VERSION 1
#define KEY_SAVE_FILE_VERSION "version" #define KEY_SAVE_FILE_VERSION "version"
#include <QMouseEvent>
#include <QGraphicsView>
#include <QJsonArray> #include <QJsonArray>
#include <QMainWindow> #include <QMainWindow>
#include <QDir> #include <QDir>
@@ -59,6 +61,16 @@ private:
QMap<int, Week> weeks; QMap<int, Week> weeks;
QMap<QString, Identifier> objectId; 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: public slots:
void compute_week_number(const QDateTime &dt); void compute_week_number(const QDateTime &dt);
void compute_time(); void compute_time();

View File

@@ -91,7 +91,7 @@
<string notr="true">font-size: 12px;</string> <string notr="true">font-size: 12px;</string>
</property> </property>
<property name="text"> <property name="text">
<string>Version: 1.0.0 (Beta 3)</string> <string>Version: 1.0.0 (Beta 4)</string>
</property> </property>
</widget> </widget>
<widget class="QLabel" name="label_3"> <widget class="QLabel" name="label_3">
@@ -107,7 +107,7 @@
<string notr="true">font-size: 12px;</string> <string notr="true">font-size: 12px;</string>
</property> </property>
<property name="text"> <property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Made with Qt 5.15.0 MinGW 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> <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> </property>
</widget> </widget>
<widget class="QTextEdit" name="textEdit"> <widget class="QTextEdit" name="textEdit">
@@ -122,6 +122,9 @@
<property name="accessibleDescription"> <property name="accessibleDescription">
<string notr="true"/> <string notr="true"/>
</property> </property>
<property name="styleSheet">
<string notr="true">font-size: 12px;</string>
</property>
<property name="undoRedoEnabled"> <property name="undoRedoEnabled">
<bool>false</bool> <bool>false</bool>
</property> </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; <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; &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; } 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; 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;-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; &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;

View File

@@ -7,19 +7,19 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1206</width> <width>1206</width>
<height>649</height> <height>662</height>
</rect> </rect>
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>1206</width> <width>1206</width>
<height>649</height> <height>662</height>
</size> </size>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>1206</width> <width>1206</width>
<height>649</height> <height>662</height>
</size> </size>
</property> </property>
<property name="font"> <property name="font">
@@ -42,7 +42,7 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>192</x> <x>192</x>
<y>19</y> <y>41</y>
<width>20</width> <width>20</width>
<height>81</height> <height>81</height>
</rect> </rect>
@@ -55,7 +55,7 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>236</x> <x>236</x>
<y>29</y> <y>51</y>
<width>151</width> <width>151</width>
<height>61</height> <height>61</height>
</rect> </rect>
@@ -117,7 +117,7 @@ color: white;</string>
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>40</x> <x>40</x>
<y>29</y> <y>51</y>
<width>161</width> <width>161</width>
<height>61</height> <height>61</height>
</rect> </rect>
@@ -179,7 +179,7 @@ color: white;</string>
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>1022</x> <x>1022</x>
<y>23</y> <y>45</y>
<width>153</width> <width>153</width>
<height>61</height> <height>61</height>
</rect> </rect>
@@ -258,7 +258,7 @@ color: white;</string>
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>427</x> <x>427</x>
<y>30</y> <y>52</y>
<width>161</width> <width>161</width>
<height>61</height> <height>61</height>
</rect> </rect>
@@ -320,7 +320,7 @@ color: white;</string>
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>378</x> <x>378</x>
<y>20</y> <y>42</y>
<width>20</width> <width>20</width>
<height>81</height> <height>81</height>
</rect> </rect>
@@ -333,7 +333,7 @@ color: white;</string>
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>930</x> <x>930</x>
<y>600</y> <y>622</y>
<width>261</width> <width>261</width>
<height>31</height> <height>31</height>
</rect> </rect>
@@ -346,7 +346,7 @@ color: white;</string>
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>140</x> <x>140</x>
<y>160</y> <y>182</y>
<width>921</width> <width>921</width>
<height>391</height> <height>391</height>
</rect> </rect>
@@ -1341,7 +1341,7 @@ font-size: 22px;</string>
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>20</x> <x>20</x>
<y>588</y> <y>610</y>
<width>44</width> <width>44</width>
<height>44</height> <height>44</height>
</rect> </rect>
@@ -1371,8 +1371,106 @@ font-size: 22px;</string>
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
<widget class="QLabel" name="window_title">
<property name="geometry">
<rect>
<x>10</x>
<y>-1</y>
<width>1081</width>
<height>41</height>
</rect>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
<widget class="QPushButton" name="closeButton">
<property name="geometry">
<rect>
<x>1156</x>
<y>0</y>
<width>51</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<family>Segoe MDL2 Assets</family>
<pointsize>-1</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">border: none;
font-size: 14px;</string>
</property>
<property name="text">
<string></string>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
<widget class="QPushButton" name="minimizeButton">
<property name="geometry">
<rect>
<x>1101</x>
<y>0</y>
<width>51</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<family>Segoe MDL2 Assets</family>
<pointsize>-1</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">border: none;
font-size: 14px;</string>
</property>
<property name="text">
<string></string>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</widget> </widget>
</widget> </widget>
<resources/> <resources/>
<connections/> <connections>
<connection>
<sender>closeButton</sender>
<signal>clicked()</signal>
<receiver>MainWindow</receiver>
<slot>close()</slot>
<hints>
<hint type="sourcelabel">
<x>1186</x>
<y>10</y>
</hint>
<hint type="destinationlabel">
<x>602</x>
<y>330</y>
</hint>
</hints>
</connection>
<connection>
<sender>minimizeButton</sender>
<signal>clicked()</signal>
<receiver>MainWindow</receiver>
<slot>showMinimized()</slot>
<hints>
<hint type="sourcelabel">
<x>1126</x>
<y>15</y>
</hint>
<hint type="destinationlabel">
<x>602</x>
<y>330</y>
</hint>
</hints>
</connection>
</connections>
</ui> </ui>