Skip to content

Commit

Permalink
[更新Qt版本并重构项目结构]: 更新了项目中使用的Qt版本,并进行了项目结构和脚本的重构。
Browse files Browse the repository at this point in the history
- 将`action.yml`中的Qt版本从`6.7.0`更新至`6.7.2`。
- `settings.json`中Qt路径更新为`C:\Qt\6.7.2\msvc2019_64\bin`。
- 在`qt.cmake`中,修改了Windows和Linux平台的Qt路径。
- `build.py`脚本中,更新了macOS下的Qt qmake路径。
- 重构了macOS的打包脚本,包括`package.sh`和`package.py`,更新了Qt-App的名称和路径。
- 添加了macOS的签名脚本`sign.bat`。
- 更新了`utils.py`,增加了文件删除功能`remove`。
- 删除了Ubuntu的旧打包脚本和相关文件,包括`DEBIAN`目录下的脚本和`package.py`。
- 更新了Windows的`build.py`,修改了Qt版本和项目路径。
- 删除了Windows的Inno Setup脚本`package.iss`和打包脚本`package.py`。
  • Loading branch information
RealChuan committed Jun 27, 2024
1 parent 259b83a commit cac3a6c
Show file tree
Hide file tree
Showing 47 changed files with 459 additions and 569 deletions.
2 changes: 1 addition & 1 deletion .github/actions/install-dependencies/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ inputs:
qt_ver:
description: 'qt version'
required: false
default: '6.7.0'
default: '6.7.2'
type: string

runs:
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
},
"cmake.generator": "Ninja",
"cmake.environment": {
"PATH": "C:\\Qt\\6.7.0\\msvc2019_64\\bin;${env:PATH};"
"PATH": "C:\\Qt\\6.7.2\\msvc2019_64\\bin;${env:PATH};"
}
}
2 changes: 1 addition & 1 deletion BatteryQuick/BatteryQuick.pro
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ SOURCES += \
main.cc

resources.files = Main.qml
resources.prefix = /qml
resources.prefix = /qt/qml/BatteryQuickResources
RESOURCES += resources

# Additional import path used to resolve QML modules in Qt Creator's code model
Expand Down
9 changes: 8 additions & 1 deletion BatteryQuick/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ qt_add_executable(BatteryQuick main.cc)
qt_add_qml_module(
BatteryQuick
URI
qml
BatteryQuickResources
VERSION
1.0
QML_FILES
Expand All @@ -23,3 +23,10 @@ set_target_properties(
WIN32_EXECUTABLE TRUE)

target_link_libraries(BatteryQuick PRIVATE Qt6::Quick)

include(GNUInstallDirs)
install(
TARGETS BatteryQuick
BUNDLE DESTINATION .
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
5 changes: 2 additions & 3 deletions BatteryQuick/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ auto main(int argc, char *argv[]) -> int
QGuiApplication app(argc, argv);

QQmlApplicationEngine engine;
const QUrl url(u"qrc:/qml/Main.qml"_qs);
const QUrl url(QStringLiteral("qrc:/qt/qml/BatteryQuickResources/Main.qml"));
QObject::connect(
&engine,
&QQmlApplicationEngine::objectCreated,
&app,
[url](QObject *obj, const QUrl &objUrl) {
if ((obj == nullptr) && url == objUrl) {
if (!obj && url == objUrl)
QCoreApplication::exit(-1);
}
},
Qt::QueuedConnection);
engine.load(url);
Expand Down
2 changes: 2 additions & 0 deletions BubbleWindow/bubblewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ void BubbleWidget::exec()

void BubbleWidget::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event)

QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
painter.setPen(d_ptr->pen);
Expand Down
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ project(
include(cmake/common.cmake)

find_package(
Qt6 REQUIRED
Qt6 6.5 REQUIRED
COMPONENTS Core
Widgets
Charts
Expand All @@ -21,8 +21,8 @@ find_package(
Sql
Quick)

qt_standard_project_setup(I18N_SOURCE_LANGUAGE en I18N_TRANSLATED_LANGUAGES
zh_CN)
qt_standard_project_setup(REQUIRES 6.5)
qt_policy(SET QTP0001 NEW)
# qt_standard_project_setup will set CMAKE_RUNTIME_OUTPUT_DIRECTORY, we need to
# set it back, and use EXECUTABLE_OUTPUT_PATH
unset(CMAKE_RUNTIME_OUTPUT_DIRECTORY)
Expand Down
2 changes: 1 addition & 1 deletion Chart/datetimechart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class DateTimeChart::DateTimeChartPrivate
PointList pointList = generateRandomDataPoints(5, 101);
int year = 2020;
int mouth = 1;
for (const QPointF &p : qAsConst(pointList)) {
for (const QPointF &p : std::as_const(pointList)) {
QDateTime momentInTime(QDate(year, mouth, 15), QTime());
scatterSeries->append(momentInTime.toMSecsSinceEpoch(), p.y());
lineSeries->append(momentInTime.toMSecsSinceEpoch(), p.y());
Expand Down
4 changes: 2 additions & 2 deletions FlowLayout/flowlayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ auto FlowLayout::sizeHint() const -> QSize
auto FlowLayout::minimumSize() const -> QSize
{
QSize size;
for (const QLayoutItem *item : qAsConst(itemList))
for (const QLayoutItem *item : std::as_const(itemList))
size = size.expandedTo(item->minimumSize());

const QMargins margins = contentsMargins();
Expand All @@ -181,7 +181,7 @@ auto FlowLayout::doLayout(const QRect &rect, bool testOnly) const -> int
//! [9]

//! [10]
for (QLayoutItem *item : qAsConst(itemList)) {
for (QLayoutItem *item : std::as_const(itemList)) {
const QWidget *wid = item->widget();
int spaceX = horizontalSpacing();
if (spaceX == -1)
Expand Down
4 changes: 2 additions & 2 deletions FlowLayout/flowwidget.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void FlowWidget::setItems(const QStringList &list)
QList<LabelWidget *> widgets = findChildren<LabelWidget *>();
qDeleteAll(widgets);

for (const QString &text : qAsConst(list)) {
for (const QString &text : std::as_const(list)) {
addItem(text);
}
}
Expand All @@ -75,7 +75,7 @@ QStringList FlowWidget::items() const
{
QStringList list;
QList<LabelWidget *> widgets = findChildren<LabelWidget *>();
for (LabelWidget *widget : qAsConst(widgets)) {
for (LabelWidget *widget : std::as_const(widgets)) {
list.append(widget->text());
}
return list;
Expand Down
2 changes: 1 addition & 1 deletion GridViewModel/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void MainWindow::setupUI()

m_imageVector.clear();
auto colorNames = QColor::colorNames();
for (const QString &colorName : qAsConst(colorNames)) {
for (const QString &colorName : std::as_const(colorNames)) {
QImage image(WIDTH, WIDTH, QImage::Format_ARGB32);
image.fill(Qt::transparent);
QPainter painter(&image);
Expand Down
4 changes: 2 additions & 2 deletions ImageCarousel/imagecarousel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ auto ImageCarousel::addImage(const QString &filename) -> bool
auto ImageCarousel::addImages(const QStringList &filenames) -> int
{
int count = 0;
for (const auto &filename : qAsConst(filenames)) {
for (const auto &filename : std::as_const(filenames)) {
if (addImage(filename)) {
++count;
}
Expand All @@ -67,7 +67,7 @@ auto ImageCarousel::addImages(const QStringList &filenames) -> int

void ImageCarousel::clearImages()
{
for (auto item : qAsConst(d_ptr->items)) {
for (auto item : std::as_const(d_ptr->items)) {
scene()->removeItem(item);
delete item;
}
Expand Down
4 changes: 1 addition & 3 deletions LogAsynchronous/LogAsynchronous.pro
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
QT += core gui concurrent

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
QT += core gui concurrent widgets

CONFIG += c++17

Expand Down
4 changes: 3 additions & 1 deletion LogAsynchronous/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ MainWindow::~MainWindow()
m_watcher.cancel();
m_watcher.waitForFinished();
}
LogAsync::instance()->stop();
qDebug() << "Stop Log!";
}

Expand All @@ -39,8 +40,9 @@ void MainWindow::testLog()
timer.start();

for (int i = 0; i < 1000; i++) {
if (!m_running)
if (!m_running) {
break;
}
qInfo() << "1234567890qwertyuiopasdfghjklzxcvbnm" << i;
QThread::msleep(1); //主界面无响应,上下文切换太快
}
Expand Down
Loading

0 comments on commit cac3a6c

Please sign in to comment.