Skip to content

Conversation

@deepin-ci-robot
Copy link
Contributor

@deepin-ci-robot deepin-ci-robot commented Oct 28, 2025

Synchronize source files from linuxdeepin/dtkdeclarative.

Source-pull-request: linuxdeepin/dtkdeclarative#545

Summary by Sourcery

Propagate context menu visibility in TextField and SearchEdit to maintain focus and UI consistency when interacting with the context menu.

Enhancements:

  • Add contextMenuVisible alias to TextField to expose the context menu’s visible state
  • Show TextField border when the context menu is open
  • Refocus TextField when its context menu is closed
  • Update SearchEdit to treat an open context menu as editing state for padding adjustments

Synchronize source files from linuxdeepin/dtkdeclarative.

Source-pull-request: linuxdeepin/dtkdeclarative#545
@sourcery-ai
Copy link

sourcery-ai bot commented Oct 28, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR synchronizes changes from linuxdeepin/dtkdeclarative by exposing context menu visibility in TextField and SearchEdit components, integrating it into border styling, editing state logic, and ensuring the field retains focus when the context menu closes.

Sequence diagram for TextField focus retention on context menu close

sequenceDiagram
participant TextField
participant contextMenu
actor User
User->>contextMenu: Close context menu
contextMenu->>TextField: onClosed triggers forceActiveFocus()
TextField->>TextField: Retain focus
Loading

Class diagram for updated TextField and SearchEdit components

classDiagram
class TextField {
  +alertText
  +alertDuration
  +showAlert
  +contextMenuVisible
}
class EditPanel {
  +showBorder
}
class Menu {
  +onClosed
}
class SearchEdit {
  +placeholder
  +editting
}
TextField --> EditPanel : background
TextField --> Menu : contextMenu
SearchEdit --> TextField : inherits LineEdit
Loading

File-Level Changes

Change Details Files
Integrate context menu visibility into TextField behavior
  • Expose menu visible state via contextMenuVisible alias
  • Include contextMenuVisible in showBorder condition
  • Add onClosed handler to refocus control upon menu close
qt6/src/qml/TextField.qml
Include context menu visibility in SearchEdit's editing state logic
  • Extend editting property to consider contextMenuVisible
qt6/src/qml/SearchEdit.qml

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
Contributor Author

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: deepin-ci-robot

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

@deepin-ci-robot
Copy link
Contributor Author

deepin pr auto review

我来分析一下这段代码的修改:

  1. 代码修改概述:
  • 在 SearchEdit.qml 中,修改了 editting 属性的判断条件
  • 在 TextField.qml 中添加了 contextMenuVisible 属性和相关的焦点处理逻辑
  1. 具体分析:

SearchEdit.qml 修改:

property bool editting: control.activeFocus || control.contextMenuVisible || (text.length !== 0)
  • 优点:添加了 contextMenuVisible 的判断,使得在显示右键菜单时也能保持编辑状态
  • 建议:属性名 "editting" 有拼写错误,应该是 "editing"

TextField.qml 修改:

property alias contextMenuVisible: contextMenu.visible
showBorder: control.activeFocus || control.contextMenuVisible
onClosed: control.forceActiveFocus()
  • 优点:
    1. 添加了 contextMenuVisible 属性,便于外部组件访问菜单状态
    2. 边框显示逻辑更完整,在显示右键菜单时保持边框
    3. 在菜单关闭时强制获取焦点,提供更好的用户体验
  1. 改进建议:

a) 修复拼写错误:

// SearchEdit.qml
property bool editing: control.activeFocus || control.contextMenuVisible || (text.length !== 0)

b) 性能优化建议:

  • 可以考虑在 contextMenuVisible 变化时使用 Qt.callLater 来延迟处理,避免不必要的重复计算

c) 安全性建议:

  • 在 forceActiveFocus() 之前可以添加条件检查,确保组件仍然存在且可见

d) 代码质量建议:

  • 建议添加注释说明这些修改的具体用途
  • 可以考虑将 contextMenuVisible 的逻辑封装成一个单独的属性或方法,便于维护
  1. 总体评价:
    这些修改主要改善了用户界面交互体验,特别是在处理右键菜单时的状态管理。代码逻辑合理,但存在小的拼写错误需要修正。建议在后续版本中考虑上述优化建议,以提高代码的可维护性和健壮性。

@18202781743 18202781743 merged commit 9ca404a into master Oct 28, 2025
13 of 16 checks passed
@18202781743 18202781743 deleted the sync-pr-545-nosync branch October 28, 2025 07:54
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