From 9ad5a8f030a0c1b7c21fd5a24f36343c4fa69dca Mon Sep 17 00:00:00 2001 From: re2zero Date: Tue, 25 Mar 2025 11:49:42 +0800 Subject: [PATCH] chore: Merge Qt5 and Qt6 build Enable Qt6 build only for special arch, compat with qt5 build. Log: Merge Qt5 and Qt6 build. --- .project | 6 ----- 3rdparty/deepin-pdfium/include/dpdfglobal.h | 4 +++ 3rdparty/deepin-pdfium/src/dpdfglobal.cpp | 6 +++++ debian/control | 29 ++++++++++++++++++--- debian/rules | 27 +++++++++++-------- reader/document/Model.cpp | 12 +++++++++ 6 files changed, 64 insertions(+), 20 deletions(-) delete mode 100644 .project diff --git a/.project b/.project deleted file mode 100644 index d566f5e18..000000000 --- a/.project +++ /dev/null @@ -1,6 +0,0 @@ -{ - "type": "homebrew", - "3rdparty": [], - "ignore": ["./debian","./translations","./resources"], - "license": [] - } diff --git a/3rdparty/deepin-pdfium/include/dpdfglobal.h b/3rdparty/deepin-pdfium/include/dpdfglobal.h index f35ebbb73..bbc6c2b55 100755 --- a/3rdparty/deepin-pdfium/include/dpdfglobal.h +++ b/3rdparty/deepin-pdfium/include/dpdfglobal.h @@ -46,7 +46,11 @@ class DPdfGlobal }; //pdfium即使不同文档之间loadpage和renderpage也不是线程安全,需要加锁 +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +class DPdfMutexLocker : public QMutexLocker +#else class DPdfMutexLocker : public QMutexLocker +#endif { public: explicit DPdfMutexLocker(const QString &tmpLog); diff --git a/3rdparty/deepin-pdfium/src/dpdfglobal.cpp b/3rdparty/deepin-pdfium/src/dpdfglobal.cpp index 4e5e77797..8b99d9943 100755 --- a/3rdparty/deepin-pdfium/src/dpdfglobal.cpp +++ b/3rdparty/deepin-pdfium/src/dpdfglobal.cpp @@ -45,9 +45,15 @@ QString DPdfGlobal::textCodeType(const char *text) return encodeind; } +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +Q_GLOBAL_STATIC_WITH_ARGS(QMutex, pdfMutex, (QMutex::Recursive)); + +DPdfMutexLocker::DPdfMutexLocker(const QString &tmpLog): QMutexLocker(pdfMutex()) +#else Q_GLOBAL_STATIC(QRecursiveMutex, pdfMutex); DPdfMutexLocker::DPdfMutexLocker(const QString &tmpLog): QMutexLocker(pdfMutex()) +#endif { m_log = tmpLog; qInfo() << m_log + " begin "; diff --git a/debian/control b/debian/control index 66586d9aa..4baad62fc 100644 --- a/debian/control +++ b/debian/control @@ -1,13 +1,36 @@ + Source: deepin-reader Section: graphics Priority: optional Maintainer: deepin -Build-Depends: debhelper (>= 11), pkg-config, qt6-base-dev, qt6-base-dev-tools, qt6-tools-dev, libdtk6widget-dev, libspectre-dev, libdjvulibre-dev, libtiff-dev, libjpeg-dev, libicu-dev, libpng-dev, zlib1g-dev, liblcms2-dev, libopenjp2-7-dev, libfreetype6-dev, libgtest-dev, libchardet-dev, qt6-webengine-dev, qt6-5compat-dev, libdtk6gui-dev, libdtk6core-dev, qt6-svg-dev +Build-Depends: + debhelper (>= 11), + pkg-config, + qt6-5compat-dev [amd64 arm64 i386 loong64] | hello, + qt6-base-dev [amd64 arm64 i386 loong64] | qtbase5-dev, + qt6-tools-dev-tools [amd64 arm64 i386 loong64] | qttools5-dev-tools, + qt6-tools-dev [amd64 arm64 i386 loong64] | qttools5-dev, + qt6-svg-dev [amd64 arm64 i386 loong64] | libqt5svg5-dev, + qt6-webengine-dev [amd64 arm64 i386 loong64] | qtwebengine5-dev, + libdtk6widget-dev [amd64 arm64 i386 loong64] | libdtkwidget-dev, + libdtk6gui-dev [amd64 arm64 i386 loong64] | libdtkgui-dev, + libdtk6core-dev [amd64 arm64 i386 loong64] | libdtkcore-dev, + libspectre-dev, + libdjvulibre-dev, + libtiff-dev, + libjpeg-dev, + libicu-dev, + libpng-dev, + zlib1g-dev, + liblcms2-dev, + libopenjp2-7-dev, + libfreetype6-dev, + libgtest-dev, + libchardet-dev, Standards-Version: 4.5.0 Package: deepin-reader Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, pandoc Description: a tool for reading document files. - Document Viewer is a tool for reading document files,supporting PDF, DJVU, DOCX etc - + Document Viewer is a tool for reading document files, supporting PDF, DJVU, DOCX etc. diff --git a/debian/rules b/debian/rules index b8079cf46..5e477b6e7 100755 --- a/debian/rules +++ b/debian/rules @@ -1,23 +1,28 @@ #!/usr/bin/make -f -# -*- makefile -*- +include /usr/share/dpkg/default.mk -# 设置 Qt6 环境 -export QT_SELECT=qt6 -# 使用系统 PATH 中的 qmake6 -export QMAKE=qmake6 +# 检测当前安装的Qt版本,优先使用Qt6,否则使用Qt5 +define detect_qt_version +ifneq (,$(shell which qmake6 2>/dev/null)) + QMAKE=qmake6 +else + QMAKE=qmake +endif +endef -include /usr/share/dpkg/default.mk +# 调用检测Qt版本的命令 +$(eval $(call detect_qt_version)) -# 指定使用 qmake 构建系统 -export DH_OPTIONS := --buildsystem=qmake +# hardcode this if want to force build with sepecific Qt version +# QMAKE=qmake %: - dh $@ --buildsystem=qmake + dh $@ --parallel --buildsystem=qmake override_dh_auto_configure: $(QMAKE) \ - VERSION=$(VERSION) \ PREFIX=/usr \ LIB_INSTALL_DIR=/usr/lib/$(DEB_HOST_MULTIARCH) \ VERSION_UPSTREAM=$(DEB_VERSION_UPSTREAM) \ - DEFINES+="VERSION=$(DEB_VERSION_UPSTREAM)" + DEFINES+="VERSION=$(DEB_VERSION_UPSTREAM)" \ + CONFIG+=release \ No newline at end of file diff --git a/reader/document/Model.cpp b/reader/document/Model.cpp index bb8748bcf..f7cfaa8bc 100755 --- a/reader/document/Model.cpp +++ b/reader/document/Model.cpp @@ -70,7 +70,11 @@ deepin_reader::Document *deepin_reader::DocumentFactory::getDocument(const int & qDebug() << "正在解压文档..." << targetDoc; QString unzipCommand = "unzip " + targetDoc; qDebug() << "执行命令: " << unzipCommand; +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) + decompressor.start(unzipCommand); +#else decompressor.startCommand(unzipCommand); +#endif if (!decompressor.waitForStarted()) { qInfo() << "start unzip failed"; error = deepin_reader::Document::ConvertFailed; @@ -111,7 +115,11 @@ deepin_reader::Document *deepin_reader::DocumentFactory::getDocument(const int & QString pandocCommand = QString("pandoc %1 --data-dir=%2 -o %3").arg(targetDoc).arg(pandocDataDir).arg(tmpHtmlFilePath); qDebug() << "执行命令: " << pandocCommand; +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) + converter.start(pandocCommand); +#else converter.startCommand(pandocCommand); +#endif if (!converter.waitForStarted()) { qInfo() << "start pandoc failed"; error = deepin_reader::Document::ConvertFailed; @@ -144,7 +152,11 @@ deepin_reader::Document *deepin_reader::DocumentFactory::getDocument(const int & QString htmltopdfCommand = prefix + "/lib/deepin-reader/htmltopdf " + tmpHtmlFilePath + " " + realFilePath; qDebug() << "执行命令: " << htmltopdfCommand; +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) + converter2.start(htmltopdfCommand); +#else converter2.startCommand(htmltopdfCommand); +#endif if (!converter2.waitForStarted()) { qInfo() << "start htmltopdf failed"; error = deepin_reader::Document::ConvertFailed;