Skip to content

fix: remove misleading warning color from delete buttons - #589

Closed
pengfeixx wants to merge 1 commit into
linuxdeepin:masterfrom
pengfeixx:agent/agent/ef48acc8dc8e
Closed

pengfeixx wants to merge 1 commit into
linuxdeepin:masterfrom
pengfeixx:agent/agent/ef48acc8dc8e

Conversation

@pengfeixx

@pengfeixx pengfeixx commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Root Cause Analysis

TermCommandLinkButton constructor unconditionally set ButtonText to TextWarning (red), causing all delete buttons using this widget to display red text. This made delete buttons look like error/warning indicators rather than normal action buttons. The redundant TextWarning reassignment in ServerConfigOptDlg::handleThemeTypeChanged() perpetuated the red color across theme switches.

Evidence: src/views/termcommandlinkbutton.cpp:25 sets palette.setColor(DPalette::ButtonText, palette.color(DPalette::TextWarning)); standalone demo confirmed TextWarning resolves to rgb(255,87,54) and ButtonText turns red after assignment, while removing it keeps ButtonText at rgb(0,0,0).

Fix

Removed the TextWarning color assignment from TermCommandLinkButton constructor (including the #include <DPaletteHelper> that became unused) and the redundant TextWarning reassignment in handleThemeTypeChanged(). Buttons now use the theme default ButtonText color. No functional logic changed.

Change Safety Assessment

Code Safety

  • Risk Level: Low
  • Target lines are not products of any historical bug fix — TextWarning assignment existed since file creation (commit 6b3bef59, 2020-05-22, structural refactor) and was carried through cppcheck cleanup (commit db11fe027, 2021-02-22). This change does not revert any historical fix.
  • Both callers (customcommandoptdlg.cpp:172, serverconfigoptdlg.cpp:58) only use the clicked signal and do not depend on text color.

Business Impact Scope

  • Custom command edit dialog: delete button text color changes from red to theme default
  • Remote server config dialog: delete button text color changes from red to theme default
  • Theme switching no longer re-applies red color to delete buttons

Verification Suggestion

Verify delete button text color in custom command edit dialog and remote server config dialog under both light and dark themes. Confirm theme switching does not restore red color.


根因分析

TermCommandLinkButton 构造函数无条件将 ButtonText 设为 TextWarning(红色),导致所有使用该控件的删除按钮文字呈红色,易被误读为错误/警示。ServerConfigOptDlg::handleThemeTypeChanged() 中冗余的 TextWarning 重复赋值在主题切换时维持了红色。

证据:src/views/termcommandlinkbutton.cpp:25 执行 palette.setColor(DPalette::ButtonText, palette.color(DPalette::TextWarning));独立 demo 确认 TextWarning 解析为 rgb(255,87,54),赋值后 ButtonText 变红;移除后 ButtonText 保持 rgb(0,0,0)。

修复方案

移除 TermCommandLinkButton 构造函数中的 TextWarning 颜色赋值(含不再使用的 #include <DPaletteHelper>),以及 handleThemeTypeChanged() 中冗余的 TextWarning 重复赋值。按钮恢复主题默认 ButtonText 颜色,不改变功能逻辑。

改动安全评估

代码安全评估

  • 风险等级: 低风险
  • 目标行非历史 bug 修复产物——TextWarning 赋值自文件创建时即存在(commit 6b3bef59,2020-05-22,结构调整),cppcheck 清理时保留(commit db11fe027,2021-02-22)。本次改动不撤销任何已有修复。
  • 两处调用方(customcommandoptdlg.cpp:172、serverconfigoptdlg.cpp:58)仅使用 clicked 信号,不依赖文字颜色。

业务影响范围

  • 自定义命令编辑窗口:删除按钮文字颜色由红色变为主题默认色
  • 远程服务器配置对话框:删除按钮文字颜色由红色变为主题默认色
  • 主题切换不再恢复删除按钮红色文字

验证建议

在浅色和深色主题下验证自定义命令编辑窗口和远程服务器配置对话框中删除按钮的文字颜色,确认主题切换后颜色不恢复为红色。

PMS: BUG-378945

Summary by Sourcery

Use the theme’s default button text color for delete buttons instead of presenting them as warning indicators.

Bug Fixes:

  • Restore delete button text to the theme default instead of the misleading warning color in custom command and remote server configuration dialogs.
  • Prevent theme changes from reapplying the warning color to delete buttons.

1. Root cause: TermCommandLinkButton constructor unconditionally set
   ButtonText to TextWarning (red), causing delete buttons to appear
   as error/warning indicators rather than normal action buttons
2. Fix: remove TextWarning color assignment from constructor and
   redundant reassignment in handleThemeTypeChanged()
3. Impact: delete buttons in custom command and remote server dialogs
   now use theme default ButtonText color, no functional change

Log: fix delete button text color from red to theme default

Influence:
1. Test delete button color in custom command edit dialog
2. Test delete button color in remote server config dialog
3. Test theme switching does not restore red color

fix: 移除删除按钮误导性的警告色

1. 根因:TermCommandLinkButton 构造函数无条件将 ButtonText 设为
   TextWarning(红色),导致删除按钮被误读为错误/警示
2. 方案:移除构造函数中的 TextWarning 颜色赋值,以及
   handleThemeTypeChanged 中冗余的重复赋值
3. 影响:自定义命令和远程服务器对话框中的删除按钮恢复主题
   默认文字颜色,不改变功能逻辑

Log: 修复删除按钮文字颜色为红色的问题

Influence:
1. 测试自定义命令编辑窗口中删除按钮文字颜色
2. 测试远程服务器配置对话框中删除按钮文字颜色
3. 测试主题切换后删除按钮颜色不恢复为红色

PMS: BUG-378945
@pengfeixx
pengfeixx marked this pull request as draft November 6, 2026 21:44
@sourcery-ai

sourcery-ai Bot commented Nov 6, 2026

Copy link
Copy Markdown

Reviewer's Guide

UI

Remove the warning-color palette overrides so delete buttons use the theme’s default text color, including after theme changes.

  • src/remotemanage/serverconfigoptdlg.cpp L351 (removed lines)
  • src/views/termcommandlinkbutton.cpp L9 (removed lines), L21 (removed lines)

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 ✨

@pengfeixx pengfeixx closed this Nov 11, 2026
@pengfeixx pengfeixx reopened this Nov 11, 2026
@pengfeixx pengfeixx closed this Nov 11, 2026
@pengfeixx
pengfeixx deleted the agent/agent/ef48acc8dc8e branch November 11, 2026 07:48
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: pengfeixx

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

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