Skip to content

fix: set transientParent for avatar settings dialog - #3516

Closed
mhduiy wants to merge 1 commit into
linuxdeepin:masterfrom
mhduiy:agent/pms-bug-bot/baa729e815bc
Closed

mhduiy wants to merge 1 commit into
linuxdeepin:masterfrom
mhduiy:agent/pms-bug-bot/baa729e815bc

Conversation

@mhduiy

@mhduiy mhduiy commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Root Cause

AvatarSettingsDialog in AccountSettings.qml uses Qt.WindowModal modality, but the dilogLoader.onLoaded callback never set transientParent before calling .show(). Without transientParent, the window manager cannot locate the parent window to apply modal dimming, so the control center main window is not grayed out when the avatar settings dialog opens.

Key evidence: The same repo's UserExperienceProgramPage.qml:43-49 already has the correct pattern — setting transientParent = Window.window before .show(), and that dialog dims correctly.

Fix

Add transientParent = Window.window assignment before .show() in the dilogLoader.onLoaded callback, matching the verified pattern in UserExperienceProgramPage.qml. Uses Window.window (deterministic reference) instead of Qt.application.activeWindow to avoid the layering issue seen in bug-352609.

Change Safety Assessment

  • Risk level: Low
  • Scope: Only affects avatar settings dialog open behavior (4 lines added, no existing logic modified or deleted)
  • Null guard: if (parentWin) ensures graceful fallback to original .show() behavior when Window.window is null
  • No external callers: dilogLoader is local to AccountSettings.qml, no cross-file references
  • Related PMS bugs (375217, 370569, 361555): All about account group list focus/navigation, unrelated to this fix

Business Impact

  • Affected module: Account settings → Avatar settings dialog
  • User scenario: When user clicks avatar in account settings, the control center main window will now be properly dimmed (modal overlay)
  • Regression risk: Minimal — same pattern already verified in UserExperienceProgramPage.qml

Verification

  1. Open account settings, click avatar to open settings dialog — verify main window is dimmed
  2. Close the dialog — verify main window returns to normal
  3. Verify other account settings operations work as before

根因分析

AccountSettings.qml 中的 AvatarSettingsDialog 使用 Qt.WindowModal 模态,但 dilogLoader.onLoaded 回调在调用 .show() 前未设置 transientParent。缺少 transientParent 时,窗口管理器无法定位父窗口进行模态置灰,导致打开头像设置对话框时控制中心主窗口不置灰。

关键证据:同仓库 UserExperienceProgramPage.qml:43-49 已有正确模式——在 .show() 前设置 transientParent = Window.window,该对话框置灰正常。

修复方案

在 dilogLoader.onLoaded 回调中于 .show() 前添加 transientParent = Window.window 赋值,参照 UserExperienceProgramPage.qml 已验证模式。使用 Window.window(确定性引用)而非 Qt.application.activeWindow,避免 bug-352609 的层级问题。

改动安全评估

  • 风险等级:低
  • 影响范围:仅影响头像设置对话框打开行为(新增 4 行,未修改或删除已有逻辑)
  • 空值守卫:if (parentWin) 确保 Window.window 为 null 时退化为原始 .show() 行为
  • 无外部调用者:dilogLoader 为 AccountSettings.qml 内部使用,无跨文件引用
  • 关联 PMS bug(375217、370569、361555):均为账户组列表焦点/导航问题,与本次修复无关

业务影响范围

  • 受影响模块:账户设置 → 头像设置对话框
  • 用户场景:用户在账户设置中点击头像打开设置对话框时,控制中心主窗口将被正确置灰(模态遮罩)
  • 回归风险:极低——UserExperienceProgramPage.qml 已有相同模式验证

验证建议

  1. 打开账户设置,点击头像打开设置对话框——验证主窗口被置灰
  2. 关闭对话框——验证主窗口恢复正常
  3. 验证账户设置其他操作无回归

PMS: BUG-305139

Summary by Sourcery

Bug Fixes:

  • Ensure the avatar settings dialog correctly dims the control center main window when opened as a modal dialog.

1. Root cause: AvatarSettingsDialog uses Qt.WindowModal modality but
   dilogLoader.onLoaded never set transientParent, so the window
   manager cannot locate the parent window to dim
2. Fix: assign transientParent = Window.window before show(), matching
   the verified pattern in UserExperienceProgramPage.qml
3. Impact: only affects avatar settings dialog open behavior, no
   change to other dialogs or existing logic

Log: Fix avatar settings dialog not dimming the control center window

Influence:
1. Test opening avatar settings dialog and verify parent window is dimmed
2. Test closing the dialog and verify parent window returns to normal
3. Verify no regression on other account settings operations

fix: 修复头像设置对话框未置灰父窗口的问题

1. 根因:AvatarSettingsDialog 使用 Qt.WindowModal 模态但 dilogLoader
   的 onLoaded 回调未设置 transientParent,窗口管理器无法定位父窗口
   进行置灰
2. 方案:在 show() 前设置 transientParent = Window.window,参照
   UserExperienceProgramPage.qml 已验证模式
3. 影响:仅影响头像设置对话框打开行为,不影响其他对话框或已有逻辑

Log: 修复头像设置对话框未置灰控制中心主窗口的问题

Influence:
1. 测试打开头像设置对话框,验证父窗口被置灰
2. 测试关闭对话框,验证父窗口恢复正常
3. 验证账户设置其他操作无回归

PMS: BUG-305139

@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 @mhduiy, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 1 minute by commenting @sourcery-ai review. Upgrade to get a review now.

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: mhduiy

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 14, 2026

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

Reviewer's Guide

Updates the avatar settings dialog loading path to set its transient parent before showing, enabling correct window-modal dimming while preserving a null-safe fallback.

Sequence diagram for modal avatar settings dialog loading

sequenceDiagram
    participant User
    participant AccountSettings
    participant AvatarSettingsDialog
    participant MainWindow

    User->>AccountSettings: Click avatar
    AccountSettings->>AvatarSettingsDialog: onLoaded()
    AccountSettings->>MainWindow: Window.window
    alt parentWin exists
        AccountSettings->>AvatarSettingsDialog: transientParent = parentWin
    end
    AccountSettings->>AvatarSettingsDialog: show()
    AvatarSettingsDialog-->>MainWindow: Apply WindowModal dimming
Loading

File-Level Changes

Change Details Files
Associate the avatar settings dialog with the current application window before showing it.
  • Capture the containing window via Window.window.
  • Set transientParent when the window reference is available.
  • Retain the existing show behavior when no parent window is available.
src/plugin-accounts/qml/AccountSettings.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

🤖 AI 代码审查报告

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

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 总体评分 100 分,大于 70 分通过阈值,代码质量符合要求。本次变更为修复头像设置对话框的模态置灰问题,在 dilogLoader.onLoaded 回调中于 show() 前添加 transientParent = Window.window 赋值,参照 UserExperienceProgramPage.qml 已验证模式,变更范围小、风险低、有空值守卫,代码实现与 commit 目的完全一致。

🔍 详细分析

1. 语法逻辑 ✅

评价: 优秀 ✅ 通过

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

建议: 代码语法正确,逻辑清晰。var parentWin = Window.window 获取窗口引用,if (parentWin) 空值守卫确保 Window.window 为 null 时退化为原始 show() 行为,边界处理完善。


2. 代码质量 ✅

评价: 优秀 ✅ 通过

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

建议: 代码结构清晰,变更最小化(仅新增 4 行),未修改或删除已有逻辑。变量命名 parentWin 清晰达意,遵循同仓库 UserExperienceProgramPage.qml 已验证模式,无重复代码,无残留调试代码。


3. 代码性能 ✅

评价: 优秀 ✅ 通过

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

建议: 性能良好,仅设置 transientParent 属性后调用 show(),无不必要的计算、循环或系统调用,资源使用合理。


4. 代码安全 🔒

评价: 优秀 ✅ 通过

🔐 发现 0 个安全漏洞

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

建议: 存在0个安全漏洞。代码不涉及用户输入处理、网络操作、文件操作或命令执行,无硬编码密钥或敏感信息泄露风险。


💡 改进建议代码示例

// 本次变更已符合最佳实践,无需额外改进
// onLoaded: function () {
//     var parentWin = Window.window
//     if (parentWin) {
//         dilogLoader.item.transientParent = parentWin
//     }
//     dilogLoader.item.show()
// }

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

@mhduiy

mhduiy commented Sep 22, 2026

Copy link
Copy Markdown
Contributor Author

修改会引入其他问题,不适合这样修改,暂时关闭

@mhduiy mhduiy closed this Sep 22, 2026
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