Skip to content

fix: update tips color to white#495

Merged
deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
ut003640:master
Feb 5, 2026
Merged

fix: update tips color to white#495
deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
ut003640:master

Conversation

@ut003640
Copy link
Contributor

@ut003640 ut003640 commented Feb 5, 2026

update tips color to white

Log: update tips color to white
PMS: BUG-316751

Summary by Sourcery

Bug Fixes:

  • Change network item tooltip bright text color from black to white to restore proper contrast with its background

update tips color to white

Log: update tips color to white
PMS: BUG-316751
@sourcery-ai
Copy link

sourcery-ai bot commented Feb 5, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR changes the tooltip/text color used in the network module’s item tips from black to white to fix a UI bug.

File-Level Changes

Change Details Files
Update the network item tips text color to white using the widget palette.
  • Retrieve the item tips widget and its current palette.
  • Change the QPalette BrightText color from Qt::black to Qt::white.
  • Reapply the modified palette back to the item tips widget before returning it.
dss-network-plugin/networkmodule.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

@deepin-ci-robot
Copy link

deepin pr auto review

这段代码的修改是将提示文本的颜色从黑色(Qt::black)修改为白色(Qt::white)。以下是对这段代码的审查意见,涵盖语法逻辑、代码质量、性能和安全方面:

1. 语法逻辑

  • 审查结果:通过。
  • 解释:代码使用了Qt框架的标准API,QPalette::setColorsetPalette 的调用方式符合Qt文档规范。逻辑上,修改 itemTips 的调色板并应用回控件是正确的。

2. 代码质量

  • 审查结果:存在改进空间。
  • 解释
    • 硬编码颜色值:直接使用 Qt::white 属于硬编码。如果系统主题发生变化(例如切换到深色/浅色模式),或者应用程序需要支持动态换肤,这种写法会导致文本颜色无法自适应背景,造成视觉上的不协调(例如在浅色背景下显示白色文字会看不清)。
    • 建议:建议使用系统主题提供的标准颜色角色,或者从样式表/QSS中读取颜色,而不是在代码中强制指定颜色。如果必须指定颜色,应确保该颜色与背景色有足够的对比度。

3. 代码性能

  • 审查结果:良好。
  • 解释:这段代码仅在创建提示控件时执行一次,不涉及高频操作或复杂计算,对性能几乎没有影响。

4. 代码安全

  • 审查结果:良好。
  • 解释:此段代码仅涉及UI颜色设置,不涉及内存操作、用户输入处理或系统调用,不存在明显的安全风险(如缓冲区溢出或注入攻击)。

综合改进建议

虽然代码逻辑正确,但为了提高代码的可维护性和UI的适应性,建议采用以下方式之一进行优化:

方案一:使用系统默认角色(推荐)
如果 BrightText 角色本身就是为了适应背景设计的,通常不需要手动强制设置颜色,或者应该设置一个更通用的角色(如 QPalette::WindowTextQPalette::Text),让Qt根据当前主题自动处理颜色。如果确实需要高亮,请确认 BrightText 是否是最佳选择。

QWidget *NetworkModule::itemTipsWidget() const
{
    QWidget *itemTips = m_netStatus->createItemTips();
    // 尝试不强制设置颜色,或者使用更通用的角色
    // itemTips->setAutoFillBackground(true); // 如果需要背景填充
    return itemTips;
}

方案二:使用样式表(QSS)
如果UI需要高度定制,建议将颜色定义移到外部样式表文件中,而不是写死在C++代码里。

// 在C++中设置样式表
itemTips->setStyleSheet("color: white;"); 

或者在全局样式表中定义类名。

方案三:使用系统主题色(如果使用的是Dtk或类似UI框架)
如果项目深度依赖Deepin Tool Kit (Dtk)或其他UI框架,通常会有获取系统高亮色或文本色的API。

// 伪代码示例,具体API取决于使用的框架
QColor textColor = DGuiApplicationHelper::instance()->palette().color(QPalette::BrightText);
p.setColor(QPalette::BrightText, textColor);

总结
修改本身解决了当前的显示问题(从黑变白),但从长远维护来看,避免硬编码颜色值是更优的做法。如果背景是深色的,强制设为白色是可行的;但如果背景可能变化,请务必使用动态颜色方案。

Copy link

@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 reviewed your changes and they look great!


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.

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: caixr23, ut003640

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

@ut003640
Copy link
Contributor Author

ut003640 commented Feb 5, 2026

/forcemerge

@deepin-bot
Copy link
Contributor

deepin-bot bot commented Feb 5, 2026

This pr force merged! (status: unstable)

@deepin-bot deepin-bot bot merged commit 8274103 into linuxdeepin:master Feb 5, 2026
16 of 18 checks passed
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.

3 participants