Skip to content

Merge from qt6.8 branch#1106

Merged
deepin-mozart merged 9 commits intoCodeya-IDE:masterfrom
deepin-mozart:master
Apr 22, 2025
Merged

Merge from qt6.8 branch#1106
deepin-mozart merged 9 commits intoCodeya-IDE:masterfrom
deepin-mozart:master

Conversation

@deepin-mozart
Copy link
Contributor

@deepin-mozart deepin-mozart commented Apr 22, 2025

Summary by Sourcery

Port the project to support both Qt5 and Qt6, addressing compatibility issues and updating code to work with newer Qt versions

Enhancements:

  • Introduced conditional compilation to support both Qt5 and Qt6 across the project
  • Updated deprecated Qt APIs and methods to work with newer Qt versions
  • Modified build system to detect and use appropriate Qt version

Build:

  • Updated CMake configuration to support Qt5 and Qt6 detection
  • Added version-specific package and library finding
  • Introduced QT_VERSION_MAJOR variable to conditionally compile code

CI:

  • Updated build scripts to handle Qt version detection
  • Modified project configuration to support multiple Qt versions

LiHua000 and others added 9 commits February 10, 2025 19:59
add -fpic

Log: as title.
Log:
Change-Id: Id5c85a4f865e619ed1dd16dbee397d197f0fcfd2
enable fpic flag

Log:
Change-Id: I1ae86cb8051484b80c455874ee3427436a168370
Log:
Change-Id: I897dcd763bffadd1f6a5f1d6ab74422fcf9f8e8a
Log:
Change-Id: Ifd5519f7b06a9f59bac0155a7b57d53e1900371d
Change-Id: I496ba14479a12ccb4b69c05b3863acf435a77913
@github-actions
Copy link

  • 检测到debian目录文件有变更: debian/control,debian/rules

@github-actions
Copy link

TAG Bot

TAG: 1.4.9
EXISTED: no
DISTRIBUTION: UNRELEASED

@sourcery-ai
Copy link

sourcery-ai bot commented Apr 22, 2025

Reviewer's Guide by Sourcery

This pull request merges changes from the qt6.8 branch. It includes updates for Qt6 compatibility, migration from QRegExp to QRegularExpression, and various bug fixes and improvements.

No diagrams generated as the changes look simple and do not need a visual representation.

File-Level Changes

Change Details Files
Addressed Qt6 compatibility issues by using preprocessor directives and Qt version checks.
  • Used #if QT_VERSION < 0x060000 to conditionally apply QFont::ForceIntegerMetrics.
  • Used #if QT_VERSION >= 0x060000 to conditionally use Qt::MiddleButton instead of Qt::MidButton.
  • Used #if QT_VERSION <= 0x060000 to conditionally use getCharacterPosition(ev->pos()) instead of getCharacterPosition(ev->position().toPoint()).
  • Used #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) to conditionally use QStringList text = textline.split("\n", QString::SkipEmptyParts); instead of QStringList text = textline.split("\n", Qt::SkipEmptyParts);
3rdparty/unioncode-qtermwidget-0.14.1/lib/TerminalDisplay.cpp
Migrated from QRegExp to QRegularExpression for improved regular expression handling.
  • Replaced QRegExp with QRegularExpression in diff_match_patch.cpp.
  • Replaced QRegExp with QRegularExpression in KeyboardTranslator.cpp.
  • Replaced QRegExp with QRegularExpression in ColorScheme.cpp.
  • Replaced QRegExp with QRegularExpression in InlineChatWidget.cpp.
  • Replaced QRegExp with QRegularExpression in TextEditor.cpp.
  • Replaced QRegExp with QRegularExpression in CodePorting.cpp.
  • Replaced QRegExp with QRegularExpression in ConfigPropertyWidget.cpp.
  • Replaced QRegExp with QRegularExpression in SymbolParser.cpp.
  • Replaced QRegExp with QRegularExpression in CodeCompletionModel.cpp.
  • Replaced QRegExp with QRegularExpression in QTermWidget.cpp.
  • Replaced QRegExp with QRegularExpression in PersistentSettings.cpp.
3rdparty/diff-match-patch/diff_match_patch.cpp
3rdparty/unioncode-qtermwidget-0.14.1/lib/KeyboardTranslator.cpp
3rdparty/unioncode-qtermwidget-0.14.1/lib/ColorScheme.cpp
src/plugins/chat/widgets/inlinechatwidget.cpp
src/plugins/codeeditor/gui/texteditor.cpp
src/plugins/codeporting/codeporting.cpp
src/plugins/python/python/project/properties/configpropertywidget.cpp
src/plugins/symbol/mainframe/symbolparser.cpp
src/plugins/codeeditor/gui/completion/codecompletionmodel.cpp
3rdparty/unioncode-qtermwidget-0.14.1/lib/qtermwidget.cpp
src/plugins/option/optioncore/mainframe/persistentsettings.cpp
Updated CMakeLists.txt files to use Qt6 when available, otherwise fallback to Qt5.
  • Added find_package(Qt6 COMPONENTS Core QUIET) to check for Qt6.
  • Set QT_VERSION_MAJOR based on whether Qt6 was found.
  • Conditionally used find_package(Qt6) or find_package(Qt5) for various Qt modules.
  • Conditionally linked against Qt6:: or Qt5:: libraries.
  • Added DTK version check.
src/plugins/javascript/CMakeLists.txt
CMakeLists.txt
3rdparty/unioncode-qtermwidget-0.14.1/CMakeLists.txt
Modified DapSession::slotReceiveClientInfo to correctly convert process ID to a string.
  • Changed getppid() to QString::number(getppid()) to ensure correct string comparison.
src/tools/debugadapter/dapsession.cpp
Improved sorting in cmakeasynparse.cpp to handle project files, directories, and other files separately.
  • Modified the sorting logic to first separate cmake files, directories, files, and other items.
  • Sorted directories and files alphabetically.
  • Appended the lists in the desired order: cmake files, directories, files, and others.
src/plugins/cxx/cmake/project/cmakeasynparse.cpp
Fixed a wheel event handling bug in TerminalDisplay.cpp.
  • Added a check for ev->angleDelta().y() == 0 to prevent processing horizontal wheel events.
  • Used ev->angleDelta().y() instead of ev->delta() to determine the wheel rotation.
  • Used ev->position().toPoint() instead of ev->pos() for Qt6 compatibility.
3rdparty/unioncode-qtermwidget-0.14.1/lib/TerminalDisplay.cpp
Addressed a potential eavesdropping issue in KPty::open() by adding a Qt version check.
  • Added #if QT_VERSION >= 0x060000 to conditionally use Qt::endl instead of endl.
3rdparty/unioncode-qtermwidget-0.14.1/lib/kpty.cpp
Fixed a layout issue in ChatWidget by setting contents margins instead of margins.
  • Changed mainLayout->setMargin(0) to mainLayout->setContentsMargins(0, 0, 0, 0).
src/plugins/chat/widgets/chatwidget.cpp
Replaced qsrand with QRandomGenerator::global()->bounded() for random number generation in ColorScheme.cpp.
  • Replaced qsrand(randomSeed) with Q_UNUSED(randomSeed).
  • Replaced qrand() % range.hue with QRandomGenerator::global()->bounded(range.hue).
3rdparty/unioncode-qtermwidget-0.14.1/lib/ColorScheme.cpp
Fixed a potential issue in Settings::groupList() and Settings::keyList() by using Qt6-compatible iteration.
  • Added #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) to conditionally use QSet<QString>::fromList() instead of iterating through the keys.
src/common/settings/settings.cpp
Fixed a potential issue in InlineChatWidgetPrivate::askForChat() by using a lambda function for QtConcurrent::run.
  • Replaced futureWatcher->setFuture(QtConcurrent::run(this, &InlineChatWidgetPrivate::createPrompt, question, false)); with futureWatcher->setFuture(QtConcurrent::run([this, &question](){ return this->createPrompt(question, false); }));
src/plugins/chat/widgets/inlinechatwidget.cpp
Fixed a potential issue in Vt102Emulation::sendMouseEvent() by using QChar to create the coordinate string.
  • Replaced coords[0] = cx + 0x20; with coords[0] = QChar(cx + 0x20);.
  • Replaced coords[1] = cy + 0x20; with coords[1] = QChar(cy + 0x20);.
3rdparty/unioncode-qtermwidget-0.14.1/lib/Vt102Emulation.cpp
Fixed a potential issue in TextEditor::replaceRange() by casting the length of the text to an int.
  • Replaced SendScintilla(SCI_GOTOPOS, startPosition + text.length()); with SendScintilla(SCI_GOTOPOS, startPosition + int(text.length()));
src/plugins/codeeditor/gui/texteditor.cpp
Fixed a potential issue in KPtyProcess by moving setupChildProcess() to the constructor and adding a Qt version check.
  • Added #if QT_VERSION < 0x060000 to conditionally compile setupChildProcess().
  • Added setChildProcessModifier for Qt6 compatibility.
3rdparty/unioncode-qtermwidget-0.14.1/lib/kptyprocess.cpp
Fixed a potential issue in Controller::initMainWindow() by adding a Qt version check.
  • Added #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) to conditionally use QApplication::desktop() instead of QGuiApplication::screens().
src/plugins/core/uicontroller/controller.cpp
Fixed a potential issue in CodeCompletionWidget::cursorPositionChanged() by adding a Qt version check.
  • Added #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) to conditionally use proxyModel->setFilterRegExp(filter); instead of proxyModel->setFilterRegularExpression(filter);
src/plugins/codeeditor/gui/completion/codecompletionwidget.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @deepin-mozart - I've reviewed your changes - here's some feedback:

Overall Comments:

  • The Qt version checks could be simplified by using QT_VERSION >= QT_MAKE_VERSION(6, 0, 0).
  • Consider using QDir::home() instead of QDir::homePath() for better code clarity.
Here's what I looked at during the review
  • 🟡 General issues: 5 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines -579 to 580
setSelection(lineFrom, indexFrom, lineTo, indexTo);
QStringList lines = selectedText().split(QRegExp("\\r\\n|\\n|\\r"));
QStringList lines = selectedText().split(QRegularExpression("\\r\\n|\\n|\\r"));
for (const QString &line : lines) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Replace QRegExp with QRegularExpression for splitting text.

This update aligns with Qt6 improvements. Be sure the regex semantics remain consistent with the previous implementation.

Suggested implementation:

    QStringList lines = selectedText().split(QRegularExpression(R"(\r\n|\n|\r)"));
    QStringList lines = selectedTexts.split(QRegularExpression(R"(\r\n|\n|\r)"));

Comment on lines 35 to 39
QString name;
QString path;
bool operator ==(const ToolChainParam &param) {
bool operator ==(const ToolChainParam &param) const {
return (this->name == param.name && this->path == param.path);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Maintain const correctness for operator==.

Marking the equality operator as const allows for comparisons on const instances and increases overall code safety.

Suggested change
QString name;
QString path;
bool operator ==(const ToolChainParam &param) {
bool operator ==(const ToolChainParam &param) const {
return (this->name == param.name && this->path == param.path);
}
QString name;
QString path;
bool operator ==(const ToolChainParam &param) const {
return (this->name == param.name && this->path == param.path);
}

this, &DirectoryGenerator::handleItemUpdated,
Qt::UniqueConnection);
QtConcurrent::run(ginfo.parser, &DirectoryAsynParse::parseProject, info);
QtConcurrent::run([ginfo, &info](){ ginfo.parser->parseProject(info); });
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question (bug_risk): Review lambda capture to avoid potential lifetime issues.

Capturing 'info' by reference in an asynchronous lambda might lead to dangling references if 'info' goes out of scope. Consider capturing it by value to ensure thread safety.

@@ -46,4 +46,4 @@ file(GLOB ICON "${CMAKE_CURRENT_SOURCE_DIR}/configures/*.svg")

install(FILES ${SUPPORTFILES} DESTINATION "${SOURCES_INSTALL_RPEFIX}/configures")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (typo): Typo: SOURCES_INSTALL_RPEFIX

Did you mean SOURCES_INSTALL_PREFIX?

Suggested implementation:

install(FILES ${SUPPORTFILES} DESTINATION "${SOURCES_INSTALL_PREFIX}/configures")

install(FILES ${ICON} DESTINATION "${SOURCES_INSTALL_PREFIX}/configures/icons")

install(FILES ${SUPPORTFILES} DESTINATION "${SOURCES_INSTALL_RPEFIX}/configures")
install(FILES ${DESKTOPFILES} DESTINATION "/usr/share/applications")
install(FILES ${ICON} DESTINATION "${SOURCES_INSTALL_RPEFIX}/configures/icons")
install(FILES ${ICON} DESTINATION "${SOURCES_INSTALL_RPEFIX}/configures/icons") No newline at end of file
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (typo): Typo: SOURCES_INSTALL_RPEFIX

Did you mean SOURCES_INSTALL_PREFIX?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

合并过程暂不处理这类问题,保证原子性

@github-actions
Copy link

  • 敏感词检查失败, 检测到3个文件存在敏感词
详情
{
    "src/plugins/core/uicontroller/controller.cpp": [
        {
            "line": "        QDesktopServices::openUrl(QUrl(\"https://github.com/linuxdeepin/deepin-unioncode/issues\"));",
            "line_number": 1206,
            "rule": "S35",
            "reason": "Url link | f8f0d2a7c7"
        },
        {
            "line": "        QDesktopServices::openUrl(QUrl(\"https://uosdn.uniontech.com/#document2?dirid=656d40a9bd766615b0b02e5e\"));",
            "line_number": 1213,
            "rule": "S35",
            "reason": "Url link | f9197a3d4e"
        }
    ],
    "debian/control": [
        {
            "line": "Homepage: http://www.deepin.org",
            "line_number": 49,
            "rule": "S35",
            "reason": "Url link | 6fe814dfb7"
        }
    ],
    "3rdparty/unioncode-qtermwidget-0.14.1/lib/TerminalDisplay.cpp": [
        {
            "line": "                                                \"<a href=\\"http://en.wikipedia.org/wiki/Flow_control\\">suspended</a>\"",
            "line_number": 3214,
            "rule": "S35",
            "reason": "Url link | 4c5b21a1de"
        }
    ]
}

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: deepin-mozart, Kakueeen

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@deepin-mozart deepin-mozart merged commit 51f61d0 into Codeya-IDE:master Apr 22, 2025
9 of 11 checks passed
@Kakueeen Kakueeen mentioned this pull request Feb 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants