Skip to content

fix: 调整快捷面板图标和文字颜色透明度及hover效果 - #509

Open
mhduiy wants to merge 1 commit into
masterfrom
fix/quick-panel-color-opacity-314503
Open

mhduiy wants to merge 1 commit into
masterfrom
fix/quick-panel-color-opacity-314503

Conversation

@mhduiy

@mhduiy mhduiy commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

log: In light mode, icon and text colours are #000000 with 70% opacity; in dark mode, icon and text colours are #ffffff with 70% opacity; on hover, icon and text colours are 100% opacity. Furthermore, the text colour of the titles in the secondary panel does not need to be adjusted; only the colours of the icons and text in the list need to be adjusted.

pms: bug-314503

修复内容

快捷面板中图标和文字颜色当前使用纯色全不透明度渲染,未遵循系统颜色规范。本次修改按设计规范调整:

  • 正常态:浅色模式 #000000 70% 透明度(alpha=178),深色模式 #ffffff 70% 透明度
  • hover 态:提升至 100% 透明度(alpha=255)

改动详情(14 文件,+240/-13)

QuickButton(bluetooth、eye-comfort-mode、wirelesscasting)

  • 添加 m_parentHover 成员和 setParentHover() 方法
  • initStyleOptiontextColor.setAlphaF(1)setAlphaF(m_parentHover ? 1.0 : 0.7)
  • hover 背景色判断增加 || m_parentHover 条件

CommonIconButton

  • 默认颜色从 Qt::black/Qt::white 改为 QColor(0,0,0,178)/QColor(255,255,255,178)
  • 添加 m_parentHover 成员和 setParentHover() 方法
  • updatePalette() 中当 m_hover || m_parentHover 时设置 alpha 为 255
  • event() 中 Enter/Leave 时调用 updatePalette() 而非仅 update()

QuickPanelWidget(bluetooth、eye-comfort-mode、media、wirelesscasting)

  • 实现 enterEvent()/leaveEvent() 传播 hover 到子按钮
  • 添加 updateTextColor() 设置 70%/100% 透明度

SignalQuickPanel

  • 添加 hover 传播和 updateTextColor()
  • setIcon 中颜色改为带透明度

JumpSettingButton

  • setIcon 颜色改为带透明度
  • event() 中传播 hover 到图标
  • paintEvent 非 hover 态添加 textColor.setAlphaF(0.7)

PluginItemDelegate

  • 非选中项添加 textColor.setAlphaF(0.7)

参考

Summary by Sourcery

Update quick-panel icon and list text rendering to use theme-aware transparency and consistent hover emphasis.

Bug Fixes:

  • Align quick-panel icon and list text colors with the system color specification by applying 70% opacity normally and full opacity on hover in both light and dark themes.

Enhancements:

  • Propagate panel hover state to child icons and controls for consistent hover feedback across quick-panel components.
  • Preserve secondary-panel title colors while applying the updated opacity behavior to relevant list icons and text.

In light mode, icon and text colours are #000000 with 70% opacity;
in dark mode, icon and text colours are #ffffff with 70% opacity;
on hover, icon and text colours are 100% opacity.

Changes:
- QuickButton (bluetooth, eye-comfort-mode, wirelesscasting): add
  m_parentHover member and setParentHover() method; change
  textColor.setAlphaF(1) to setAlphaF(m_parentHover ? 1.0 : 0.7);
  add m_parentHover to hover background condition
- CommonIconButton: default colors changed from Qt::black/Qt::white
  to QColor(0,0,0,178)/QColor(255,255,255,178) (178≈70%×255); add
  m_parentHover and setParentHover(); updatePalette sets alpha 255
  on hover; event() calls updatePalette() instead of update()
- QuickPanelWidget (bluetooth, eye-comfort-mode, media, wirelesscasting):
  add enterEvent/leaveEvent to propagate hover to child buttons;
  add updateTextColor() to set 70%/100% alpha on labels
- SignalQuickPanel: add hover propagation and updateTextColor()
- JumpSettingButton: use 70% alpha colors; propagate hover to icon;
  add textColor.setAlphaF(0.7) in non-hover paintEvent
- PluginItemDelegate: add textColor.setAlphaF(0.7) for non-selected items

pms: bug-314503

Log: 调整快捷面板图标和文字颜色透明度,正常态70%,hover态100%
@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

The PR standardizes quick-panel icon and list-text rendering to 70% opacity in light/dark themes, restores full opacity during hover, and propagates parent-panel hover state to child controls without changing secondary-panel title text behavior.

Sequence diagram for quick-panel hover opacity propagation

sequenceDiagram
    participant User
    participant QuickPanelWidget
    participant CommonIconButton
    participant Labels

    User->>QuickPanelWidget: enterEvent(event)
    QuickPanelWidget->>CommonIconButton: setParentHover(true)
    CommonIconButton->>CommonIconButton: updatePalette()
    QuickPanelWidget->>Labels: updateTextColor(true)
    Note over CommonIconButton,Labels: Icons and list text use 100% opacity
    User->>QuickPanelWidget: leaveEvent(event)
    QuickPanelWidget->>CommonIconButton: setParentHover(false)
    CommonIconButton->>CommonIconButton: updatePalette()
    QuickPanelWidget->>Labels: updateTextColor(false)
    Note over CommonIconButton,Labels: Icons and list text use 70% opacity
Loading

Flow diagram for theme-aware quick-panel colors

flowchart LR
    Theme[DGuiApplicationHelper themeType] --> Light[Light theme: black at 70% alpha]
    Theme --> Dark[Dark theme: white at 70% alpha]
    Light --> Normal[Normal state]
    Dark --> Normal
    Hover[Parent or control hover] --> Full[Set alpha to 100%]
    Normal --> Full
Loading

File-Level Changes

Change Details Files
Apply theme-aware 70% default and 100% hover opacity to quick-panel icons and list text.
  • Use alpha 178 black/white icon colors for light/dark themes.
  • Raise icon and text alpha on direct or parent-widget hover.
  • Propagate panel enter/leave events to child icon buttons and labels.
  • Refresh palettes immediately on icon hover transitions.
plugins/dde-dock/common/commoniconbutton.cpp
plugins/dde-dock/common/commoniconbutton.h
plugins/dde-dock/common/singlequickpanel.cpp
plugins/dde-dock/common/singlequickpanel.h
plugins/dde-dock/bluetooth/quickpanelwidget.cpp
plugins/dde-dock/bluetooth/quickpanelwidget.h
plugins/dde-dock/eye-comfort-mode/quickpanelwidget.cpp
plugins/dde-dock/eye-comfort-mode/quickpanelwidget.h
plugins/dde-dock/media/quickpanelwidget.cpp
plugins/dde-dock/media/quickpanelwidget.h
plugins/dde-network-display-ui/plugins/dock-wirelesscasting-plugin/src/quickpanelwidget.cpp
plugins/dde-network-display-ui/plugins/dock-wirelesscasting-plugin/src/quickpanelwidget.h
Update standalone quick-setting and plugin-list rendering to use reduced-opacity text and icons in the normal state.
  • Pass semi-transparent theme colors to jump-setting and signal/media icons.
  • Apply 70% alpha to non-hover jump-setting text and non-selected plugin items.
plugins/dde-dock/common/jumpsettingbutton.cpp
plugins/dde-dock/common/pluginitemdelegate.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 found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="plugins/dde-dock/common/commoniconbutton.cpp" line_range="20-22" />
<code_context>
     , m_hover(false)
+    , m_parentHover(false)
     , m_state(Default)
-    , m_lightThemeColor(Qt::black)
-    , m_darkThemeColor(Qt::white)
+    , m_lightThemeColor(QColor(0, 0, 0, 178))
+    , m_darkThemeColor(QColor(255, 255, 255, 178))
     , m_activeState(false)
     , m_hoverEnable(true)
</code_context>
<issue_to_address>
**issue (broader_impact):** Changing the default `m_lightThemeColor` and `m_darkThemeColor` to 70% alpha does not affect buttons initialized through the string overload of `setIcon`, because that overload ends with `update()` rather than `updatePalette()`. Those callers retain the inherited opaque `WindowText` palette and do not receive the new normal-state opacity.

**Triggers:** When a `CommonIconButton` is configured with `setIcon(const QString &, const QString &, const QString &)` and is not later updated through a path that calls `updatePalette()`.

**Suggested fix:** Call `updatePalette()` from the string overload after selecting the icon.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment on lines -20 to 22
, m_lightThemeColor(Qt::black)
, m_darkThemeColor(Qt::white)
, m_lightThemeColor(QColor(0, 0, 0, 178))
, m_darkThemeColor(QColor(255, 255, 255, 178))
, m_activeState(false)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (broader_impact): Changing the default m_lightThemeColor and m_darkThemeColor to 70% alpha does not affect buttons initialized through the string overload of setIcon, because that overload ends with update() rather than updatePalette(). Those callers retain the inherited opaque WindowText palette and do not receive the new normal-state opacity.

Triggers: When a CommonIconButton is configured with setIcon(const QString &, const QString &, const QString &) and is not later updated through a path that calls updatePalette().

Suggested fix: Call updatePalette() from the string overload after selecting the icon.

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

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

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 总体评分 94 分,大于 70 分通过阈值。本次变更调整快捷面板图标和文字颜色透明度以符合设计规范(正常态70%透明度,hover态100%透明度),代码逻辑正确,无安全漏洞。主要不足为跨插件代码重复及缺少设计规范注释。

🔍 详细分析

1. 语法逻辑 ✅

评价: 优秀 ✅ 通过

潜在问题:

  1. plugins/dde-dock/media/quickpanelwidget.cpp:140 - updateTextColor()方法仅更新m_titleLab,未更新m_artistLab,可能导致hover态下艺术家名称透明度不一致

建议: 确认media组件中m_artistLab是否需要同步调整透明度。如需调整,在updateTextColor()中添加对m_artistLab的palette设置;如不需调整,建议添加注释说明原因。


2. 代码质量 ✅

评价: 良好 ✅ 通过

潜在问题:

  1. plugins/dde-dock/bluetooth/quickpanelwidget.cpp:189 - enterEvent()/leaveEvent()/updateTextColor()与eye-comfort-mode和wirelesscasting中实现几乎完全相同,存在跨插件代码重复
  2. plugins/dde-dock/bluetooth/quickpanelwidget.cpp:30 - setParentHover()方法在bluetooth、eye-comfort-mode、wirelesscasting三个插件中重复定义
  3. plugins/dde-dock/common/commoniconbutton.cpp:120 - setParentHover()和updateTextColor()等新增方法缺少注释说明设计规范(70%/100%透明度规则)

建议: 1.考虑将enterEvent()/leaveEvent()/updateTextColor()提取到公共基类或工具类中,减少跨插件代码重复
2.在updateTextColor()和setParentHover()方法处添加注释,说明'按设计规范:正常态70%透明度(alpha=178),hover态100%透明度(alpha=255)',便于后续维护理解设计意图


3. 代码性能 ✅

评价: 优秀 ✅ 通过

潜在问题:

  1. plugins/dde-dock/common/commoniconbutton.cpp:175 - event()中将update()改为updatePalette(),每次Enter/Leave触发完整调色板重计算,对UI事件影响可忽略

建议: 当前性能表现可接受。如需进一步优化,可在updatePalette()中添加对m_hover和m_parentHover状态变化的判断,仅在颜色实际需要变化时才重新设置palette。


4. 代码安全 🔒

评价: 优秀 ✅ 通过

🔐 发现 0 个安全漏洞

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

建议: 无安全风险。本次变更为纯UI渲染代码,不涉及用户输入处理、网络操作、文件系统访问或命令执行,无安全风险。


💡 改进建议代码示例

// 建议在updateTextColor()方法中添加设计规范注释

// bluetooth/eye-comfort-mode/wirelesscasting QuickPanelWidget
void QuickPanelWidget::updateTextColor(bool hover)
{
    // 设计规范:正常态70%透明度(alpha=0.7),hover态100%透明度(alpha=1.0)
    // 浅色模式文字颜色#000000,深色模式文字颜色#ffffff
    bool isLight = DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::LightType;
    QColor color = isLight ? QColor(0, 0, 0) : QColor(255, 255, 255);
    color.setAlphaF(hover ? 1.0 : 0.7);

    QPalette pa = m_nameLabel->palette();
    pa.setColor(QPalette::BrightText, color);
    pa.setColor(QPalette::WindowText, color);
    m_nameLabel->setPalette(pa);
    m_stateLabel->setPalette(pa);
}

// media QuickPanelWidget - 建议确认是否需要同步更新m_artistLab
void QuickPanelWidget::updateTextColor(bool hover)
{
    // 设计规范:正常态70%透明度,hover态100%透明度
    bool isLight = DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::LightType;
    QColor color = isLight ? QColor(0, 0, 0) : QColor(255, 255, 255);
    color.setAlphaF(hover ? 1.0 : 0.7);

    QPalette pa = m_titleLab->palette();
    pa.setColor(QPalette::BrightText, color);
    m_titleLab->setPalette(pa);

    // TODO: 确认是否需要同步更新艺术家标签透明度
    // pa = m_artistLab->palette();
    // pa.setColor(QPalette::BrightText, color);
    // m_artistLab->setPalette(pa);
}

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

@deepin-bot

deepin-bot Bot commented Sep 22, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 2.0.41
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #520

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