Skip to content

Conversation

@GongHeng2017
Copy link

@GongHeng2017 GongHeng2017 commented Nov 19, 2025

-- Add code to adjust QT5

Log: add feature
Task: https://pms.uniontech.com/task-view-383493.html

Summary by Sourcery

Add Qt version checks to support both Qt5 and Qt6, adjusting child process modifiers and widget event handling accordingly.

Enhancements:

  • Add preprocessor guards around setChildProcessModifier calls to apply only for Qt6 and above
  • Conditionally override PreviousLabel::enterEvent with QEvent for Qt5 and QEnterEvent for Qt6 to match API changes

@sourcery-ai
Copy link

sourcery-ai bot commented Nov 19, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Introduce conditional compilation for QT version compatibility by guarding new child process modifier setup calls for QT6+ and aligning enterEvent overload signatures to QT5 or QT6 APIs.

Class diagram for PreviousLabel changes (QT5/QT6 compatibility)

classDiagram
class PreviousLabel {
  +paintEvent(QPaintEvent *e)
  +mouseDoubleClickEvent(QMouseEvent *event)
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
  +enterEvent(QEvent *event)
#else
  +enterEvent(QEnterEvent *event)
#endif
  +leaveEvent(QEvent *event)
  +focusInEvent(QFocusEvent *event)
  +focusOutEvent(QFocusEvent *event)
}
Loading

Class diagram for KPtyProcess changes (QT6 child process modifier)

classDiagram
class KPtyProcess {
  +KPtyProcess(QObject *parent)
  +KPtyProcess(int ptyMasterFd, QObject *parent)
  +~KPtyProcess()
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
  +setChildProcessModifier(lambda)
#endif
}
Loading

File-Level Changes

Change Details Files
Guarded setChildProcessModifier calls for QT6+ in KPtyProcess constructors
  • Added #if QT_VERSION >= QT_VERSION_CHECK(6,0,0) before setChildProcessModifier
  • Wrapped setupChildProcessImpl invocation inside the guard
  • Appended corresponding #endif after the call
3rdparty/interface/process/kptyprocess.cpp
Adjusted PreviousLabel::enterEvent signature based on QT version
  • Inserted #if QT_VERSION < QT_VERSION_CHECK(6,0,0) to declare enterEvent(QEvent*) for QT5
  • Provided else branch defining enterEvent(QEnterEvent*) for QT6
  • Mirrored these guards and signatures in both header and source files
src/source/tree/treeheaderview.cpp
src/source/tree/treeheaderview.h

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!

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 there - I've reviewed your changes and they look great!


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.

@deepin-ci-robot
Copy link

deepin pr auto review

我来对这段代码变更进行审查:

  1. 代码逻辑和语法:
  • 代码正确使用了 QT_VERSION_CHECK 宏来区分 Qt5 和 Qt6 的版本差异
  • 条件编译指令 #if/#endif 的使用是正确的
  • 语法上没有问题
  1. 代码质量:
  • 代码结构清晰,版本判断逻辑合理
  • 修改后的代码保持了向后兼容性
  • 注释清晰,代码可读性良好
  1. 代码性能:
  • 这些修改主要是为了适配不同 Qt 版本的 API 变化,不会对性能产生显著影响
  • 条件编译在预处理阶段完成,不会增加运行时开销
  1. 代码安全:
  • 修改是安全的,正确处理了 Qt5 和 Qt6 之间的 API 差异
  • 在 treeheaderview.h 中有一个小问题:Qt6 版本的 enterEvent 参数类型写成了 EnterEvent,应该是 QEnterEvent

改进建议:

  1. 在 treeheaderview.h 中,Qt6 版本的 enterEvent 参数类型应该修正为 QEnterEvent,而不是 EnterEvent:
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void enterEvent(QEvent *event) override;
#else
void enterEvent(QEnterEvent *event) override;  // 修正:EnterEvent -> QEnterEvent
#endif
  1. 建议在代码中添加更详细的注释,说明为什么需要进行这些版本区分,这样可以帮助其他开发者更好地理解代码的意图。

  2. 考虑将版本判断的宏定义集中到一个头文件中,以便统一管理和维护。

这些修改主要是为了适配 Qt5 和 Qt6 之间的 API 变化,整体实现是合理的,只需要修正上述提到的小问题即可。

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: GongHeng2017, lzwind

The full list of commands accepted by this bot can be found 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

@GongHeng2017
Copy link
Author

/merge

@deepin-bot deepin-bot bot merged commit 165d2e2 into linuxdeepin:develop/snipe Nov 20, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants