Skip to content

Conversation

@pengfeixx
Copy link
Contributor

@pengfeixx pengfeixx commented Nov 12, 2025

Fix the issue of incomplete display of long text

Log: Fix the issue of incomplete display of long text
pms: BUG-338961

Summary by Sourcery

Fix truncated notification text by dynamically calculating and applying implicit heights to the notification content container and its column layout based on child element heights.

Bug Fixes:

  • Prevent incomplete display of long notification text by adjusting implicitHeight on the content container.

Enhancements:

  • Introduce contentRow and contentColumn IDs and compute contentColumn.implicitHeight as the sum of firstLine, title, and bodyText heights.
  • Add implicitHeight binding to the Control wrapper to match the calculated content height.

Fix the issue of incomplete display of long text

Log: Fix the issue of incomplete display of long text
pms: BUG-338961
@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: pengfeixx

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

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

@sourcery-ai
Copy link

sourcery-ai bot commented Nov 12, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

The PR resolves truncated notification text by replacing static height fills with calculated implicitHeight bindings on the content container, ensuring the control resizes based on its children’s actual heights.

Class diagram for updated layout components in NotifyItemContent.qml

classDiagram
    class NotifyItem {
    }
    class Control {
        +implicitHeight
    }
    class contentRow
    class contentColumn {
        +implicitHeight
    }
    class firstLine
    class title {
        +implicitHeight
    }
    class bodyText {
        +implicitHeight
    }
    class bodyRow

    NotifyItem --> Control : contains
    Control --> contentRow : contentItem
    contentRow --> contentColumn : contains
    contentColumn --> firstLine : contains
    contentColumn --> title : contains
    contentColumn --> bodyText : contains
    contentColumn --> bodyRow : contains

    contentColumn : -Layout.fillHeight
    contentColumn : +implicitHeight
    Control : +implicitHeight = contentColumn.implicitHeight
    contentColumn : +implicitHeight = sum of children heights
    title : +implicitHeight
    bodyText : +implicitHeight
Loading

Flow diagram for implicitHeight calculation in contentColumn

flowchart TD
    A["firstLine.Layout.preferredHeight"] --> B["Add to height"]
    C["root.title !== ''"] --> D["Add title.implicitHeight to height"]
    E["bodyText.visible && bodyText.implicitHeight > 0"] --> F["Add bodyText.implicitHeight to height"]
    B --> G["Return total height"]
    D --> G
    F --> G
Loading

File-Level Changes

Change Details Files
Propagate dynamic height from contentColumn to root control
  • Added implicitHeight binding on Control impl to contentColumn.implicitHeight
  • Removed Layout.fillHeight on contentColumn
panels/notification/plugin/NotifyItemContent.qml
Compute contentColumn height based on child elements
  • Implemented implicitHeight script to sum heights of firstLine, title, and bodyText
  • Added conditional inclusion for title and bodyText visibility
panels/notification/plugin/NotifyItemContent.qml
Add identifiers for layout and text components
  • Introduced ids: contentRow, contentColumn, title, bodyRow for precise references
  • Updated bindings to use new ids in height calculations
panels/notification/plugin/NotifyItemContent.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

@deepin-ci-robot
Copy link

deepin pr auto review

我来分析一下这段代码的变更:

  1. 代码改动概述:
  • 添加了 implicitHeight 属性来动态计算内容高度
  • 移除了 Layout.fillHeight: true 属性
  • 为多个组件添加了 id 以便引用
  • 增加了自定义的 implicitHeight 计算逻辑
  1. 代码质量改进建议:
  • 优点:

    • 代码结构更清晰,通过添加 id 提高了可读性
    • 动态计算高度的方式更灵活,可以根据实际内容自适应
    • 移除 fillHeight 是合理的,避免不必要的空间占用
  • 潜在问题:

    • implicitHeight 的计算逻辑中,使用 bodyHeight > 0 的判断可能不够严谨,建议改为 bodyHeight > 0 && bodyText.text !== ""
    • 没有对计算出的 height 做边界检查,应该确保其在 minimumHeightmaximumHeight 范围内
  1. 性能优化建议:
  • implicitHeight 的计算可能会在属性变化时频繁触发,建议考虑使用缓存机制
  • 可以将计算逻辑封装成一个单独的函数,提高代码复用性
  1. 安全性考虑:
  • 当前代码没有明显的安全隐患
  • 建议在计算高度时添加异常处理,防止意外的数值导致界面显示问题
  1. 改进建议代码示例:
implicitHeight: {
    var height = firstLine.Layout.preferredHeight
    if (root.title !== "") {
        height += title.implicitHeight
    }
    var bodyHeight = bodyText.implicitHeight
    if (bodyText.visible && bodyHeight > 0 && bodyText.text !== "") {
        height += bodyHeight
    }
    // 确保高度在合理范围内
    return Math.max(NotifyStyle.contentItem.miniHeight, 
                   Math.min(height, 240))
}
  1. 其他建议:
  • 考虑添加属性变化时的过渡动画,使界面变化更平滑
  • 可以添加注释说明 implicitHeight 的计算逻辑,方便其他开发者理解

总的来说,这是一个积极的改动,使布局更加灵活和精确,但还需要一些细节优化来提高代码的健壮性。

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> `panels/notification/plugin/NotifyItemContent.qml:153` </location>
<code_context>
                 Layout.topMargin: NotifyStyle.contentItem.topMargin
                 Layout.bottomMargin: NotifyStyle.contentItem.bottomMargin
                 Layout.fillWidth: true
-                Layout.fillHeight: true
                 Layout.minimumHeight: NotifyStyle.contentItem.miniHeight
                 Layout.maximumHeight: 240
</code_context>

<issue_to_address>
**question:** Removing Layout.fillHeight may affect vertical stretching of contentColumn.

Please verify that removing Layout.fillHeight does not cause layout issues, especially in scenarios where contentColumn should stretch vertically.
</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.

Layout.topMargin: NotifyStyle.contentItem.topMargin
Layout.bottomMargin: NotifyStyle.contentItem.bottomMargin
Layout.fillWidth: true
Layout.fillHeight: true
Copy link

Choose a reason for hiding this comment

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

question: Removing Layout.fillHeight may affect vertical stretching of contentColumn.

Please verify that removing Layout.fillHeight does not cause layout issues, especially in scenarios where contentColumn should stretch vertically.

@18202781743
Copy link
Contributor

18202781743 commented Nov 12, 2025

这个也处理了高度的问题, #1337

@deepin-bot
Copy link

deepin-bot bot commented Nov 13, 2025

TAG Bot

New tag: 2.0.18
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #1349

@deepin-bot
Copy link

deepin-bot bot commented Nov 14, 2025

TAG Bot

New tag: 2.0.19
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #1350

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