Skip to content

fix: center dialog title with vertical offset#620

Merged
mhduiy merged 1 commit into
linuxdeepin:masterfrom
MyLeeJiEun:fork-from-master-0515-fix-issue-361279
May 18, 2026
Merged

fix: center dialog title with vertical offset#620
mhduiy merged 1 commit into
linuxdeepin:masterfrom
MyLeeJiEun:fork-from-master-0515-fix-issue-361279

Conversation

@MyLeeJiEun
Copy link
Copy Markdown
Contributor

@MyLeeJiEun MyLeeJiEun commented May 15, 2026

  1. Replace plain title text with a centered D.Label in DialogTitleBar
  2. Align title horizontally centered and vertically offset downward by 30px
  3. Constrain title max width to prevent overlapping with side buttons

Log: Center the dialog window title with downward offset and width limit

fix: 对话框标题居中并添加垂直偏移

  1. 将 DialogTitleBar 中的纯文本标题替换为居中的 D.Label 组件
  2. 标题水平居中,垂直方向向下偏移 30 像素
  3. 限制标题最大宽度,避免与两侧按钮重叠

Log: 将对话框窗口标题居中并设置下移偏移和宽度限制
PMS: BUG-361279

Summary by Sourcery

Bug Fixes:

  • Center the dialog title within the title bar while preventing it from overlapping adjacent buttons or icons.

@deepin-ci-robot
Copy link
Copy Markdown
Contributor

Hi @MyLeeJiEun. Thanks for your PR.

I'm waiting for a linuxdeepin member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 15, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Centers the dialog window title by replacing the plain title string with a styled D.Label in DialogTitleBar, applying horizontal centering, a vertical downward offset, and a max-width constraint to avoid overlap with side buttons.

File-Level Changes

Change Details Files
Render the dialog title via a centered D.Label with vertical offset and width constraint instead of using the DialogTitleBar title property.
  • Replace the simple title binding with an inline D.Label component bound to control.title
  • Center the label horizontally within the title bar and vertically via verticalCenter plus a 30px downward offset
  • Reuse title bar font and palette for the label to preserve existing styling
  • Constrain the label width to min(implicitWidth, parent.width - 120) to prevent overlap with icons/buttons and enable right-side eliding with centered alignment
qt6/src/qml/DialogWindow.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
Copy Markdown

@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 - I've found 2 issues, and left some high level feedback:

  • The new D.Label references titleBar.font and titleBar.palette, but titleBar is not defined in this scope of DialogWindow.qml; consider binding to a property that is actually available here (e.g., from control or DialogTitleBar's exposed properties) to avoid runtime errors.
  • The hard-coded constants verticalCenterOffset: 30 and parent.width - 120 are magic numbers that may not adapt well to different title bar layouts or DPI; it would be more robust to derive these offsets from the actual title bar height and side button widths or expose them as configurable properties.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new D.Label references `titleBar.font` and `titleBar.palette`, but `titleBar` is not defined in this scope of DialogWindow.qml; consider binding to a property that is actually available here (e.g., from `control` or `DialogTitleBar`'s exposed properties) to avoid runtime errors.
- The hard-coded constants `verticalCenterOffset: 30` and `parent.width - 120` are magic numbers that may not adapt well to different title bar layouts or DPI; it would be more robust to derive these offsets from the actual title bar height and side button widths or expose them as configurable properties.

## Individual Comments

### Comment 1
<location path="qt6/src/qml/DialogWindow.qml" line_range="76-77" />
<code_context>
+                        anchors.verticalCenterOffset: 30 // 正数向下移,根据视觉效果调整
+
+                        // --- 样式设置 ---
+                        font: titleBar.font 
+                        palette: titleBar.palette
+
+                        // 限制最大宽度,避免文字太长冲到左右两边的按钮或图标
</code_context>
<issue_to_address>
**issue (bug_risk):** Using `titleBar` here is likely invalid, since ids are not visible across component boundaries.

Within `sourceComponent: DialogTitleBar { ... }`, the `titleBar` id defined inside `DialogTitleBar` is not in scope—ids are local to their own component. This will resolve to an undefined or incorrect object. To reuse the title bar styling, either bind to something in scope (e.g. `parent.font` / `parent.palette`) or have `DialogTitleBar` expose the needed values via properties (e.g. `property font titleFont`, `property palette titlePalette`) and bind to those instead.
</issue_to_address>

### Comment 2
<location path="qt6/src/qml/DialogWindow.qml" line_range="80" />
<code_context>
+                        palette: titleBar.palette
+
+                        // 限制最大宽度,避免文字太长冲到左右两边的按钮或图标
+                        width: Math.min(implicitWidth, parent.width - 120)
+                        elide: Text.ElideRight
+                        horizontalAlignment: Text.AlignHCenter
</code_context>
<issue_to_address>
**issue (bug_risk):** Width calculation can become negative when `parent.width` is small.

When `parent.width < 120`, `parent.width - 120` becomes negative, so `width` can be set to a negative value, causing layout issues. Consider clamping the available width to zero, e.g. `width: Math.min(implicitWidth, Math.max(parent.width - 120, 0))`.
</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.

Comment thread qt6/src/qml/DialogWindow.qml Outdated
Comment thread qt6/src/qml/DialogWindow.qml Outdated
Comment thread qt6/src/qml/DialogWindow.qml Outdated
Comment thread qt6/src/qml/DialogWindow.qml Outdated
Comment thread qt6/src/qml/DialogWindow.qml Outdated
@MyLeeJiEun MyLeeJiEun force-pushed the fork-from-master-0515-fix-issue-361279 branch from 7f5bc69 to 4a7b979 Compare May 16, 2026 05:50
mhduiy
mhduiy previously approved these changes May 16, 2026
@MyLeeJiEun MyLeeJiEun force-pushed the fork-from-master-0515-fix-issue-361279 branch 5 times, most recently from 2ca5dac to 4e16df3 Compare May 18, 2026 09:40
mhduiy
mhduiy previously approved these changes May 18, 2026
Replace plain title text with a centered D.Label in DialogTitleBar

Log: Center the dialog window title with downward offset

fix: 对话框标题替换为 D.Label 组件

将 DialogTitleBar 中的纯文本标题替换为 D.Label 组件

Log: 将对话框窗口标题居中并设置下移偏移
PMS: BUG-361279
@MyLeeJiEun MyLeeJiEun force-pushed the fork-from-master-0515-fix-issue-361279 branch from 4e16df3 to 1c06ed0 Compare May 18, 2026 10:03
@deepin-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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

@mhduiy mhduiy merged commit 08bed9b into linuxdeepin:master May 18, 2026
18 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants