Skip to content

Commit

Permalink
[更新Qt版本和依赖管理]: 更新了Qt版本和改进了依赖管理
Browse files Browse the repository at this point in the history
- 在`action.yml`文件中,将Qt版本从`6.7.2`更新到`6.8.1`。
- 在`.github/dependabot.yml`文件中,新增了Dependabot配置,用于自动维护GitHub Actions依赖。
- 在`cmake.yml`、`qmake.yml`、`toolchain.yml`工作流文件中,将`MACOSX_DEPLOYMENT_TARGET`从`11.0`更新到`12.0`,并更新了Windows的运行器版本从`windows-2019`到`windows-latest`。
- 在`README.md`文件中,添加了关于图片加载速度问题的说明,并提出了使用缓存技术的解决方案。
- 在`qt.cmake`文件中,更新了Qt安装路径,以匹配新版本的Qt。
- 在`vcpkg.json`文件中,更新了`builtin-baseline`值,以反映vcpkg依赖的变化。
  • Loading branch information
RealChuan committed Dec 16, 2024
1 parent 53a8960 commit 0662e03
Show file tree
Hide file tree
Showing 25 changed files with 126 additions and 109 deletions.
12 changes: 6 additions & 6 deletions .github/actions/install-dependencies/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ inputs:
qt_ver:
description: 'qt version'
required: false
default: '6.7.2'
default: '6.8.1'
type: string

runs:
Expand All @@ -37,7 +37,7 @@ runs:
rm vcpkg.json
- name: Cache windows vcpkg
if: startsWith(runner.os, 'Windows')
if: runner.os == 'Windows'
uses: actions/cache@v4
with:
path: C:\vcpkg\installed
Expand All @@ -49,7 +49,7 @@ runs:
save-always: true

- name: Cache macos or linux vcpkg
if: startsWith(runner.os, 'macOS') || startsWith(runner.os, 'Linux')
if: runner.os == 'macOS' || runner.os == 'Linux'
uses: actions/cache@v4
with:
path: /usr/local/share/vcpkg/installed
Expand All @@ -61,7 +61,7 @@ runs:
save-always: true

- name: Install dependencies on windows
if: startsWith(runner.os, 'Windows')
if: runner.os == 'Windows'
shell: bash
run: |
choco install ninja
Expand All @@ -70,7 +70,7 @@ runs:
vcpkg install ${{ inputs.vcpkg_libs }} --triplet x64-windows || (cat C:/vcpkg/installed/vcpkg/issue_body.md && exit 1)
- name: Install dependencies on macos
if: startsWith(runner.os, 'macOS')
if: runner.os == 'macOS'
shell: bash
run: |
brew install ninja python-setuptools
Expand All @@ -81,7 +81,7 @@ runs:
vcpkg install ${{ inputs.vcpkg_libs }} --triplet arm64-osx || (cat /usr/local/share/vcpkg/installed/vcpkg/issue_body.md && exit 1)
- name: Install dependencies on linux
if: startsWith(runner.os, 'Linux')
if: runner.os == 'Linux'
shell: bash
run: |
sudo apt-get update
Expand Down
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
- package-ecosystem: "github-actions" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"

2 changes: 1 addition & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:
- 'README*'

env:
MACOSX_DEPLOYMENT_TARGET: 11.0
MACOSX_DEPLOYMENT_TARGET: 12.0

jobs:
build:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/qmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:
- 'README*'

env:
MACOSX_DEPLOYMENT_TARGET: 11.0
MACOSX_DEPLOYMENT_TARGET: 12.0

jobs:
build:
Expand All @@ -27,7 +27,7 @@ jobs:
fail-fast: false
matrix:
os:
- windows-2019
- windows-latest
- macos-latest
- ubuntu-latest

Expand All @@ -51,7 +51,7 @@ jobs:
if: startsWith(matrix.os, 'windows')
shell: pwsh
run: |
..\scripts\windows\setVsDev.ps1 -VersionRange "[16.0,17.0)" -Arch "x64"
..\scripts\windows\setVsDev.ps1
& qmake ./../.
& jom
working-directory: build
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/toolchain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
workflow_dispatch:

env:
MACOSX_DEPLOYMENT_TARGET: 11.0
MACOSX_DEPLOYMENT_TARGET: 12.0

jobs:
build:
Expand All @@ -20,7 +20,6 @@ jobs:
matrix:
os:
- windows-latest
- windows-2019
- macos-latest
- ubuntu-latest

Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@

1. 跟OpenGL看图界面类似,在旋转任意角度的时候,纹理的宽高比会变化,导致显示不正常;

#### 图片加载速度问题

1. 使用`QPixmapCache`或者`QCache`之类的缓存技术,可以通过空间换时间,在加载已经加载过的图片时,提升加载速度。

## 看图界面

<div align=center>
Expand Down
4 changes: 2 additions & 2 deletions cmake/qt.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
if(CMAKE_HOST_WIN32)
list(APPEND CMAKE_PREFIX_PATH "C:\\Qt\\6.7.2\\msvc2019_64")
list(APPEND CMAKE_PREFIX_PATH "C:\\Qt\\6.8.1\\msvc2022_64")
elseif(CMAKE_HOST_APPLE)

elseif(CMAKE_HOST_LINUX)
list(APPEND CMAKE_PREFIX_PATH "/opt/Qt/6.7.2/gcc_64")
list(APPEND CMAKE_PREFIX_PATH "/opt/Qt/6.8.1/gcc_64")
endif()
10 changes: 5 additions & 5 deletions examples/graphics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ target_link_libraries(
thirdparty
dump
utils
Qt6::Gui
Qt6::Widgets
Qt6::OpenGLWidgets
Qt6::Network
Qt6::Concurrent
Qt::Gui
Qt::Widgets
Qt::OpenGLWidgets
Qt::Network
Qt::Concurrent
egif)
qt_finalize_executable(Qt-Graphics)
44 changes: 20 additions & 24 deletions examples/graphics/imageviewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,9 @@ void ImageViewer::onOpenImage()
QString imageFilters(tr("Images (*.bmp *.gif *.jpg *.jpeg *.png *.svg *.tiff *.webp *.icns "
"*.bitmap *.graymap *.pixmap *.tga *.xbitmap *.xpixmap)"));
//qDebug() << imageFilters;
const QString path = QStandardPaths::standardLocations(QStandardPaths::PicturesLocation)
.value(0, QDir::homePath());
const QString filename = QFileDialog::getOpenFileName(this,
tr("Open Image"),
path,
imageFilters);
const auto path = QStandardPaths::standardLocations(QStandardPaths::PicturesLocation)
.value(0, QDir::homePath());
const auto filename = QFileDialog::getOpenFileName(this, tr("Open Image"), path, imageFilters);
if (filename.isEmpty()) {
return;
}
Expand All @@ -97,7 +94,7 @@ void ImageViewer::onOpenImage()

void ImageViewer::onMaskImage()
{
QPixmap pixmap = d_ptr->imageView->pixmap();
auto pixmap = d_ptr->imageView->pixmap();
if (pixmap.isNull()) {
return;
}
Expand All @@ -109,7 +106,7 @@ void ImageViewer::onMaskImage()

void ImageViewer::onRoundImage()
{
QPixmap pixmap = d_ptr->imageView->pixmap();
auto pixmap = d_ptr->imageView->pixmap();
if (pixmap.isNull()) {
return;
}
Expand All @@ -121,7 +118,7 @@ void ImageViewer::onRoundImage()

void ImageViewer::onScaleFactorChanged(qreal factor)
{
const QString info = QString::number(factor * 100, 'f', 2) + QLatin1Char('%');
const auto info = QString::number(factor * 100, 'f', 2) + QLatin1Char('%');
d_ptr->scaleLabel->setText(info);
}

Expand All @@ -139,7 +136,7 @@ void ImageViewer::onImageChanged(const QString &url)
d_ptr->urlLabel->setText(url);
d_ptr->fileSizeLabel->setText(Utils::convertBytesToString(QFile(url).size()));

for (const ImageInfo &image : std::as_const(d_ptr->imageInfoList)) {
for (const auto &image : std::as_const(d_ptr->imageInfoList)) {
if (image.fileInfo().absoluteFilePath() == url) {
return;
}
Expand Down Expand Up @@ -171,12 +168,11 @@ void ImageViewer::onFormatChecked(bool state)

void ImageViewer::onFormatChanged(const QString &)
{
QImage::Format format = QImage::Format(d_ptr->formatBox->currentData().toInt());
Qt::ImageConversionFlags flags = Qt::ImageConversionFlags(
d_ptr->colorBox->currentData().toInt());
auto format = QImage::Format(d_ptr->formatBox->currentData().toInt());
auto flags = Qt::ImageConversionFlags(d_ptr->colorBox->currentData().toInt());

QImage image = d_ptr->imageView->pixmap().toImage();
QPixmap pixmap = QPixmap::fromImage(image.convertToFormat(format, flags));
auto image = d_ptr->imageView->pixmap().toImage();
auto pixmap = QPixmap::fromImage(image.convertToFormat(format, flags));
if (pixmap.isNull()) {
QMessageBox::warning(this, tr("WARNING"), tr("Format Conversion Failed!"));
return;
Expand Down Expand Up @@ -223,17 +219,17 @@ void ImageViewer::setupUI()

QWidget *ImageViewer::toolWidget()
{
QPushButton *openImageButton = new QPushButton(tr("Open Picture"), this);
auto *openImageButton = new QPushButton(tr("Open Picture"), this);
connect(openImageButton, &QPushButton::clicked, this, &ImageViewer::onOpenImage);

QPushButton *maskImageButton = new QPushButton(tr("Mask Picture"), this);
auto *maskImageButton = new QPushButton(tr("Mask Picture"), this);
connect(maskImageButton, &QPushButton::clicked, this, &ImageViewer::onMaskImage);

QPushButton *roundImageButton = new QPushButton(tr("Round Picture"), this);
auto *roundImageButton = new QPushButton(tr("Round Picture"), this);
connect(roundImageButton, &QPushButton::clicked, this, &ImageViewer::onRoundImage);

QGroupBox *infoBox = new QGroupBox(tr("Image Information"), this);
QGridLayout *gridLayout = new QGridLayout(infoBox);
auto *infoBox = new QGroupBox(tr("Image Information"), this);
auto *gridLayout = new QGridLayout(infoBox);
gridLayout->addWidget(new QLabel(tr("Url: "), this), 0, 0, 1, 1);
gridLayout->addWidget(d_ptr->urlLabel, 0, 1, 1, 1);
gridLayout->addWidget(new QLabel(tr("File Size: "), this), 1, 0, 1, 1);
Expand All @@ -243,16 +239,16 @@ QWidget *ImageViewer::toolWidget()
gridLayout->addWidget(new QLabel(tr("Scaling Ratio:"), this), 3, 0, 1, 1);
gridLayout->addWidget(d_ptr->scaleLabel, 3, 1, 1, 1);

QCheckBox *formatBox = new QCheckBox(tr("Format"), this);
auto *formatBox = new QCheckBox(tr("Format"), this);
connect(formatBox, &QCheckBox::clicked, this, &ImageViewer::onFormatChecked);
QHBoxLayout *formatLayout = new QHBoxLayout;
auto *formatLayout = new QHBoxLayout;
formatLayout->addWidget(formatBox);
formatLayout->addWidget(d_ptr->formatBox);
formatLayout->addWidget(d_ptr->colorBox);

QWidget *widget = new QWidget(this);
auto *widget = new QWidget(this);
widget->setMaximumWidth(300);
QVBoxLayout *rightLayout = new QVBoxLayout(widget);
auto *rightLayout = new QVBoxLayout(widget);
rightLayout->addWidget(openImageButton);
rightLayout->addWidget(infoBox);
rightLayout->addLayout(formatLayout);
Expand Down
8 changes: 5 additions & 3 deletions examples/graphics/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
class MainWindow::MainWindowPrivate
{
public:
MainWindowPrivate(QWidget *parent)
: q_ptr(parent)
explicit MainWindowPrivate(MainWindow *q)
: q_ptr(q)
{
drawWidget = new DrawWidget(q_ptr);
imageViewer = new ImageViewer(q_ptr);
Expand All @@ -35,7 +35,8 @@ class MainWindow::MainWindowPrivate
}
~MainWindowPrivate() {}

QWidget *q_ptr;
MainWindow *q_ptr;

DrawWidget *drawWidget;
ImageViewer *imageViewer;
OpenglViewer *openglViewer;
Expand All @@ -53,6 +54,7 @@ MainWindow::MainWindow(QWidget *parent)
setupUI();
resize(1000, 618);
Utils::windowCenter(this);

#if QT_VERSION > QT_VERSION_CHECK(6, 0, 0)
// 图片读取限制大小
qInfo() << tr("QImage memory allocation above this limit: %1MB.")
Expand Down
10 changes: 5 additions & 5 deletions examples/rhiviewer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ target_link_libraries(
thirdparty
dump
utils
Qt6::GuiPrivate
Qt6::Gui
Qt6::Widgets
Qt6::Network
Qt6::Concurrent)
Qt::GuiPrivate
Qt::Gui
Qt::Widgets
Qt::Network
Qt::Concurrent)
qt_finalize_executable(Qt-RhiViewer)
2 changes: 1 addition & 1 deletion src/3rdparty/3rdparty.pri
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ CONFIG(debug, debug|release) {
-llibbreakpad_client -llibbreakpad
}

LIBS += -lcommon -lclient -lutil -lbase
LIBS += -lvcpkg_crashpad_client_common -lvcpkg_crashpad_client -lvcpkg_crashpad_util -lvcpkg_crashpad_base

LIBS += -lgif

Expand Down
4 changes: 2 additions & 2 deletions src/3rdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ set(PROJECT_SOURCES
thirdparty_global.hpp)

add_custom_library(thirdparty ${PROJECT_SOURCES})
target_link_libraries(thirdparty PRIVATE shared_qtlockedfile utils Qt6::Network
Qt6::Widgets)
target_link_libraries(thirdparty PRIVATE shared_qtlockedfile utils Qt::Network
Qt::Widgets)

if(CMAKE_HOST_WIN32)
target_compile_definitions(thirdparty PRIVATE "THRIDPARTY_LIBRARY")
Expand Down
2 changes: 1 addition & 1 deletion src/3rdparty/gif/egif/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
set(PROJECT_SOURCES GifEncoder.cpp GifEncoder.h NeuQuant.cpp NeuQuant.h)

add_custom_library(egif ${PROJECT_SOURCES})
target_link_libraries(egif PRIVATE GIF::GIF Qt6::Widgets)
target_link_libraries(egif PRIVATE GIF::GIF Qt::Widgets)

if(CMAKE_HOST_WIN32)
target_compile_definitions(egif PRIVATE "THRIDPARTY_LIBRARY" _UNICODE UNICODE)
Expand Down
2 changes: 1 addition & 1 deletion src/3rdparty/qtlockedfile/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ endif()

add_library(shared_qtlockedfile STATIC ${OS_SOURCES} qtlockedfile.cpp
qtlockedfile.h)
target_link_libraries(shared_qtlockedfile Qt6::Core)
target_link_libraries(shared_qtlockedfile Qt::Core)
target_include_directories(shared_qtlockedfile
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
if(CMAKE_HOST_WIN32)
Expand Down
18 changes: 10 additions & 8 deletions src/3rdparty/qtsingleapplication/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
add_library(shared_qtsingleapplication SHARED
qtsingleapplication.cpp qtsingleapplication.h
qtlocalpeer.cpp qtlocalpeer.h
)
target_link_libraries(shared_qtsingleapplication shared_qtlockedfile Qt6::Core Qt6::Network Qt6::Widgets)
target_include_directories(shared_qtsingleapplication PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
if (WIN32)
target_compile_definitions(shared_qtsingleapplication PRIVATE "THRIDPARTY_LIBRARY" _UNICODE UNICODE)
add_library(
shared_qtsingleapplication SHARED
qtsingleapplication.cpp qtsingleapplication.h qtlocalpeer.cpp qtlocalpeer.h)
target_link_libraries(shared_qtsingleapplication shared_qtlockedfile Qt::Core
Qt::Network Qt::Widgets)
target_include_directories(shared_qtsingleapplication
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
if(WIN32)
target_compile_definitions(shared_qtsingleapplication
PRIVATE "THRIDPARTY_LIBRARY" _UNICODE UNICODE)
endif()
2 changes: 1 addition & 1 deletion src/dump/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ set(PROJECT_SOURCES breakpad.hpp breakpad.cc crashpad.hpp crashpad.cc
dump_global.hpp)
add_custom_library(dump ${PROJECT_SOURCES})
target_link_libraries(
dump PRIVATE utils Qt6::Widgets unofficial::breakpad::libbreakpad
dump PRIVATE utils Qt::Widgets unofficial::breakpad::libbreakpad
unofficial::breakpad::libbreakpad_client crashpad::crashpad)

if(CMAKE_HOST_WIN32)
Expand Down
4 changes: 2 additions & 2 deletions src/gpugraphics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ endif()
qt_add_resources(SOURCES shader.qrc)

add_custom_library(gpugraphics ${PROJECT_SOURCES} ${SOURCES})
target_link_libraries(gpugraphics PRIVATE Qt6::GuiPrivate Qt6::Gui Qt6::Widgets
Qt6::OpenGLWidgets)
target_link_libraries(gpugraphics PRIVATE Qt::GuiPrivate Qt::Gui Qt::Widgets
Qt::OpenGLWidgets)

if(CMAKE_HOST_WIN32)
target_compile_definitions(gpugraphics PRIVATE "GPUGRAPHICS_LIBRARY")
Expand Down
Loading

0 comments on commit 0662e03

Please sign in to comment.