Skip to content

fix: improve license dialog window behavior - #462

Open
wjyrich wants to merge 1 commit into
linuxdeepin:masterfrom
wjyrich:fix-bug-380347
Open

wjyrich wants to merge 1 commit into
linuxdeepin:masterfrom
wjyrich:fix-bug-380347

Conversation

@wjyrich

@wjyrich wjyrich commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor
  1. Change window flags from WindowStaysOnTopHint/Tool to Dialog with close button hint
  2. Add --parent-window option to set transient parent via X11 window ID
  3. Skip manual centering when a parent window is set, letting the WM position the dialog
  4. Ensure the close button is always visible and connected to close the window
  5. Exit the application after the window closes in closeEvent to avoid lingering processes with a foreign parent
  6. Dim the background opacity of disabled buttons and skip highlight text color when disabled
  7. Add spacing and titlebar margins for proper icon and close button layout
  8. Add unit tests for consent gating, disabled button rendering, dialog flags, and close behavior

Log: Fixed license dialog staying on top and added parent window support with proper close button behavior

Influence:

  1. Verify the dialog no longer stays above other applications on both X11 and Wayland
  2. Test the --parent-window option with a valid X11 window ID and confirm the dialog is transient to the parent
  3. Confirm the window manager centers the dialog relative to the parent when a parent is provided
  4. Verify manual centering still works when no parent window is specified
  5. Test the close button closes the window and exits the application in all launch modes (with/without titlebar icon, with/without hide-bottom)
  6. Verify the close button is always visible and functional
  7. Test that the accept button remains disabled until the consent checkbox is checked
  8. Verify disabled buttons have a dimmed background and no highlight text color
  9. Run the unit tests to confirm all new test cases pass

fix: 优化许可对话框窗口行为

  1. 将窗口标志从 WindowStaysOnTopHint/Tool 改为带关闭按钮提示的 Dialog
  2. 添加 --parent-window 选项,通过 X11 窗口 ID 设置临时父窗口
  3. 设置父窗口时跳过手动居中,由窗口管理器定位对话框
  4. 确保关闭按钮始终可见并连接到关闭窗口操作
  5. 在 closeEvent 中关闭窗口后退出应用,避免存在外部父窗口时进程残留
  6. 降低禁用按钮的背景透明度,禁用时跳过高亮文字颜色
  7. 添加间距和标题栏边距以正确布局图标和关闭按钮
  8. 添加针对同意勾选控制、禁用按钮渲染、对话框标志和关闭行为的单元测试

Log: 修复许可对话框置顶问题,新增父窗口支持并完善关闭按钮行为

Influence:

  1. 验证对话框在 X11 和 Wayland 下不再始终置顶于其他应用之上
  2. 使用有效的 X11 窗口 ID 测试 --parent-window 选项,确认对话框为父窗口 的临时窗口
  3. 确认提供父窗口时窗口管理器相对父窗口居中对话框
  4. 验证未指定父窗口时手动居中仍然有效
  5. 在所有启动模式下测试关闭按钮关闭窗口并退出应用(有无标题栏图标、有无 隐藏底部)
  6. 验证关闭按钮始终可见且可用
  7. 测试同意勾选框未勾选时接受按钮保持禁用
  8. 验证禁用按钮背景变暗且无高亮文字颜色
  9. 运行单元测试确认所有新增测试用例通过

PMS: BUG-380347

Summary by Sourcery

Improve license dialog window behavior across launch modes and display systems.

New Features:

  • Add support for assigning the license dialog a transient X11 parent through the --parent-window option.

Bug Fixes:

  • Prevent the license dialog from staying above other applications and ensure closing it reliably terminates the application.
  • Ensure disabled buttons render with dimmed backgrounds and without highlighted text.

Enhancements:

  • Use standard dialog behavior with a consistently visible close button, improved titlebar spacing, and window-manager positioning for transient dialogs.

Tests:

  • Add coverage for consent-gated acceptance, disabled button rendering, dialog window flags, focus behavior, and close handling.

1. Change window flags from WindowStaysOnTopHint/Tool to Dialog with
close button hint
2. Add --parent-window option to set transient parent via X11 window ID
3. Skip manual centering when a parent window is set, letting the WM
position the dialog
4. Ensure the close button is always visible and connected to close
the window
5. Exit the application after the window closes in closeEvent to avoid
lingering processes with a foreign parent
6. Dim the background opacity of disabled buttons and skip highlight
text color when disabled
7. Add spacing and titlebar margins for proper icon and close button
layout
8. Add unit tests for consent gating, disabled button rendering, dialog
flags, and close behavior

Log: Fixed license dialog staying on top and added parent window support
with proper close button behavior

Influence:
1. Verify the dialog no longer stays above other applications on both
X11 and Wayland
2. Test the --parent-window option with a valid X11 window ID and
confirm the dialog is transient to the parent
3. Confirm the window manager centers the dialog relative to the parent
when a parent is provided
4. Verify manual centering still works when no parent window is
specified
5. Test the close button closes the window and exits the application in
all launch modes (with/without titlebar icon, with/without hide-bottom)
6. Verify the close button is always visible and functional
7. Test that the accept button remains disabled until the consent
checkbox is checked
8. Verify disabled buttons have a dimmed background and no highlight
text color
9. Run the unit tests to confirm all new test cases pass

fix: 优化许可对话框窗口行为

1. 将窗口标志从 WindowStaysOnTopHint/Tool 改为带关闭按钮提示的 Dialog
2. 添加 --parent-window 选项,通过 X11 窗口 ID 设置临时父窗口
3. 设置父窗口时跳过手动居中,由窗口管理器定位对话框
4. 确保关闭按钮始终可见并连接到关闭窗口操作
5. 在 closeEvent 中关闭窗口后退出应用,避免存在外部父窗口时进程残留
6. 降低禁用按钮的背景透明度,禁用时跳过高亮文字颜色
7. 添加间距和标题栏边距以正确布局图标和关闭按钮
8. 添加针对同意勾选控制、禁用按钮渲染、对话框标志和关闭行为的单元测试

Log: 修复许可对话框置顶问题,新增父窗口支持并完善关闭按钮行为

Influence:
1. 验证对话框在 X11 和 Wayland 下不再始终置顶于其他应用之上
2. 使用有效的 X11 窗口 ID 测试 --parent-window 选项,确认对话框为父窗口
的临时窗口
3. 确认提供父窗口时窗口管理器相对父窗口居中对话框
4. 验证未指定父窗口时手动居中仍然有效
5. 在所有启动模式下测试关闭按钮关闭窗口并退出应用(有无标题栏图标、有无
隐藏底部)
6. 验证关闭按钮始终可见且可用
7. 测试同意勾选框未勾选时接受按钮保持禁用
8. 验证禁用按钮背景变暗且无高亮文字颜色
9. 运行单元测试确认所有新增测试用例通过

PMS: BUG-380347
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: wjyrich

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

@wjyrich

wjyrich commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

@sourcery-ai

sourcery-ai Bot commented Oct 28, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR converts the license window into a standard closeable dialog with optional X11 transient-parent support, delegates parented positioning to the window manager, ensures reliable close-and-exit behavior, refines titlebar and disabled-button styling, and adds regression tests for the primary interaction and window-state changes.

Sequence diagram for license dialog startup and closing

sequenceDiagram
    participant User
    participant Application
    participant MainWindow
    participant WindowManager

    User->>Application: start with --parent-window
    Application->>Application: QWindow::fromWinId
    Application->>MainWindow: setTransientParent
    Application->>WindowManager: show transient dialog
    WindowManager-->>MainWindow: position relative to parent
    MainWindow-->>User: display closeable dialog
    User->>MainWindow: click close button
    MainWindow->>MainWindow: closeEvent
    MainWindow->>Application: qApp->exit(0)
Loading

Flow diagram for license consent gating

flowchart TD
    Start([Dialog displayed]) --> Consent{Consent checkbox checked?}
    Consent -->|No| Disabled[Accept button disabled]
    Consent -->|Yes| Enabled[Accept button enabled]
    Disabled --> Consent
    Enabled --> Accept[User accepts license]
Loading

File-Level Changes

Change Details Files
Reworked the dialog window lifecycle and positioning to behave as a normal transient dialog instead of an always-on-top utility window.
  • Replaced platform-specific always-on-top/tool flags with dialog and close-button hints.
  • Added optional hexadecimal/decimal X11 parent-window parsing and transient-parent assignment.
  • Skipped manual centering for parented dialogs while retaining it for standalone launches.
  • Added deferred focus activation and application exit handling after accepted close events.
dde-license-dialog/src/main.cpp
dde-license-dialog/src/mainwindow.cpp
dde-license-dialog/src/mainwindow.h
Made the title bar and close control consistently visible and correctly laid out across launch configurations.
  • Connected the close button directly to window closing.
  • Enabled the close button independently of titlebar icon and bottom-content settings.
  • Added titlebar margins, content spacing, and a default titlebar icon.
  • Synchronized the native window title with the localized dialog title.
dde-license-dialog/src/mainwindow.cpp
Adjusted disabled-button styling to distinguish unavailable actions without applying active-state highlighting.
  • Reduced disabled button background opacity.
  • Applied highlight text color only while the button is enabled.
dde-license-dialog/src/content.cpp
Added regression coverage for consent gating, rendering, dialog flags, focus, and close behavior.
  • Verified acceptance remains disabled until consent is checked.
  • Compared rendered enabled and disabled button appearance.
  • Checked dialog flags, close-button visibility, and absence of always-on-top behavior.
  • Verified initial focus state and that the close button hides the window.
dde-license-dialog/tests/ut_content.cpp
dde-license-dialog/tests/ut_mainwindow.cpp

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

deepin pr auto review

🤖 AI 代码审查报告

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

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 本次提交旨在改进 DDE 许可证对话框的窗口行为,包含窗口标志简化、父窗口嵌入支持、关闭按钮行为统一化和禁用态视觉反馈。四维度分析均未发现问题,代码逻辑正确、结构清晰、性能合理、无安全漏洞。新增单元测试覆盖了关键变更点。

🔍 详细分析

1. 语法逻辑 ✅

评价: 语法正确,逻辑清晰 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: []


2. 代码质量 ✅

评价: 代码结构清晰,注释完整 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: []


3. 代码性能 ✅

评价: 性能良好,资源使用合理 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: []


4. 代码安全 🔒

评价: 存在0个安全漏洞 ✅ 通过

🔐 发现 0 个安全漏洞

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

建议: []


💡 改进建议代码示例

本次变更代码质量良好,无需修复。以下为可选的改进建议示例(非必须): // content.cpp 中可考虑将透明度魔法数字提取为命名常量 static constexpr qreal kEnabledOpacity = 0.15; static constexpr qreal kDisabledOpacity = 0.06; static constexpr qreal kSunkenOpacity = 0.25; static constexpr qreal kHoverOpacity = 0.20;

本报告由 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.

2 participants