diff --git a/CMakeLists.txt b/CMakeLists.txt index aeb170938..1996fcd33 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,20 +11,24 @@ set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_AUTOUIC ON) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -Wl,--as-needed -fPIE") -set(QT_MINIMUM_VERSION "6.0.0") +#set(QT_MINIMUM_VERSION "6.0.0") set(CMAKE_EXE_LINKER_FLAGS "-pie") # 查找Qt库 -find_package(QT NAMES Qt6 REQUIRED COMPONENTS Core Widgets Gui DBus Xml Svg Test) -message("Using Qt version: ${QT_VERSION_MAJOR}") +find_package(Qt6 QUIET) # 选择DTK版本 -if(QT_VERSION_MAJOR EQUAL "6") +if(Qt6_FOUND) + find_package(Qt6 REQUIRED COMPONENTS Core Widgets Gui DBus Xml Svg Test) set(BUILD_WITH_QT6 ON) + set(QT_VERSION_MAJOR 6) set(DTK_VERSION_MAJOR 6) else() + find_package(Qt5 REQUIRED COMPONENTS Core Widgets Gui DBus Xml Svg Test) + set(QT_VERSION_MAJOR 5) set(DTK_VERSION_MAJOR "") endif() +message("Using Qt version: ${QT_VERSION_MAJOR}") message("Using dtk version: ${DTK_VERSION_MAJOR}") # 查找DTK库 @@ -86,13 +90,13 @@ endif() # 设置链接库 set(LINK_LIBS - Qt6::Core - Qt6::DBus - Qt6::Widgets - Qt6::Xml - Qt6::Svg - Qt6::Test - Qt6::SvgWidgets + Qt${QT_VERSION_MAJOR}::Core + Qt${QT_VERSION_MAJOR}::DBus + Qt${QT_VERSION_MAJOR}::Widgets + Qt${QT_VERSION_MAJOR}::Xml + Qt${QT_VERSION_MAJOR}::Svg + Qt${QT_VERSION_MAJOR}::Test + Qt${QT_VERSION_MAJOR}::SvgWidgets Dtk${DTK_VERSION_MAJOR}::Widget Dtk${DTK_VERSION_MAJOR}::Gui Dtk${DTK_VERSION_MAJOR}::Core diff --git a/debian/control b/debian/control index 128001ac8..c49c84ca8 100644 --- a/debian/control +++ b/debian/control @@ -5,28 +5,27 @@ Maintainer: Deepin Packages Builder Build-Depends: debhelper, cmake, - qt6-base-dev, pkg-config, libexif-dev, libraw-dev, - libqt6opengl6, - libdtk6gui-dev, - qt6-svg-dev, - qt6-tools-dev, - qt6-tools-dev-tools, - libdtk6widget-dev, - libdtk6gui-dev, - libdtk6core-dev, - libxcb-util0-dev, - libdtk6core-bin, libgtest-dev, - libgmock-dev + libgmock-dev, + libxcb-util0-dev, + qt6-base-dev | qtbase5-dev, + libqt6opengl6 | libqt5opengl5-dev, + qt6-svg-dev | libqt5svg5-dev, + qt6-tools-dev | qttools5-dev, + qt6-tools-dev-tools | qttools5-dev-tools, + libdtk6gui-dev | libdtkgui-dev, + libdtk6widget-dev | libdtkwidget-dev, + libdtk6core-dev | libdtkcore5-bin, + libdtk6core-bin | libdtkcore5-bin Standards-Version: 3.9.8 Homepage: http://www.deepin.org Package: deepin-draw Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, qt6-image-formats-plugins, deepin-picker-cli +Depends: ${shlibs:Depends}, ${misc:Depends}, qt6-image-formats-plugins | qt5-image-formats-plugins, deepin-picker-cli Description: Draw for UOS Draw is a lightweight drawing tool for users to freely draw and simply edit images. Recommends: uos-reporter, deepin-event-log, kimageformat-plugins diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b94d3e5ec..a1a3004af 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -11,7 +11,7 @@ set(CMAKE_AUTOMOC ON) # 自动处理moc文件 set(CMAKE_AUTORCC ON) # 自动处理rcc文件 set(CMAKE_AUTOUIC ON) # 自动处理uic文件 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -Wl,--as-needed -fPIE") # 设置C++编译标志,启用调试信息和警告 -set(QT_MINIMUM_VERSION "6.0.0") # 定义Qt的最低版本为6.0.0 +#set(QT_MINIMUM_VERSION "6.0.0") # 定义Qt的最低版本为6.0.0 set(CMAKE_EXE_LINKER_FLAGS "-pie") # 设置可执行文件的链接标志 # 设置编译器/链接器标志 @@ -150,7 +150,7 @@ find_package(PkgConfig REQUIRED) # 检查第三方库(这里检查了名字为dtkwidget的库和名字为dtkgui的库),然后取名3RMODULES pkg_check_modules(3RMODULES REQUIRED - dtk6widget dtk6gui dtk6core + dtk${DTK_VERSION_MAJOR}widget dtk${DTK_VERSION_MAJOR}gui dtk${DTK_VERSION_MAJOR}core ) # 添加调试信息 @@ -174,15 +174,15 @@ target_link_libraries(${BASE_LIB} ${3RMODULES_LIBRARIES} ${CMAKE_DL_LIBS}) # endif() # 设置链接库 set(LINK_LIBS - Qt6::Core - Qt6::DBus - Qt6::Widgets - Qt6::PrintSupport - Qt6::Svg - Qt6::Concurrent - Dtk6::Widget - Dtk6::Gui - Dtk6::Core + Qt${QT_VERSION_MAJOR}::Core + Qt${QT_VERSION_MAJOR}::DBus + Qt${QT_VERSION_MAJOR}::Widgets + Qt${QT_VERSION_MAJOR}::PrintSupport + Qt${QT_VERSION_MAJOR}::Svg + Qt${QT_VERSION_MAJOR}::Concurrent + Dtk${DTK_VERSION_MAJOR}::Widget + Dtk${DTK_VERSION_MAJOR}::Gui + Dtk${DTK_VERSION_MAJOR}::Core ) # 替换原来的 if-else 链接逻辑 diff --git a/src/application.cpp b/src/application.cpp index 90cc8cced..d5043da54 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -436,24 +436,6 @@ bool Application::isFileNameLegal(const QString &path, int *outErrorReson) QRegularExpression splitExp("[/\\\\]"); -//Qt5: 使用 indexIn 方法来查找匹配项。 -//Qt6: 使用 QRegularExpressionMatchIterator 来遍历所有匹配项。 -#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) - int pos = splitExp.indexIn(path); - while (pos != -1) { - QString dirStr = path.left(pos + 1); - if (dirStr.count() > 1) { - QDir dir(dirStr); - if (!dir.exists()) { - if (outErrorReson != nullptr) { - *outErrorReson = 2; - } - return false; - } - } - pos = splitExp.indexIn(path, pos + 1); - } -#else QRegularExpressionMatchIterator it = splitExp.globalMatch(path); while (it.hasNext()) { QRegularExpressionMatch match = it.next(); @@ -469,7 +451,6 @@ bool Application::isFileNameLegal(const QString &path, int *outErrorReson) } } } -#endif bool isdir = (path.endsWith('/') || path.endsWith('\\')); return !isdir; diff --git a/src/drawshape/cdrawscene.cpp b/src/drawshape/cdrawscene.cpp index b02a128df..1ae2f0a85 100644 --- a/src/drawshape/cdrawscene.cpp +++ b/src/drawshape/cdrawscene.cpp @@ -41,7 +41,11 @@ #include #include #include +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) #include +#else +#include +#endif DWIDGET_USE_NAMESPACE diff --git a/src/drawshape/drawItems/csizehandlerect.cpp b/src/drawshape/drawItems/csizehandlerect.cpp index 70a313cea..70da134ef 100644 --- a/src/drawshape/drawItems/csizehandlerect.cpp +++ b/src/drawshape/drawItems/csizehandlerect.cpp @@ -86,30 +86,13 @@ void CSizeHandleRect::paint(QPainter *painter, const QStyleOptionGraphicsItem *o if (isFatherDragging()) return; - //在Qt6中,QGraphicsSvgItem的renderer()方法已经被移除。在Qt5中,renderer()方法是可用的,因此需要分别处理。 - #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) if (!m_isRotation) { - if (renderer() != &m_lightRenderer) { - setSharedRenderer(&m_lightRenderer); - } - } - #else - // Qt6 处理逻辑 - if (!m_isRotation) { - //// 在Qt6中直接使用m_lightRenderer进行绘制 m_lightRenderer.render(painter, this->boundingRect()); } - #endif painter->setClipping(false); QRectF rect = this->boundingRect(); - - #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - this->renderer()->render(painter, rect); - #else - // 在Qt6中使用QSvgRenderer直接绘制 m_lightRenderer.render(painter, rect); - #endif painter->setClipping(true); } @@ -172,15 +155,9 @@ QRectF CSizeHandleRect::boundingRect() const qreal scale = curView()->getScale(); QRectF rect; -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - // Qt5 处理逻辑 - rect = QGraphicsSvgItem::boundingRect(); -#else // Qt6 中使用 QSvgRenderer::viewBoxF() 方法。这将返回整个SVG的视图框矩形 // TODO: 这里以后可能需要留意下,感觉可能会出ui BUG,目前没发现问题 rect = m_lightRenderer.viewBoxF(); -#endif - rect.setWidth(rect.width() / scale); rect.setHeight(rect.height() / scale); return rect; diff --git a/src/drawshape/drawItems/csizehandlerect.h b/src/drawshape/drawItems/csizehandlerect.h index 677aeec43..a1954e2ea 100644 --- a/src/drawshape/drawItems/csizehandlerect.h +++ b/src/drawshape/drawItems/csizehandlerect.h @@ -5,16 +5,16 @@ #ifndef CSIZEHANDLERECT #define CSIZEHANDLERECT -#if (QT_VERSION_MAJOR == 5) -#include -#elif (QT_VERSION_MAJOR == 6) -#include -#endif - #include #include #include +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +#include +#else +#include +#endif + QT_BEGIN_NAMESPACE class QFocusEvent; class QGraphicsItem; diff --git a/src/drawshape/drawTools/ctexttool.cpp b/src/drawshape/drawTools/ctexttool.cpp index b15f383e5..05a83c349 100644 --- a/src/drawshape/drawTools/ctexttool.cpp +++ b/src/drawshape/drawTools/ctexttool.cpp @@ -357,7 +357,7 @@ void CTextTool::initFontFamilyWidget(QComboBox *fontHeavy) drawBoard()->attributionWidget()->installComAttributeWgt(EFontFamily, fontFamily, sourceHumFont); // 连接当前索引变化信号,兼容Qt5和Qt6 - connect(fontComboBox, &QComboBox::currentIndexChanged, this, [ = ](int index) { + connect(fontComboBox, QOverload::of(&QComboBox::currentIndexChanged), this, [ = ](int index) { // 获取当前选中的字体 QString family = fontComboBox->itemText(index); // 标记为活动预览 @@ -366,7 +366,7 @@ void CTextTool::initFontFamilyWidget(QComboBox *fontHeavy) }); // 连接当前索引变化信号,处理高亮显示的字体 - connect(fontComboBox, &QComboBox::currentIndexChanged, this, [ = ](int index) { + connect(fontComboBox, QOverload::of(&QComboBox::currentIndexChanged), this, [ = ](int index) { // 获取当前高亮的字体 QString family = fontComboBox->itemText(index); // 预览的不用支持撤销还原 diff --git a/src/frame/cgraphicsview.cpp b/src/frame/cgraphicsview.cpp index a46fde688..7bbb4b165 100644 --- a/src/frame/cgraphicsview.cpp +++ b/src/frame/cgraphicsview.cpp @@ -1000,7 +1000,7 @@ void PageView::slotOnPaste(bool textItemInCenter) } } } else { - qDebug() << "mp->hasImage()" << mp->hasImage() << Qt::endl; + qDebug() << "mp->hasImage()" << mp->hasImage(); //粘贴画板内部图元 CShapeMimeData *data = qobject_cast(mp); diff --git a/src/frame/cmultiptabbarwidget.cpp b/src/frame/cmultiptabbarwidget.cpp index 432d9ee4d..a1326f110 100644 --- a/src/frame/cmultiptabbarwidget.cpp +++ b/src/frame/cmultiptabbarwidget.cpp @@ -301,7 +301,11 @@ QString FileSelectDialog::extractSuffix(const QString &filter) return QString(); QString suffixes = match.captured(1); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) QStringList suffixList = suffixes.split(' ', Qt::SkipEmptyParts); +#else + QStringList suffixList = suffixes.split(' ', QString::SplitBehavior::SkipEmptyParts); +#endif if (suffixList.isEmpty()) return QString(); diff --git a/src/widgets/dialog/cexportimagedialog.cpp b/src/widgets/dialog/cexportimagedialog.cpp index 5cdfc5bb4..9b9482971 100644 --- a/src/widgets/dialog/cexportimagedialog.cpp +++ b/src/widgets/dialog/cexportimagedialog.cpp @@ -528,7 +528,7 @@ void CExportImageDialog::CExportImageDialog_private::initSizeSettingLayoutUi(QFo group->addButton(_radioPiexlBtn, EPixelModel); #if (QT_VERSION_MAJOR == 5) // 在Qt 5中,连接按钮切换信号,使用QAbstractButton*和bool作为参数 - connect(group, SIGNAL(buttonToggled(QAbstractButton*, bool)), _q, [ = ](QAbstractButton *button, bool checked) { + connect(group, QOverload::of(&QButtonGroup::buttonToggled), _q, [ = ](QAbstractButton *button, bool checked) { if (checked) { settingModel = ESizeSettingModel(group->id(button)); // 获取按钮的ID updateSettingModelUi();