Skip to content

sync: from linuxdeepin/dde-session-shell - #550

Open
deepin-ci-robot wants to merge 1 commit into
masterfrom
sync-pr-99-nosync
Open

deepin-ci-robot wants to merge 1 commit into
masterfrom
sync-pr-99-nosync

Conversation

@deepin-ci-robot

@deepin-ci-robot deepin-ci-robot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Synchronize source files from linuxdeepin/dde-session-shell.

Source-pull-request: linuxdeepin/dde-session-shell#99

Summary by Sourcery

Fix password placeholder sizing and elision so it fits correctly alongside embedded line-edit controls.

Bug Fixes:

  • Prevent password placeholder text from overlapping embedded status and action icons by sizing it to the available line-edit content area.
  • Use the effective content width when resizing placeholder fonts, avoiding oversized placeholder text and related layout issues.

Chores:

  • Synchronize the lock desktop entry with the upstream dde-session-shell source.

Synchronize source files from linuxdeepin/dde-session-shell.

Source-pull-request: linuxdeepin/dde-session-shell#99
@deepin-ci-robot

Copy link
Copy Markdown
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

@sourcery-ai

sourcery-ai Bot commented Sep 24, 2026

Copy link
Copy Markdown

Reviewer's Guide

Synchronizes selected files with upstream dde-session-shell, improving placeholder font fitting and rendering by accounting for QLineEdit text/layout margins so placeholder text does not overlap adjacent icons.

Flow diagram for margin-aware placeholder rendering

flowchart TD
    A[Placeholder text and line edit geometry] --> B[Read textMargins]
    B --> C[Read layout contentsMargins]
    C --> D[Compute available text width]
    D --> E[Fit placeholder font to available width]
    E --> F[Build effective text rectangle]
    F --> G[Elide text to rectangle width]
    G --> H[Draw single-line placeholder]
    G --> I[Show tooltip when text is elided]
Loading

File-Level Changes

Change Details Files
Adjust placeholder sizing and rendering to account for the embedded line edit’s margins and icon space.
  • Subtract text and layout content margins when reducing the placeholder font size.
  • Build an effective placeholder rectangle that excludes horizontal margins before eliding and drawing text.
  • Retain tooltip behavior for elided placeholder text.
src/widgets/dlineeditex.cpp
Synchronize the lock desktop entry with the upstream dde-session-shell source.
  • Update the desktop entry contents to match the upstream version.
files/snipe/dde-lock.desktop

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

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@deepin-ci-robot

Copy link
Copy Markdown
Contributor Author

deepin pr auto review

🤖 AI 代码审查报告

总体评分: 94 分 (通过阈值: 70分)

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 总体评分 94 分,大于 70 分通过阈值,代码质量符合要求。本次变更修复了密码占位文本与嵌入图标的重叠问题,逻辑正确,无安全漏洞。

🔍 详细分析

1. 语法逻辑 ✅

评价: 优秀 ✅ 通过

潜在问题:

  1. src/widgets/dlineeditex.cpp:89 - availWidth 在 margins 超过控件宽度时可能为负值,while 循环会执行到 pointSize<=1 后直接 return,不调用 setFont(pre-existing 行为,非本次引入)

建议: 建议在 availWidth 计算后增加对负值或零值的保护判断,如 availWidth = qMax(availWidth, 1),避免极端情况下循环无意义执行。同时建议跟进 TODO 注释中的 font() 问题。


2. 代码质量 ✅

评价: 良好 ✅ 通过

潜在问题:

  1. src/widgets/dlineeditex.cpp:93 - 存在 pre-existing TODO 注释,font() 获取问题尚未调查解决
  2. src/widgets/dlineeditex.cpp:84 - setPlaceholderTextFont 和 paintEvent 中存在相似的 margins 计算逻辑,属于重复代码块

建议: 建议将 margins 计算逻辑提取为独立的辅助方法,如 int DLineEditEx::availableTextWidth() const 或 QMargins DLineEditEx::effectiveMargins() const,减少代码重复,提高可维护性。


3. 代码性能 ✅

评价: 优秀 ✅ 通过

潜在问题:

  1. src/widgets/dlineeditex.cpp:91 - while 循环内每次迭代构造 QFontMetrics 对象(pre-existing,可优化)

建议: 建议将 QFontMetrics 构造移到 while 循环外部,仅更新 fontTmp 后重新计算 boundingRect,减少不必要的对象构造开销。


4. 代码安全 🔒

评价: 优秀 ✅ 通过

🔐 存在 0 个安全漏洞

📊 漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个

安全漏洞详情:
✅ 未发现安全漏洞

建议: 无安全漏洞,代码仅涉及 UI 占位文本渲染逻辑,不存在用户输入直接进入危险操作的风险路径。建议保持现有防御性编程习惯。


💡 改进建议代码示例

// 建议提取公共 margins 计算方法,并优化循环性能

int DLineEditEx::availableTextWidth() const
{
    QMargins textMargins = lineEdit()->textMargins();
    QMargins layoutMargins(0, 0, 0, 0);
    if (auto *layout = lineEdit()->layout()) {
        layoutMargins = layout->contentsMargins();
    }
    int availWidth = width() - textMargins.left() - textMargins.right()
                   - layoutMargins.left() - layoutMargins.right();
    return qMax(availWidth, 1); // 保护负值情况
}

void DLineEditEx::setPlaceholderTextFont(const QFont &font)
{
    const QString &text = lineEdit()->placeholderText();
    QFont fontTmp = font;
    int availWidth = availableTextWidth();
    QFontMetrics fm(fontTmp); // 循环外构造一次
    while (fm.boundingRect(text).width() > availWidth) {
        if (fontTmp.pointSize() <= 1) {
            qWarning() << "Password line edit font size" << font.pointSize() << fontTmp.pointSize();
            return;
        }
        fontTmp.setPointSize(fontTmp.pointSize() - 1);
        fm = QFontMetrics(fontTmp); // 仅更新 metrics
    }
    setFont(fontTmp);
}

本报告由 AI 代码审查工具自动生成

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.

1 participant