Skip to content

fix: fix titlebar control overlap at small window widths - #759

Open
add-uos wants to merge 1 commit into
linuxdeepin:masterfrom
add-uos:agent/pms-bug-bot/9f62e4a5
Open

fix: fix titlebar control overlap at small window widths#759
add-uos wants to merge 1 commit into
linuxdeepin:masterfrom
add-uos:agent/pms-bug-bot/9f62e4a5

Conversation

@add-uos

@add-uos add-uos commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

根因分析

强根因WindowTitlebar.qmltitleRowLayoutwidth: parent.width - 20 未计入 anchors.leftMargin: 30,导致 RowLayout 右边缘溢出父容器(DTK TitleBar customCenter)10px,侵入菜单按钮区域。同时响应式阈值 showSearchEdit: titleRowLayout.width > 400 低于内容实际所需宽度 468px(导航82+搜索300+添加36+边距50),当宽度在 400~468px 之间时搜索框和添加按钮显示但无法容纳,AlignCenter/AlignRight 布局导致控件互相重叠。

关键证据

  • WindowTitlebar.qml:216width: parent.width - 20 + leftMargin: 30 → 右边缘溢出 10px
  • WindowTitlebar.qml:220 — 阈值 400 < 内容所需 468px
  • DTK TitleBar customCenter 紧邻 optionMenuBtn(菜单按钮),溢出直接侵入

修复方案

  1. width: parent.width - 20 + anchors.left 改为 anchors.left + anchors.right 双端锚定(leftMargin 30, rightMargin 20),消除溢出
  2. showSearchEdit 阈值从 400 提高到 500,确保内容能完全容纳时才显示

改动安全评估

低风险:仅调整 QML 布局属性和条件阈值,无函数签名变更,无外部调用者(References=0)。修改的代码行中,width/anchors 部分为 2023 年原始代码(非之前修复),阈值部分为 2026-01 修复的改进(非撤销)。

Summary by Sourcery

Adjust title bar layout responsiveness to prevent control overlap at small window widths.

Bug Fixes:

  • Fix title bar center layout overflowing into the menu button area at narrow window widths.
  • Update the search field visibility threshold so search and add controls only appear when there is sufficient space.

Fix titleRowLayout width overflow by replacing the explicit
"width: parent.width - 20" with left-right anchor binding so the
RowLayout no longer overflows its parent container. Also raise the
search edit responsive threshold from 400 to 500 so the search box
and add button are only shown when the full content (468px) fits.

修复标题栏 titleRowLayout 宽度计算溢出问题,将显式宽度 parent.width - 20
改为左右双端锚定(leftMargin 30 + rightMargin 20),消除 10px 溢出;
将搜索框响应式显示阈值从 400 提高到 500,确保内容能完全容纳时才显示,
避免搜索框、添加按钮与菜单按钮/窗口控制按钮重叠。

Log: 修复音乐应用在768P或更小分辨率窗口居左或居右时标题栏控件重叠的问题
PMS: BUG-330047
Influence: 修复窗口在小分辨率下居左或居右时,标题栏搜索框和添加按钮因布局
溢出和响应式阈值过低而与右侧菜单按钮、窗口控制按钮重叠的问题。

@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.

Sorry @add-uos, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: add-uos

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 Aug 12, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjusts the titlebar center layout anchoring and responsive threshold to prevent control overlap at small window widths.

Flow diagram for updated responsive titlebar controls

flowchart LR
    P[ParentTitleBar]
    T[titleRowLayout]

    P --> T
    T[titleRowLayout\nanchors.leftMargin = 30\nanchors.rightMargin = 20]

    W[titleRowLayout.width]
    T --> W

    W --> C{width > 500}
    C -->|yes| SE_true[showSearchEdit = true]
    C -->|no| SE_false[showSearchEdit = false]

    W --> N{width > 300}
    N -->|yes| SN_true[showNavButtons = true]
    N -->|no| SN_false[showNavButtons = false]
Loading

File-Level Changes

Change Details Files
Fix titlebar center content width calculation and responsive visibility threshold to avoid overlapping controls at narrow window widths.
  • Replace explicit width calculation with symmetric left/right anchoring using leftMargin and rightMargin to keep the layout within the parent container.
  • Add right anchor and rightMargin so the titleRowLayout width naturally respects both margins and no longer overflows into the menu button area.
  • Increase the showSearchEdit visibility threshold from 400 to 500 so the search box and add button are only shown when there is enough horizontal space to contain them without overlap.
  • Add an inline comment documenting the actual required content width (~468px) and the rationale for choosing the 500px threshold.
src/music-player/mainwindow/WindowTitlebar.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
Copy Markdown

deepin pr auto review

★ 总体评分:100分

■ 【总体评价】

代码优化了QML标题栏布局方式并修正了响应式显示阈值,彻底解决了UI控件重叠缺陷
逻辑完全正确且代码规范优秀,无任何扣分项

■ 【详细分析】

  • 1.语法逻辑(完全正确)✓

将硬编码的宽度计算 width: parent.width - 20 替换为标准的锚点布局 anchors.leftanchors.right 配合 leftMarginrightMargin,符合QML响应式布局规范,消除了因父容器尺寸变化导致的布局异常。将 showSearchEdit 阈值从 400 提升至 500,准确匹配了实际子控件(导航82+搜索300+添加36+边距50=468px)的宽度需求。
建议:继续保持使用锚点布局替代硬编码尺寸的做法

  • 2.代码质量(优秀)✓

增加了详尽的算术注释,清晰说明了 500px 阈值的推导过程(82+300+36+50=468),极大提升了代码的可读性和后续维护性。布局属性结构清晰,去除了硬编码的魔法数字。
建议:无

  • 3.代码性能(无性能问题)✓

修改仅涉及布局引擎的锚点绑定计算和简单的属性比较表达式,未引入任何额外的组件实例化、复杂的循环嵌套或频繁的属性信号触发,对运行时性能无负面影响。
建议:无

  • 4.代码安全(存在0个安全漏洞)✓

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个
本次修改仅涉及 QML 前端 UI 布局与显示逻辑,不包含任何网络请求、文件读写、命令执行或用户敏感数据处理,不存在安全攻击面。
建议:无

■ 【改进建议代码示例】

--- a/src/music-player/mainwindow/WindowTitlebar.qml
+++ b/src/music-player/mainwindow/WindowTitlebar.qml
@@ -210,14 +210,17 @@ TitleBar {
 
         RowLayout {
             id: titleRowLayout
-            width: parent.width - 20
             anchors {
                 left: parent.left
+                right: parent.right
                 leftMargin: 30
+                rightMargin: 20
             }
 
             // 响应式显示控制 - 使用内容区域自身宽度判断
-            property bool showSearchEdit: titleRowLayout.width > 400
+            // 搜索框+添加按钮全部显示时需要约 468px(导航82+搜索300+添加36+边距50),
+            // 阈值取 500 确保内容能完全容纳时才显示,避免控件重叠
+            property bool showSearchEdit: titleRowLayout.width > 500
             property bool showNavButtons: titleRowLayout.width > 300
 
             RowLayout {

@deepin-bot

deepin-bot Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

TAG Bot

New tag: 7.0.63
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #762

@deepin-bot

deepin-bot Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

TAG Bot

New tag: 7.0.64
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #765

@deepin-bot

deepin-bot Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

TAG Bot

New tag: 7.0.65
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #768

@deepin-bot

deepin-bot Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

TAG Bot

New tag: 7.0.66
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #779

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.

2 participants