Skip to content

Commit f10a1a9

Browse files
committed
[统一配置与C++20升级]: 重构项目配置并启用C++20标准
- **引入公共配置文件** `common.pri`,集中管理编译选项、版本信息和公司元数据 - **移除各子项目重复配置**,如`CONFIG += c++17`和弃用警告定义,改为继承公共配置 - **升级C++标准至C++20**,要求编译器最低版本为GCC 8/Clang 10/MSVC 2019 16.10 - **优化异步日志模块**: - 使用C++20标准库的`std::binary_semaphore`替代`QMutex`+`QWaitCondition` - 改进日志文件名格式,增加应用版本号字段 - 规范枚举命名(`Orientation::StandardAndFile`) - **规范资源文件顺序**,统一将`RESOURCES`声明放在`SOURCES/HEADERS`之后 - **增强版本元数据**,统一设置应用程序厂商、版权、产品名称等基础信息 - **强制Qt最低版本要求**,通过`QT_DISABLE_DEPRECATED_BEFORE=0x060000`禁用Qt6之前废弃API
1 parent e97b303 commit f10a1a9

File tree

37 files changed

+136
-331
lines changed

37 files changed

+136
-331
lines changed

Battery/Battery.pro

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,9 @@
1+
include(../common.pri)
2+
13
QT += core gui
24

35
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
46

5-
CONFIG += c++17
6-
7-
# The following define makes your compiler emit warnings if you use
8-
# any Qt feature that has been marked deprecated (the exact warnings
9-
# depend on your compiler). Please consult the documentation of the
10-
# deprecated API in order to know how to port your code away from it.
11-
DEFINES += QT_DEPRECATED_WARNINGS
12-
13-
# You can also make your code fail to compile if it uses deprecated APIs.
14-
# In order to do so, uncomment the following line.
15-
# You can also select to disable deprecated APIs only up to a certain version of Qt.
16-
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
17-
187
SOURCES += \
198
batterywidget.cpp \
209
main.cpp \

Bootstrap/Bootstrap.pro

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1+
include(../common.pri)
2+
13
QT += core gui
24

35
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
46

5-
CONFIG += c++17
6-
7-
# You can make your code fail to compile if it uses deprecated APIs.
8-
# In order to do so, uncomment the following line.
9-
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
10-
117
SOURCES += \
128
main.cc
139

@@ -26,10 +22,10 @@ unix:!macx{
2622
SOURCES += bootstrap_linux.cc
2723
}
2824

25+
RESOURCES += \
26+
resouce.qrc
27+
2928
# Default rules for deployment.
3029
qnx: target.path = /tmp/$${TARGET}/bin
3130
else: unix:!android: target.path = /opt/$${TARGET}/bin
3231
!isEmpty(target.path): INSTALLS += target
33-
34-
RESOURCES += \
35-
resouce.qrc

BubbleWindow/BubbleWindow.pro

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,9 @@
1+
include(../common.pri)
2+
13
QT += core gui
24

35
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
46

5-
CONFIG += c++17
6-
7-
# The following define makes your compiler emit warnings if you use
8-
# any Qt feature that has been marked deprecated (the exact warnings
9-
# depend on your compiler). Please consult the documentation of the
10-
# deprecated API in order to know how to port your code away from it.
11-
DEFINES += QT_DEPRECATED_WARNINGS
12-
13-
# You can also make your code fail to compile if it uses deprecated APIs.
14-
# In order to do so, uncomment the following line.
15-
# You can also select to disable deprecated APIs only up to a certain version of Qt.
16-
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
17-
187
SOURCES += \
198
bubblewidget.cpp \
209
main.cpp \

Chart/Chart.pro

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,9 @@
1+
include(../common.pri)
2+
13
QT += core gui charts
24

35
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
46

5-
CONFIG += c++17
6-
7-
# The following define makes your compiler emit warnings if you use
8-
# any Qt feature that has been marked deprecated (the exact warnings
9-
# depend on your compiler). Please consult the documentation of the
10-
# deprecated API in order to know how to port your code away from it.
11-
DEFINES += QT_DEPRECATED_WARNINGS
12-
13-
# You can also make your code fail to compile if it uses deprecated APIs.
14-
# In order to do so, uncomment the following line.
15-
# You can also select to disable deprecated APIs only up to a certain version of Qt.
16-
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
17-
187
SOURCES += \
198
areachart.cpp \
209
callout.cpp \

CheckBoxStandardItem/CheckBoxStandardItem.pro

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1+
include(../common.pri)
2+
13
QT += core gui
24

35
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
46

5-
CONFIG += c++17
6-
7-
# You can make your code fail to compile if it uses deprecated APIs.
8-
# In order to do so, uncomment the following line.
9-
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
10-
117
SOURCES += \
128
checkboxstandarditem.cc \
139
main.cc \

Clock/Clock.pro

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,9 @@
1+
include(../common.pri)
2+
13
QT += core gui
24

35
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
46

5-
CONFIG += c++17
6-
7-
# The following define makes your compiler emit warnings if you use
8-
# any Qt feature that has been marked deprecated (the exact warnings
9-
# depend on your compiler). Please consult the documentation of the
10-
# deprecated API in order to know how to port your code away from it.
11-
DEFINES += QT_DEPRECATED_WARNINGS
12-
13-
# You can also make your code fail to compile if it uses deprecated APIs.
14-
# In order to do so, uncomment the following line.
15-
# You can also select to disable deprecated APIs only up to a certain version of Qt.
16-
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
17-
187
SOURCES += \
198
clockwidget.cpp \
209
main.cpp \

DashBoard/DashBoard.pro

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,9 @@
1+
include(../common.pri)
2+
13
QT += core gui
24

35
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
46

5-
CONFIG += c++17
6-
7-
# The following define makes your compiler emit warnings if you use
8-
# any Qt feature that has been marked deprecated (the exact warnings
9-
# depend on your compiler). Please consult the documentation of the
10-
# deprecated API in order to know how to port your code away from it.
11-
DEFINES += QT_DEPRECATED_WARNINGS
12-
13-
# You can also make your code fail to compile if it uses deprecated APIs.
14-
# In order to do so, uncomment the following line.
15-
# You can also select to disable deprecated APIs only up to a certain version of Qt.
16-
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
17-
187
SOURCES += \
198
dashboardwidget.cpp \
209
main.cpp \

DragDrop/DragDrop.pro

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,9 @@
1+
include(../common.pri)
2+
13
QT += core gui
24

35
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
46

5-
CONFIG += c++17
6-
7-
# The following define makes your compiler emit warnings if you use
8-
# any Qt feature that has been marked deprecated (the exact warnings
9-
# depend on your compiler). Please consult the documentation of the
10-
# deprecated API in order to know how to port your code away from it.
11-
DEFINES += QT_DEPRECATED_WARNINGS
12-
13-
# You can also make your code fail to compile if it uses deprecated APIs.
14-
# In order to do so, uncomment the following line.
15-
# You can also select to disable deprecated APIs only up to a certain version of Qt.
16-
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
17-
187
SOURCES += \
198
draglistwidget.cpp \
209
droplistwidget.cpp \
@@ -30,18 +19,3 @@ HEADERS += \
3019
qnx: target.path = /tmp/$${TARGET}/bin
3120
else: unix:!android: target.path = /opt/$${TARGET}/bin
3221
!isEmpty(target.path): INSTALLS += target
33-
34-
# Output directory
35-
CONFIG(debug, debug|release) {
36-
output = debug
37-
TARGET = $$TARGET
38-
}
39-
CONFIG(release, debug|release) {
40-
output = release
41-
}
42-
43-
DESTDIR = bin
44-
OBJECTS_DIR = $$output
45-
MOC_DIR = $$output
46-
RCC_DIR = $$output
47-
UI_DIR = $$output

FlowLayout/FlowLayout.pro

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1+
include(../common.pri)
2+
13
QT += core gui
24

35
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
46

5-
CONFIG += c++17
6-
7-
# You can make your code fail to compile if it uses deprecated APIs.
8-
# In order to do so, uncomment the following line.
9-
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
10-
117
SOURCES += \
128
flowlayout.cpp \
139
flowwidget.cc \

GridViewModel/GridViewModel.pro

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1+
include(../common.pri)
2+
13
QT += core gui
24

35
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
46

5-
CONFIG += c++17
6-
7-
# You can make your code fail to compile if it uses deprecated APIs.
8-
# In order to do so, uncomment the following line.
9-
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
10-
117
SOURCES += \
128
gridmodel.cpp \
139
gridview.cpp \

HttpClient/HttpClient.pro

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,9 @@
1+
include(../common.pri)
2+
13
QT += core gui network testlib
24

35
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
46

5-
CONFIG += c++17
6-
7-
# The following define makes your compiler emit warnings if you use
8-
# any Qt feature that has been marked deprecated (the exact warnings
9-
# depend on your compiler). Please consult the documentation of the
10-
# deprecated API in order to know how to port your code away from it.
11-
DEFINES += QT_DEPRECATED_WARNINGS
12-
13-
# You can also make your code fail to compile if it uses deprecated APIs.
14-
# In order to do so, uncomment the following line.
15-
# You can also select to disable deprecated APIs only up to a certain version of Qt.
16-
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
17-
187
SOURCES += \
198
httpclient.cc \
209
httpclient_unittest.cc

IconButton/IconButton.pro

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1+
include(../common.pri)
2+
13
QT += core gui
24

35
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
46

5-
CONFIG += c++17
6-
7-
# You can make your code fail to compile if it uses deprecated APIs.
8-
# In order to do so, uncomment the following line.
9-
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
10-
117
SOURCES += \
128
iconfliter.cc \
139
main.cc \

ImageCarousel/ImageCarousel.pro

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1+
include(../common.pri)
2+
13
QT += core gui
24

35
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
46

5-
CONFIG += c++17
6-
7-
# You can make your code fail to compile if it uses deprecated APIs.
8-
# In order to do so, uncomment the following line.
9-
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
10-
117
SOURCES += \
128
graphicspixmapitem.cc \
139
imagecarousel.cc \

LoadingIndicator/LoadingIndicator.pro

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1+
include(../common.pri)
2+
13
QT += core gui
24

35
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
46

5-
CONFIG += c++17
6-
7-
# You can make your code fail to compile if it uses deprecated APIs.
8-
# In order to do so, uncomment the following line.
9-
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
10-
117
SOURCES += \
128
loadingindicator.cc \
139
main.cc \
@@ -17,10 +13,10 @@ HEADERS += \
1713
loadingindicator.hpp \
1814
mainwindow.hpp
1915

16+
RESOURCES += \
17+
resource.qrc
18+
2019
# Default rules for deployment.
2120
qnx: target.path = /tmp/$${TARGET}/bin
2221
else: unix:!android: target.path = /opt/$${TARGET}/bin
2322
!isEmpty(target.path): INSTALLS += target
24-
25-
RESOURCES += \
26-
resource.qrc

LogAsynchronous/LogAsynchronous.pro

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,6 @@
1-
QT += core gui concurrent widgets
2-
3-
CONFIG += c++17
1+
include(../common.pri)
42

5-
# The following define makes your compiler emit warnings if you use
6-
# any Qt feature that has been marked deprecated (the exact warnings
7-
# depend on your compiler). Please consult the documentation of the
8-
# deprecated API in order to know how to port your code away from it.
9-
DEFINES += QT_DEPRECATED_WARNINGS
10-
11-
# You can also make your code fail to compile if it uses deprecated APIs.
12-
# In order to do so, uncomment the following line.
13-
# You can also select to disable deprecated APIs only up to a certain version of Qt.
14-
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
3+
QT += core gui concurrent widgets
154

165
SOURCES += \
176
logasync.cpp \

LogAsynchronous/logasync.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
#include "logfile.hpp"
33

44
#include <QDateTime>
5-
#include <QMutex>
6-
#include <QWaitCondition>
5+
6+
#include <semaphore>
77

88
// 消息处理函数
99
void messageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
@@ -66,7 +66,7 @@ void messageHandler(QtMsgType type, const QMessageLogContext &context, const QSt
6666

6767
switch (instance->orientation()) {
6868
case LogAsync::Orientation::File: emit instance->appendBuf(printToFile); break;
69-
case LogAsync::Orientation::StdAndFile:
69+
case LogAsync::Orientation::StandardAndFile:
7070
emit instance->appendBuf(printToFile);
7171
fprintf(stdPrint, "%s", printToConsole.toLocal8Bit().constData());
7272
::fflush(stdPrint);
@@ -91,10 +91,9 @@ class LogAsync::LogAsyncPrivate
9191
bool autoDelFile = false;
9292
qint64 autoDelFileDays = 7;
9393
QtMsgType msgType = QtWarningMsg;
94-
LogAsync::Orientation orientation = LogAsync::Orientation::Std;
94+
LogAsync::Orientation orientation = LogAsync::Orientation::Standard;
9595
int maxConsoleLineSize = 1024 * 10;
96-
QWaitCondition waitCondition;
97-
QMutex mutex;
96+
std::binary_semaphore semaphore{0};
9897
};
9998

10099
auto LogAsync::instance() -> LogAsync *
@@ -169,8 +168,7 @@ auto LogAsync::maxConsoleLineSize() -> int
169168
void LogAsync::startWork()
170169
{
171170
start();
172-
QMutexLocker lock(&d_ptr->mutex);
173-
d_ptr->waitCondition.wait(&d_ptr->mutex, 5000);
171+
d_ptr->semaphore.acquire();
174172
}
175173

176174
void LogAsync::stop()
@@ -186,7 +184,7 @@ void LogAsync::run()
186184
{
187185
LogFile logFile;
188186
connect(this, &LogAsync::appendBuf, &logFile, &LogFile::onWrite);
189-
d_ptr->waitCondition.wakeOne();
187+
d_ptr->semaphore.release();
190188
exec();
191189
}
192190

0 commit comments

Comments
 (0)