Skip to content

fix(dde-license-dialog): distinguish disabled button visual state - #453

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

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

Conversation

@mhduiy

@mhduiy mhduiy commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

修复 PMS BUG-360973

问题

免责声明对话框中"确定"按钮的活动色状态有误:未勾选协议时(disabled),按钮仍显示高亮文本色(看起来可点击);勾选协议后(enabled-normal),背景透明度与 disabled 状态相同(均为 0.15),用户无法从视觉上区分按钮是否可用。

根因

dde-license-dialog/src/content.cpp 中自定义 LicenseDialogButton::initStyleOption() 存在两处缺陷:

  1. 背景透明度未区分 disabled 与 enabled-normalbackgroundOpacity 默认 0.15,enabled 分支仅在 sunken(0.25)/hover(0.2) 时覆盖,enabled-normal 回退到 0.15,与 disabled 完全相同。
  2. 高亮文本色未检查 enabled 状态m_highlighted=true 时无条件将 ButtonText 设为高亮色,disabled 的"确定"按钮仍显示高亮文本色。

修复

initStyleOption 中:

  • 为 disabled 状态设置更低背景透明度(0.05),与 enabled-normal(0.15) 区分
  • 仅在 State_Enabled 时应用高亮文本色,disabled 时使用 QPalette::DisabledButtonText

改动范围

仅修改 dde-license-dialog/src/content.cppinitStyleOption 方法,+9/-2 行,回归风险低。

PMS

https://pms.uniontech.com/bug-view-360973.html

Summary by Sourcery

Fix the disclaimer dialog confirmation button’s disabled-state appearance.

Bug Fixes:

  • Correct the disclaimer dialog’s confirmation button styling so disabled and enabled states are visually distinguishable.
  • Use the disabled button text color when the highlighted confirmation button is unavailable.

The OK button in the license disclaimer dialog uses a custom
LicenseDialogButton with a custom initStyleOption. Two issues made
disabled and enabled-normal states visually identical:

1. backgroundOpacity defaulted to 0.15 for both disabled and
   enabled-normal (only sunken/hover were overridden), so users
   could not tell whether the button was clickable from the background.
2. The highlighted text color was applied unconditionally when
   m_highlighted was true, ignoring State_Enabled, so the disabled
   OK button still showed the highlight text color.

Fix: set backgroundOpacity to 0.05 for disabled state, and only
apply the highlight text color when State_Enabled is set; use the
disabledButtonText color otherwise.

Log: yes
Bug: https://pms.uniontech.com/bug-view-360973.html
@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 LicenseDialogButton styling so disabled and enabled-normal states are visually distinguishable, and prevents disabled highlighted buttons from using the active highlight text color. The change is isolated to initStyleOption in dde-license-dialog/src/content.cpp.

Flow diagram for LicenseDialogButton state styling

flowchart TD
    A["initStyleOption"] --> B{"State_Enabled?"}
    B -->|Yes| C{"MouseOver or Sunken?"}
    C -->|Sunken| D["backgroundOpacity = 0.25"]
    C -->|MouseOver| E["backgroundOpacity = 0.2"]
    C -->|Normal| F["backgroundOpacity = 0.15"]
    B -->|No| G["backgroundOpacity = 0.05"]
    D --> H{"m_highlighted?"}
    E --> H
    F --> H
    G --> H
    H -->|Yes and enabled| I["ButtonText = highlight color"]
    H -->|Yes and disabled| J["ButtonText = Disabled ButtonText color"]
    H -->|No| K["Keep ButtonText color"]
Loading

File-Level Changes

Change Details Files
Differentiate disabled and enabled-normal button backgrounds through state-specific opacity values.
  • Keep enabled hover and pressed opacity behavior unchanged.
  • Set disabled button background opacity to 0.05, while enabled-normal remains 0.15.
dde-license-dialog/src/content.cpp
Apply highlighted text coloring only to enabled buttons and preserve the disabled palette text color otherwise.
  • Guard highlighted text color assignment with State_Enabled.
  • Use QPalette::Disabled ButtonText for highlighted disabled buttons.
dde-license-dialog/src/content.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


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 总体评分 100 分,大于 70 分通过阈值,代码质量符合要求。本次修改精准修复了 PMS BUG-360973 中免责声明对话框"确定"按钮 disabled 状态视觉不可区分的问题,改动范围小、回归风险低。

🔍 详细分析

1. 语法逻辑 ✅

评价: 优秀 ✅ 通过

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

建议: 代码语法正确,逻辑清晰,无语法错误或逻辑缺陷。initStyleOption 方法中新增的 else 分支和嵌套 if-else 结构正确处理了所有状态分支。


2. 代码质量 ✅

评价: 优秀 ✅ 通过

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

建议: 代码结构清晰,变更最小化,无重复代码。修改精准聚焦于问题根因,符合最小改动原则。


3. 代码性能 ✅

评价: 优秀 ✅ 通过

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

建议: 性能良好,资源使用合理,无性能瓶颈。新增的条件分支仅涉及简单的浮点数赋值和 QPalette 颜色读取,对 UI 渲染性能无可感知影响。


4. 代码安全 🔒

评价: 优秀 ✅ 通过

🔐 发现 0 个安全漏洞

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

建议: 存在0个安全漏洞,安全合规。漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个。本次修改仅涉及 UI 调色板操作,不涉及用户输入处理、网络通信、文件操作或权限管理,无安全风险。


💡 改进建议代码示例

// 当前修复代码已经合理,无需额外修改
// initStyleOption 方法中正确区分了 disabled 和 enabled 状态

qreal backgroundOpacity = 0.15;
if (option->state.testFlag(QStyle::State_Enabled)) {
    if (option->state.testFlag(QStyle::State_Sunken)) {
        backgroundOpacity = 0.25;
    } else if (option->state.testFlag(QStyle::State_MouseOver)) {
        backgroundOpacity = 0.2;
    }
} else {
    backgroundOpacity = 0.05;  // disabled 状态使用更低透明度
}

if (m_highlighted) {
    if (option->state.testFlag(QStyle::State_Enabled)) {
        QColor textColor = option->palette.highlight().color();
        option->palette.setColor(QPalette::ButtonText, textColor);
    } else {
        QColor textColor = option->palette.color(QPalette::Disabled, QPalette::ButtonText);
        option->palette.setColor(QPalette::ButtonText, textColor);
    }
}

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

@mhduiy

mhduiy commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

已经修复此问题:bb8b7a67e24fc3bf246ea8bf3d15cbd68053e0d8,关闭 此PR

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