Skip to content

fix: improve theme compatibility for bluetooth label#361

Merged
wjyrich merged 1 commit into
linuxdeepin:masterfrom
wjyrich:fix-bug-332553
Sep 5, 2025
Merged

fix: improve theme compatibility for bluetooth label#361
wjyrich merged 1 commit into
linuxdeepin:masterfrom
wjyrich:fix-bug-332553

Conversation

@wjyrich

@wjyrich wjyrich commented Sep 5, 2025

Copy link
Copy Markdown
Contributor

Changed QLabel to DLabel for better theme integration and added dynamic text color handling
Added DPaletteHelper and DGuiApplicationHelper includes for theme management
Implemented theme change handler to update text color when system theme changes
Adjusted text alpha values from 0.75 to 0.6 for better readability across themes
Modified bottom margin from 2 to 6 for better spacing

These changes ensure consistent text appearance in both light and dark themes
and improve the overall visual experience in the bluetooth dock plugin

fix: 改进蓝牙标签的主题兼容性

将 QLabel 改为 DLabel 以实现更好的主题集成并添加动态文本颜色处理
添加 DPaletteHelper 和 DGuiApplicationHelper 包含以进行主题管理 实现主题变更处理程序,在系统主题更改时更新文本颜色
将文本透明度值从 0.75 调整为 0.6,以在不同主题下获得更好的可读性
将底部边距从 2 修改为 6 以获得更好的间距

这些更改确保在浅色和深色主题下文本外观一致
并改善蓝牙坞站插件的整体视觉体验
Pms: BUG-332553

Summary by Sourcery

Improve theme compatibility and readability of the Bluetooth dock plugin by integrating labels with the system theme, handling dynamic theme changes, and adjusting text opacity and spacing.

Enhancements:

  • Switch the “My Devices” label from QLabel to DLabel and use DPaletteHelper and DGuiApplicationHelper for theme-aware coloring and runtime theme change handling
  • Reduce text opacity from 75% to 60% and increase the label’s bottom margin from 2 to 6 to enhance readability and spacing, also applying 60% transparency to DeviceControlWidget text

@sourcery-ai

sourcery-ai Bot commented Sep 5, 2025

Copy link
Copy Markdown

Reviewer's Guide

This PR refactors the BluetoothAdapterItem’s device label to use DLabel with dynamic theme-aware coloring and spacing, and updates the DeviceControlWidget text transparency for improved readability across light and dark themes.

File-Level Changes

Change Details Files
Replace QLabel with DLabel and integrate theme-based color updates for the “My Devices” label
  • Swap QLabel for DLabel
  • Add DPaletteHelper and DGuiApplicationHelper includes
  • Bind font size using DFontSizeManager
  • Set contentsMargins bottom to 6 instead of 2
  • Compute and apply textColor with 0.6 alpha based on themeType
  • Connect themeTypeChanged signal to update the palette and call update()
plugins/dde-dock/bluetooth/componments/bluetoothadapteritem.cpp
plugins/dde-dock/bluetooth/componments/bluetoothadapteritem.h
Adjust DeviceControlWidget text alpha for consistency
  • Change textNomal.setAlphaF from 0.75 to 0.6
plugins/dde-dock/bluetooth/componments/bluetoothadapteritem.h

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 there - 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.

});
connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, this, [this]{
QColor textColor;
if (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::LightType) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

代码优化一下,提成一个函数,颜色可以取出来,只修改透明度,

Changed QLabel to DLabel for better theme integration and added dynamic
text color handling
Added DPaletteHelper and DGuiApplicationHelper includes for theme
management
Implemented theme change handler to update text color when system theme
changes
Adjusted text alpha values from 0.75 to 0.6 for better readability
across themes
Modified bottom margin from 2 to 6 for better spacing

These changes ensure consistent text appearance in both light and dark
themes
and improve the overall visual experience in the bluetooth dock plugin

fix: 改进蓝牙标签的主题兼容性

将 QLabel 改为 DLabel 以实现更好的主题集成并添加动态文本颜色处理
添加 DPaletteHelper 和 DGuiApplicationHelper 包含以进行主题管理
实现主题变更处理程序,在系统主题更改时更新文本颜色
将文本透明度值从 0.75 调整为 0.6,以在不同主题下获得更好的可读性
将底部边距从 2 修改为 6 以获得更好的间距

这些更改确保在浅色和深色主题下文本外观一致
并改善蓝牙坞站插件的整体视觉体验
Pms: BUG-332553
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

根据提供的代码 diff,我来分析一下改进的内容:

代码审查意见

1. 语法逻辑

  • 代码逻辑基本清晰,没有明显的语法错误。
  • 新增的 updateMyDeviceLabelTheme() 函数实现了主题切换时更新标签颜色的功能,逻辑合理。

2. 代码质量

  • 改进点

    • 使用 DLabel 替换了普通 QLabel,符合 DTK 风格规范
    • 添加了主题切换的支持,提升了界面的一致性
    • 增加了适当的间距(从 2px 调整为 6px)
    • 将文字透明度统一调整为 0.6(之前是 0.75)
  • 建议

    • 可以考虑将颜色值定义为常量,便于统一管理和修改
    • updateMyDeviceLabelTheme() 函数可以添加注释说明其用途

3. 代码性能

  • 主题切换时使用了信号槽机制,只在主题变化时更新,性能表现良好
  • 使用了 DTK 的辅助类(DPaletteHelper、DGuiApplicationHelper),这些都已经过优化

4. 代码安全

  • 代码中使用了 DTK 的安全组件,符合框架的安全规范
  • 颜色设置使用了透明度(alpha),避免了硬编码的颜色值

5. 其他建议

  • 可以考虑将主题相关的颜色定义提取为常量,例如:
namespace {
    constexpr qreal LABEL_TEXT_ALPHA = 0.6;
    constexpr int LABEL_MARGIN_TOP = 6;
    // 其他常量...
}
  • updateMyDeviceLabelTheme() 函数中添加注释说明其作用
  • 可以考虑将设备控制按钮的透明度也统一使用常量

总的来说,这次改进主要围绕主题适配和界面一致性展开,改动合理且符合 DTK 的设计规范。通过使用 DTK 组件和统一透明度,提升了界面的整体美观度和一致性。

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743, wjyrich

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

@wjyrich wjyrich merged commit 972165c into linuxdeepin:master Sep 5, 2025
9 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