Skip to content

Conversation

@caixr23
Copy link
Contributor

@caixr23 caixr23 commented Nov 6, 2025

Modifying text beyond the scope of the control

pms: BUG-317343

Summary by Sourcery

Prevent text overflow in PageDetails by using DccLabel with fillWidth and middle ellipsis for the displayName

Enhancements:

  • Replace Label with DccLabel for the item header to support dynamic sizing and text elision
  • Enable fillWidth and set elide to middle to prevent displayName text from overflowing its container

@sourcery-ai
Copy link

sourcery-ai bot commented Nov 6, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Replaced the default Label with DccLabel and updated its layout and text eliding settings to prevent overflow beyond control boundaries.

Class diagram for updated label usage in PageDetails.qml

classDiagram
    class Label {
    }
    class DccLabel {
        +Layout.alignment: Qt.AlignLeft
        +Layout.fillWidth: true
        +font: DccUtils.copyFont(...)
        +text: dccObj.displayName
        +elide: Text.ElideMiddle
    }
    PageDetails ..> DccLabel : uses
    Label <|-- DccLabel
Loading

File-Level Changes

Change Details Files
Switched from Label to DccLabel for improved styling and behavior
  • Replaced Label component with DccLabel
dcc-network/qml/PageDetails.qml
Enabled dynamic width allocation for the label
  • Added Layout.fillWidth: true to support flexible sizing
dcc-network/qml/PageDetails.qml
Configured middle elision to handle overflowing text
  • Added elide: Text.ElideMiddle to truncate text in the center
dcc-network/qml/PageDetails.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

@caixr23 caixr23 requested a review from mhduiy November 6, 2025 08:18
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!

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location> `dcc-network/qml/PageDetails.qml:45` </location>
<code_context>
-                    Label {
+                    DccLabel {
                         Layout.alignment: Qt.AlignLeft
+                        Layout.fillWidth: true
                         font: DccUtils.copyFont(D.DTK.fontManager.t4, {
                                                     "bold": true
</code_context>

<issue_to_address>
**suggestion:** Setting Layout.fillWidth to true may affect layout responsiveness.

Please verify that expanding the label does not disrupt alignment or spacing of other RowLayout elements, particularly with dynamic content or resizing.

Suggested implementation:

```
                    DccLabel {
                        Layout.alignment: Qt.AlignLeft
                        Layout.fillWidth: true
                        // Debug: Add border to verify label expansion and layout impact
                        border.color: "red"
                        border.width: 1
                        font: DccUtils.copyFont(D.DTK.fontManager.t4, {
                                                    "bold": true
                                                })
                        text: dccObj.displayName
                        elide: Text.ElideMiddle
                        // TODO: Remove border after verifying layout responsiveness
                        // If expansion disrupts layout, consider constraining width:
                        // Layout.preferredWidth: 200
                        // Layout.maximumWidth: 300
                    }

```

After running the application and resizing the window, observe the red border around the label. If the label's expansion disrupts the alignment or spacing of other elements, uncomment and adjust `Layout.preferredWidth` or `Layout.maximumWidth` as needed. Remove the border once verification is complete.
</issue_to_address>

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

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: caixr23, mhduiy

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

Modifying text beyond the scope of the control

pms: BUG-317343
@caixr23 caixr23 merged commit 8ee3046 into linuxdeepin:master Nov 6, 2025
11 of 13 checks passed
@caixr23 caixr23 deleted the BUG-317343 branch November 6, 2025 08:24
@deepin-ci-robot
Copy link

deepin pr auto review

我来帮你分析这段代码的变更。这段修改主要涉及QML界面中标签组件的改进,让我从多个角度进行分析:

  1. 语法逻辑分析:
  • Label 替换为 DccLabel 是合理的,这符合项目的组件命名规范
  • 添加了 Layout.fillWidth: true 属性,让标签可以自适应宽度
  • 添加了 elide: Text.ElideMiddle 属性,当文本过长时会在中间显示省略号
  • 这些修改在语法和逻辑上都是正确的
  1. 代码质量改进:
  • 使用 DccLabel 替代通用 Label 更符合项目规范
  • 文本省略处理提升了用户体验
  • 布局属性的添加使界面更具响应性
  • 代码结构清晰,符合QML最佳实践
  1. 性能优化:
  • Layout.fillWidth 属性的使用是合理的,不会显著影响性能
  • 文本省略处理在渲染时会有轻微开销,但这是必要的用户体验改进
  • 没有引入不必要的性能问题
  1. 安全性考虑:
  • 这段代码修改主要涉及UI展示,没有安全风险
  • 文本显示相关的修改不会引入安全漏洞

改进建议:

  1. 可以考虑添加一个最大宽度限制,避免文本过长时布局变形:
Layout.maximumWidth: parent.width * 0.8
  1. 如果文本可能包含特殊字符,建议添加文本转义处理:
text: dccObj.displayName.toString().escape()
  1. 可以考虑添加一个工具提示,显示完整文本:
ToolTip.text: dccObj.displayName
ToolTip.visible: truncated

总体来说,这是一个良好的改进,提升了界面的可用性和美观性。修改合理,没有明显问题。

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