Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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库
Expand Down Expand Up @@ -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
Expand Down
25 changes: 12 additions & 13 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,27 @@ Maintainer: Deepin Packages Builder <packages@deepin.com>
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
22 changes: 11 additions & 11 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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") # 设置可执行文件的链接标志

# 设置编译器/链接器标志
Expand Down Expand Up @@ -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
)

# 添加调试信息
Expand All @@ -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 链接逻辑
Expand Down
19 changes: 0 additions & 19 deletions src/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -469,7 +451,6 @@ bool Application::isFileNameLegal(const QString &path, int *outErrorReson)
}
}
}
#endif

bool isdir = (path.endsWith('/') || path.endsWith('\\'));
return !isdir;
Expand Down
4 changes: 4 additions & 0 deletions src/drawshape/cdrawscene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,14 @@
#include <QGraphicsView>
#include <QPainterPath>
#include <QtMath>
#include <DApplication>

Check warning on line 41 in src/drawshape/cdrawscene.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <DApplication> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QScrollBar>

Check warning on line 42 in src/drawshape/cdrawscene.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QScrollBar> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QWindow>

Check warning on line 43 in src/drawshape/cdrawscene.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QWindow> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include <QtSvgWidgets/QGraphicsSvgItem>
#else
#include <QtSvg/QGraphicsSvgItem>

Check warning on line 47 in src/drawshape/cdrawscene.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QtSvg/QGraphicsSvgItem> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#endif

DWIDGET_USE_NAMESPACE

Expand Down
23 changes: 0 additions & 23 deletions src/drawshape/drawItems/csizehandlerect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions src/drawshape/drawItems/csizehandlerect.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
#ifndef CSIZEHANDLERECT
#define CSIZEHANDLERECT

#if (QT_VERSION_MAJOR == 5)
#include <QGraphicsSvgItem>
#elif (QT_VERSION_MAJOR == 6)
#include <QtSvgWidgets/QGraphicsSvgItem>
#endif

#include <QGraphicsRectItem>

Check warning on line 8 in src/drawshape/drawItems/csizehandlerect.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QGraphicsRectItem> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QList>

Check warning on line 9 in src/drawshape/drawItems/csizehandlerect.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QList> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QSvgRenderer>

Check warning on line 10 in src/drawshape/drawItems/csizehandlerect.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QSvgRenderer> not found. Please note: Cppcheck does not need standard library headers to get proper results.

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include <QtSvgWidgets/QGraphicsSvgItem>
#else
#include <QtSvg/QGraphicsSvgItem>

Check warning on line 15 in src/drawshape/drawItems/csizehandlerect.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QtSvg/QGraphicsSvgItem> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#endif

QT_BEGIN_NAMESPACE
class QFocusEvent;
class QGraphicsItem;
Expand Down
4 changes: 2 additions & 2 deletions src/drawshape/drawTools/ctexttool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>::of(&QComboBox::currentIndexChanged), this, [ = ](int index) {
// 获取当前选中的字体
QString family = fontComboBox->itemText(index);
// 标记为活动预览
Expand All @@ -366,7 +366,7 @@ void CTextTool::initFontFamilyWidget(QComboBox *fontHeavy)
});

// 连接当前索引变化信号,处理高亮显示的字体
connect(fontComboBox, &QComboBox::currentIndexChanged, this, [ = ](int index) {
connect(fontComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [ = ](int index) {
// 获取当前高亮的字体
QString family = fontComboBox->itemText(index);
// 预览的不用支持撤销还原
Expand Down
2 changes: 1 addition & 1 deletion src/frame/cgraphicsview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<CShapeMimeData *>(mp);
Expand Down
4 changes: 4 additions & 0 deletions src/frame/cmultiptabbarwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion src/widgets/dialog/cexportimagedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<QAbstractButton *, bool>::of(&QButtonGroup::buttonToggled), _q, [ = ](QAbstractButton *button, bool checked) {
if (checked) {
settingModel = ESizeSettingModel(group->id(button)); // 获取按钮的ID
updateSettingModelUi();
Expand Down