Skip to content

fix: 统一任务栏亮度插件图标与控制中心一致 - #512

Closed
mhduiy wants to merge 2 commits into
linuxdeepin:masterfrom
mhduiy:fix-pms-296501-brightness-icon
Closed

mhduiy wants to merge 2 commits into
linuxdeepin:masterfrom
mhduiy:fix-pms-296501-brightness-icon

Conversation

@mhduiy

@mhduiy mhduiy commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Root Cause Analysis

The brightness plugin in the taskbar (brightnessitem.cpp) loads the SVG icon display-brightness-control (half-filled sun) via QIcon::fromTheme(), while the control center plugin area loads the DCI icon dcc-dde-brightness (hollow sun) from /usr/share/dde-dock/icons/dcc-setting/. Two independently maintained icon resources with no unified contract cause visual inconsistency.

Key evidence:

  • brightnessitem.cpp:53 uses QIcon::fromTheme("display-brightness-control") (SVG, half-filled sun)
  • dccdockexport.cpp loadPluginData() uses QIcon::fromTheme("dcc-dde-brightness") (DCI, hollow sun)
  • DCI file dcc-dde-brightness.dci is installed by the same plugin's CMakeLists.txt

Fix

Unify the taskbar brightness plugin to load the same DCI icon dcc-dde-brightness used by the control center:

  1. Add #include <DIconTheme>
  2. Add DCI search path /usr/share/dde-dock/icons/dcc-setting via Dtk::Gui::DIconTheme::setDciThemeSearchPaths()
  3. Change icon name from display-brightness-control to dcc-dde-brightness

Only 1 file changed (brightnessitem.cpp), ~5 lines added/modified.

Change Safety Assessment

Risk level: Low

  • No function signature changes, no public API changes, no external callers affected
  • BrightnessItem::init() was introduced in the initial commit and never modified since
  • Related PMS bug 375465 (tooltip font fix) is unrelated to this icon change

Business impact:

  • Affected module: brightness plugin icon display in taskbar
  • After fix, the taskbar brightness icon should visually match the control center plugin area icon (hollow sun DCI)
  • No functional logic changes (brightness adjustment, tooltip, context menu all unaffected)

Verification suggestions:

  • Verify the taskbar brightness icon displays correctly in both light/dark themes
  • Verify the icon visually matches the control center plugin area brightness icon
  • Verify brightness plugin functionality remains intact (brightness adjustment, tooltip, right-click menu)

根因分析

任务栏亮度插件(brightnessitem.cpp)通过 QIcon::fromTheme("display-brightness-control") 加载 SVG 图标(半填充太阳),而控制中心插件区域通过 QIcon::fromTheme("dcc-dde-brightness") 加载 DCI 图标(空心太阳)。两套图标资源独立维护、无统一引用合约,导致视觉不一致。

修复方案

将任务栏亮度插件改为加载与控制中心相同的 DCI 图标 dcc-dde-brightness:

  1. 添加 #include <DIconTheme>
  2. 通过 Dtk::Gui::DIconTheme::setDciThemeSearchPaths() 添加 DCI 搜索路径 /usr/share/dde-dock/icons/dcc-setting
  3. 图标名从 display-brightness-control 改为 dcc-dde-brightness

仅改动 brightnessitem.cpp 1 个文件,约 5 行。

改动安全评估

风险等级:低风险

  • 不涉及函数签名变更、不修改公开 API、无外部调用者受影响
  • BrightnessItem::init() 自初始提交引入后从未修改
  • 关联 PMS bug 375465(tooltip 字体修复)与本次图标修改无关

业务影响范围:

  • 受影响模块:任务栏亮度插件图标显示
  • 修复后任务栏亮度图标应与控制中心插件区域图标视觉一致(空心太阳 DCI 图标)
  • 不影响功能逻辑(亮度调节、tooltip 显示、右键菜单均不受影响)

验证建议:

  • 验证任务栏亮度插件图标在浅色/深色主题下均正常显示
  • 验证图标与控制中心插件区域亮度图标视觉一致
  • 验证亮度插件功能不受影响(亮度调节、tooltip、右键菜单)

Summary by Sourcery

Unify dock plugin icon resources so brightness and wireless casting icons use the intended DCI assets consistently.

Bug Fixes:

  • Align the taskbar brightness plugin icon with the control center by using the shared DCI brightness icon.

Build:

  • Update wireless casting icon packaging to install the DCI resource in the dock icon directory and remove the obsolete SVG resource.

Chores:

  • Update reuse and Debian installation metadata.

mhduiy added 2 commits January 9, 2025 21:30
任务栏亮度插件使用 SVG 图标 display-brightness-control(半填充太阳),
而控制中心插件区域使用 DCI 图标 dcc-dde-brightness(空心太阳),
两套图标资源独立维护导致视觉不一致。

将任务栏亮度插件改为加载与控制中心相同的 DCI 图标
dcc-dde-brightness,并添加 DCI 搜索路径。

Log: 修复任务栏亮度图标与控制中心插件区域图标不一致的问题
Bug: https://pms.uniontech.com/bug-view-296501.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

The PR changes the brightness taskbar plugin to load the same DCI icon as the control center by configuring the DCI search path and using dcc-dde-brightness; it also includes unrelated-looking wireless-casting icon packaging and metadata changes that should be reviewed separately.

Sequence diagram for unified brightness icon loading

sequenceDiagram
    participant BrightnessItem
    participant DIconTheme
    participant IconTheme
    participant Taskbar
    participant ControlCenter

    BrightnessItem->>DIconTheme: dciThemeSearchPaths()
    BrightnessItem->>DIconTheme: setDciThemeSearchPaths(dciPaths)
    BrightnessItem->>IconTheme: fromTheme(dcc-dde-brightness)
    IconTheme-->>BrightnessItem: DCI brightness icon
    BrightnessItem->>Taskbar: setIcon(dcc-dde-brightness)
    ControlCenter->>IconTheme: fromTheme(dcc-dde-brightness)
    IconTheme-->>ControlCenter: Same DCI brightness icon
Loading

File-Level Changes

Change Details Files
Unify the taskbar brightness icon with the control center by resolving the shared DCI resource through DIconTheme.
  • Add the DIconTheme dependency and prepend the installed control-center icon directory to DCI search paths.
  • Replace the half-filled theme icon name with dcc-dde-brightness before setting the plugin icon.
plugins/dde-dock/brightness/brightnessitem.cpp
Update the wireless-casting plugin’s installed control-center icon resource from SVG to DCI.
  • Install the dcc-wireless-casting.dci asset in the control-center icon directory.
  • Remove the previous wireless-casting.svg asset.
plugins/dde-network-display-ui/plugins/CMakeLists.txt
plugins/dde-network-display-ui/plugins/dock-wirelesscasting-plugin/res/wireless-casting.svg
Adjust repository metadata and Debian installation packaging.
  • Update the REUSE dep5 metadata.
  • Modify the wireless-casting Debian install manifest.
.reuse/dep5
debian/dde-wirelesscasting-plugin.install

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/brightness/brightnessitem.cpp" line_range="56" />
<code_context>
-    m_icon->setIcon(QIcon::fromTheme("display-brightness-control"));
+
+    auto dciPaths = Dtk::Gui::DIconTheme::dciThemeSearchPaths();
+    dciPaths.prepend("/usr/share/dde-dock/icons/dcc-setting");
+    Dtk::Gui::DIconTheme::setDciThemeSearchPaths(dciPaths);
+
</code_context>
<issue_to_address>
**issue (bug_risk):** The DCI search path is hard-coded to `/usr/share/dde-dock/icons/dcc-setting`, while CMake installs the icon relative to `CMAKE_INSTALL_PREFIX`. Builds or packages using a non-`/usr` prefix install `dcc-dde-brightness.dci` elsewhere, so `QIcon::fromTheme("dcc-dde-brightness")` cannot find the icon and the taskbar icon is empty.

**Triggers:** When the project is built or packaged with a `CMAKE_INSTALL_PREFIX` other than `/usr`.

**Suggested fix:** Use the configured install prefix or a runtime-resolved data path instead of hard-coding `/usr/share`.
</issue_to_address>

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

m_icon->setIcon(QIcon::fromTheme("display-brightness-control"));

auto dciPaths = Dtk::Gui::DIconTheme::dciThemeSearchPaths();
dciPaths.prepend("/usr/share/dde-dock/icons/dcc-setting");

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 (bug_risk): The DCI search path is hard-coded to /usr/share/dde-dock/icons/dcc-setting, while CMake installs the icon relative to CMAKE_INSTALL_PREFIX. Builds or packages using a non-/usr prefix install dcc-dde-brightness.dci elsewhere, so QIcon::fromTheme("dcc-dde-brightness") cannot find the icon and the taskbar icon is empty.

Triggers: When the project is built or packaged with a CMAKE_INSTALL_PREFIX other than /usr.

Suggested fix: Use the configured install prefix or a runtime-resolved data path instead of hard-coding /usr/share.

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

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

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 总体评分 98 分,大于 70 分通过阈值,代码质量符合要求。本次变更将任务栏亮度插件图标从 SVG 格式统一为 DCI 格式,与控制中心保持一致,变更范围小且安全。

🔍 详细分析

1. 语法逻辑 ✅

评价: 优秀 ✅ 通过

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

建议: 代码语法正确,逻辑清晰,无需修改


2. 代码质量 ✅

评价: 优秀 ✅ 通过

潜在问题:

  1. plugins/dde-dock/brightness/brightnessitem.cpp:53 - DCI 搜索路径修改逻辑未添加注释说明原因,建议添加简要注释
  2. plugins/dde-dock/brightness/brightnessitem.cpp:54 - 硬编码路径 "/usr/share/dde-dock/icons/dcc-setting",建议提取为常量定义

建议: 建议将硬编码路径提取为常量或宏定义,并为 DCI 搜索路径修改添加简要注释说明原因


3. 代码性能 ✅

评价: 优秀 ✅ 通过

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

建议: DCI 路径设置仅在 init() 中执行一次,无性能问题


4. 代码安全 🔒

评价: 优秀 ✅ 通过

🔐 发现 0 个安全漏洞

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

建议: 无安全漏洞,代码安全合规


💡 改进建议代码示例

// 建议使用常量定义路径,并添加注释
constexpr auto kDccSettingIconPath = "/usr/share/dde-dock/icons/dcc-setting";

void BrightnessItem::init()
{
    m_icon->setFixedSize(Dock::DOCK_PLUGIN_ITEM_FIXED_SIZE);

    // 添加控制中心插件图标搜索路径,确保 DCI 图标能被正确加载
    auto dciPaths = Dtk::Gui::DIconTheme::dciThemeSearchPaths();
    dciPaths.prepend(kDccSettingIconPath);
    Dtk::Gui::DIconTheme::setDciThemeSearchPaths(dciPaths);

    m_icon->setIcon(QIcon::fromTheme("dcc-dde-brightness"));
    connect(m_applet, &BrightnessApplet::requestHideApplet, this, &BrightnessItem::requestHideApplet);
}

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

@mhduiy

mhduiy commented Sep 21, 2026

Copy link
Copy Markdown
Contributor Author

Closing: wrong direction. Fix moved to dde-control-center instead (per user feedback: Control Center should use taskbar's display-brightness-control icon, not the reverse).

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