Skip to content

Conversation

@pengfeixx
Copy link
Contributor

@pengfeixx pengfeixx commented Dec 2, 2025

Fix the issue with link text style errors

Log: Fix the issue with link text style errors
pms: BUG-320975

Summary by Sourcery

Adjust the user experience program description to use rich text with theme-aware styling and keep it updated when the application theme changes.

Bug Fixes:

  • Prevent incorrect link text styling in the user experience program description by separating link and normal text colors and using rich text rendering.

Enhancements:

  • Refactor construction of the user experience program description into a reusable helper that reacts to theme changes.
  • Improve layout of the user experience program label by using padding and explicit width instead of full anchoring and opacity.

@sourcery-ai
Copy link

sourcery-ai bot commented Dec 2, 2025

Reviewer's Guide

Refactors how the User Experience Program description text is generated so that link styling is correctly handled across themes, and updates the QML label configuration to render rich text with theme-aware colors while reacting to theme changes at runtime.

Sequence diagram for theme change updating User Experience Program text

sequenceDiagram
    actor User
    participant DGuiApplicationHelper
    participant SystemInfoWork
    participant SystemInfoModel
    participant UserExperienceProgramPage
    participant userExperienceLabel

    User->>DGuiApplicationHelper: Change theme in system settings
    DGuiApplicationHelper-->>SystemInfoWork: themeTypeChanged
    SystemInfoWork->>SystemInfoWork: onThemeTypeChanged()
    SystemInfoWork->>SystemInfoWork: updateUserExperienceProgramText()
    SystemInfoWork->>DGuiApplicationHelper: themeType()
    DGuiApplicationHelper-->>SystemInfoWork: themeType value
    SystemInfoWork->>SystemInfoWork: Build themed HTML with normalColor and link style
    SystemInfoWork->>SystemInfoModel: setUserExperienceProgramText(htmlText)
    SystemInfoModel-->>UserExperienceProgramPage: userExperienceProgramText changed
    UserExperienceProgramPage-->>userExperienceLabel: text binding updated (RichText)
    userExperienceLabel->>User: Display themed text with correctly styled links
Loading

Updated class diagram for SystemInfoWork and related UI text handling

classDiagram
    class SystemInfoWork {
        - SystemInfoModel* m_model
        + SystemInfoWork(SystemInfoModel* model, QObject* parent)
        + void activate()
        + void deactivate()
        + void onTimezoneChanged(QString timezone)
        + void onShortDateFormatChanged(int shortDateFormate)
        + void onLicenseAuthorizationProperty()
        + void onThemeTypeChanged()
        - void getLicenseState()
        - void updateUserExperienceProgramText()
        + bool isUeProgramEnabled()
    }

    class SystemInfoModel {
        + void setUserExperienceProgramText(QString text)
        + QString userExperienceProgramText()
    }

    class DGuiApplicationHelper {
        - static DGuiApplicationHelper* m_instance
        + static DGuiApplicationHelper* instance()
        + int themeType()
        + void themeTypeChanged()
    }

    class UserExperienceProgramPage {
        + SystemInfoModel* model
        + void bindUserExperienceProgramText()
    }

    class DLabel {
        + int leftPadding
        + int rightPadding
        + int topPadding
        + int bottomPadding
        + QFont font
        + int horizontalAlignment
        + int wrapMode
        + int textFormat
        + int width
        + QString text
        + QString currentLinkUrl
    }

    SystemInfoWork --> SystemInfoModel : updates
    SystemInfoWork ..> DGuiApplicationHelper : uses
    UserExperienceProgramPage --> SystemInfoModel : reads
    UserExperienceProgramPage --> DLabel : contains userExperienceLabel
    SystemInfoModel --> DLabel : text bound via userExperienceProgramText
Loading

File-Level Changes

Change Details Files
Generate User Experience Program description text via a helper that applies theme-aware colors and link styling, and refresh it when the theme changes.
  • Replaced inline construction of the User Experience Program HTML text in activate() with a call to a new updateUserExperienceProgramText() helper.
  • Implemented updateUserExperienceProgramText() to build the HTML string with theme-dependent normal text color (semi-transparent black for light theme, semi-transparent white for dark theme).
  • Ensured links in the HTML use inline styles (no text decoration) while surrounding descriptive text uses the theme-aware color via span tags.
  • Added onThemeTypeChanged() slot that calls updateUserExperienceProgramText() so text is regenerated when the theme changes.
  • Connected DGuiApplicationHelper::themeTypeChanged to SystemInfoWork::onThemeTypeChanged so theme changes are observed.
src/plugin-systeminfo/operation/systeminfowork.cpp
src/plugin-systeminfo/operation/systeminfowork.h
Adjust QML label for User Experience Program text to properly render rich text and layout.
  • Switched from anchors.fill with margins to explicit paddings for the label content to simplify layout.
  • Updated font reference from DTK.fontManager.t6 to D.DTK.fontManager.t6 (new/consistent namespace usage).
  • Enabled rich text rendering by setting textFormat to Text.RichText for the label, required for styled HTML content.
  • Bound label width to parent width when available to ensure correct wrapping behavior and removed manual opacity control, relying instead on theme-controlled text color.
src/plugin-systeminfo/qml/UserExperienceProgramPage.qml

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

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 there - I've reviewed your changes - here's some feedback:

  • The hard-coded ARGB hex color values used for normalColor in updateUserExperienceProgramText() may not stay consistent with future theme changes or accessibility requirements; consider deriving the color from the current palette or a theme helper API instead of embedding literal values.
  • In UserExperienceProgramPage.qml, binding width: parent ? parent.width : implicitWidth on userExperienceLabel can conflict with layout/parent sizing; if this label is in a layout or container that already manages width, consider removing the explicit width binding and relying on layout/anchors to avoid potential binding loops or unexpected resizing.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The hard-coded ARGB hex color values used for `normalColor` in `updateUserExperienceProgramText()` may not stay consistent with future theme changes or accessibility requirements; consider deriving the color from the current palette or a theme helper API instead of embedding literal values.
- In `UserExperienceProgramPage.qml`, binding `width: parent ? parent.width : implicitWidth` on `userExperienceLabel` can conflict with layout/parent sizing; if this label is in a layout or container that already manages width, consider removing the explicit width binding and relying on layout/anchors to avoid potential binding loops or unexpected resizing.

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, pengfeixx

The full list of commands accepted by this bot can be found here.

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

Fix the issue with link text style errors

Log: Fix the issue with link text style errors
pms: BUG-320975
@deepin-ci-robot
Copy link

deepin pr auto review

我来对这个diff进行代码审查:

  1. 代码逻辑改进:
  • 将用户体验计划文本的初始化逻辑从activate()方法中提取到单独的updateUserExperienceProgramText()方法中,这是一个很好的重构,提高了代码的可维护性。
  • 添加了主题切换的响应机制,当主题改变时自动更新文本颜色,提升了用户体验。
  1. 代码质量改进:
  • 在updateUserExperienceProgramText()中增加了对m_model的空指针检查,提高了代码的健壮性。
  • 使用QStringLiteral替代普通字符串字面量,提高了性能。
  • 使用HTML span标签统一管理文本颜色,使样式更加统一。
  1. 代码性能改进:
  • 将文本颜色计算移到updateUserExperienceProgramText()中,避免了重复计算。
  • 使用信号槽机制响应主题变化,而不是频繁轮询,减少了系统资源消耗。
  1. 代码安全改进:
  • 对URL使用了tr()进行国际化处理,确保不同语言环境下都能正确显示。
  • 使用textFormat: Text.RichText明确指定文本格式,避免潜在的XSS风险。

建议改进:

  1. 在SystemInfoWork.h中,可以考虑将updateUserExperienceProgramText()声明为const方法,因为它不修改对象状态。
  2. 在UserExperienceProgramPage.qml中,建议为userExperienceLabel添加maximumLineCount属性,避免文本过长时显示问题。
  3. 可以考虑将颜色值定义为常量,便于后续维护:
private:
    static constexpr const char* DARK_THEME_TEXT_COLOR = "#B3FFFFFF";
    static constexpr const char* LIGHT_THEME_TEXT_COLOR = "#64000000";
  1. 建议在updateUserExperienceProgramText()中添加日志,便于调试:
if (!m_model) {
    qWarning() << "SystemInfoWork: model is null in updateUserExperienceProgramText";
    return;
}
  1. 在QML文件中,建议添加对parent的空值检查:
width: parent ? parent.width : implicitWidth

这些改进将进一步提高代码的可维护性、性能和安全性。

@pengfeixx
Copy link
Contributor Author

/forcemerge

@deepin-bot
Copy link

deepin-bot bot commented Dec 4, 2025

This pr force merged! (status: blocked)

@deepin-bot deepin-bot bot merged commit 0db26d2 into linuxdeepin:master Dec 4, 2025
16 of 18 checks passed
@pengfeixx pengfeixx deleted the fix-320975 branch December 4, 2025 03:02
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