Skip to content

fix: add support for markdown format in user license#3152

Merged
mhduiy merged 1 commit intolinuxdeepin:masterfrom
mhduiy:doc
Apr 3, 2026
Merged

fix: add support for markdown format in user license#3152
mhduiy merged 1 commit intolinuxdeepin:masterfrom
mhduiy:doc

Conversation

@mhduiy
Copy link
Copy Markdown
Contributor

@mhduiy mhduiy commented Apr 3, 2026

  1. Added QT_NS::QuickPrivate to CMakeLists.txt to access QQuickText private API for text format detection
  2. Updated copyright years from 2023 to 2026 in source files
  3. Enhanced SystemInfoModel to detect markdown format based on file extension (.md) in setEndUserAgreementPath()
  4. Added userLicenseFormat property with QQuickText::TextFormat type to expose format information to QML
  5. Modified UserLicensePage.qml to use dynamic textFormat from model instead of hardcoded MarkdownText
  6. This ensures proper rendering of both plain text and markdown license files based on actual file type

Log: User license page now automatically detects and renders markdown format for .md files

fix: 用户许可协议添加对markdown格式的支持

  1. 在CMakeLists.txt中添加QT_NS::QuickPrivate以访问QQuickText私有API进行 文本格式检测
  2. 将源文件中的版权年份从2023年更新到2026年
  3. 增强SystemInfoModel,在setEndUserAgreementPath()中基于文件扩展名(.md) 检测markdown格式
  4. 添加userLicenseFormat属性(QQuickText::TextFormat类型)将格式信息暴露 给QML
  5. 修改UserLicensePage.qml使用模型中的动态textFormat,而不是硬编码 的MarkdownText
  6. 确保根据实际文件类型正确渲染纯文本和markdown格式的许可文件

Log: 用户许可协议页面现在能自动检测并渲染.md文件的markdown格式

PMS: TASK-388139

Summary by Sourcery

Add dynamic detection and exposure of the user license text format so the QML user license page can correctly render markdown and plain-text files, and update related build configuration and metadata.

New Features:

  • Expose userLicenseFormat from SystemInfoModel to QML to indicate the license text format.
  • Automatically determine user license format as markdown when the agreement file has a .md extension.

Enhancements:

  • Update the user license QML page to use the model-provided text format instead of a hardcoded markdown setting.
  • Update copyright years in system info model sources to 2026.

Build:

  • Link against Qt Quick private library to access QQuickText text format APIs.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Apr 3, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adds markdown-vs-plain-text detection for the user license file and exposes the detected QQuickText::TextFormat to QML, so the license page renders .md files as markdown and other files as plain text, while also updating copyright years and linking against Qt Quick private APIs.

Sequence diagram for dynamic user license text format detection and rendering

sequenceDiagram
    actor User
    participant UserLicensePageQml
    participant SystemInfoModel

    User->>UserLicensePageQml: Open_license_page
    UserLicensePageQml->>SystemInfoModel: setEndUserAgreementPath(path)
    activate SystemInfoModel
    SystemInfoModel->>SystemInfoModel: m_endUserAgreementTextPath = path
    SystemInfoModel->>SystemInfoModel: isMarkdown = path.endsWith(.md)
    SystemInfoModel->>SystemInfoModel: m_userLicenseFormat = isMarkdown ? MarkdownText : PlainText
    SystemInfoModel-->>UserLicensePageQml: userLicenseFormatChanged signal
    deactivate SystemInfoModel

    UserLicensePageQml->>SystemInfoModel: read userLicense
    SystemInfoModel-->>UserLicensePageQml: license text

    UserLicensePageQml->>SystemInfoModel: read userLicenseFormat
    SystemInfoModel-->>UserLicensePageQml: QQuickText::TextFormat

    UserLicensePageQml->>UserLicensePageQml: Text.textFormat = userLicenseFormat
    UserLicensePageQml-->>User: Render license as markdown or plain text
Loading

Class diagram for updated SystemInfoModel user license format handling

classDiagram
    class SystemInfoModel {
        +QString userLicense
        +std::optional<QString> endUserAgreementPath()
        +QQuickText::TextFormat userLicenseFormat()
        +void setEndUserAgreementPath(QString path)
        -- backing fields --
        -std::optional<QString> m_endUserAgreementTextPath
        -QQuickText::TextFormat m_userLicenseFormat
        -- signals --
        +void userLicenseChanged()
        +void userLicenseFormatChanged()
    }
Loading

File-Level Changes

Change Details Files
Detect and store license text format in SystemInfoModel based on the end-user agreement path.
  • Include QQuickText private header and , switch to includes ordering
  • Add Q_PROPERTY for userLicenseFormat with type QQuickText::TextFormat and corresponding getter
  • Introduce m_userLicenseFormat member defaulted to QQuickText::PlainText and userLicenseFormatChanged() signal
  • In setEndUserAgreementPath(), derive isMarkdown from .md extension and set m_userLicenseFormat to MarkdownText or PlainText, emitting userLicenseFormatChanged()
src/plugin-systeminfo/operation/systeminfomodel.h
src/plugin-systeminfo/operation/systeminfomodel.cpp
Make QML license page use the model-provided text format instead of hardcoded markdown.
  • Change Text item in UserLicensePage.qml to bind textFormat to dccData.systemInfoMode().userLicenseFormat instead of Text.MarkdownText
src/plugin-systeminfo/qml/UserLicensePage.qml
Link against Qt Quick private library to use QQuickText private API.
  • Add ${QT_NS}::QuickPrivate to SystemInfo_Libraries so the plugin links against Qt Quick private symbols
src/plugin-systeminfo/CMakeLists.txt
Update SPDX copyright years to 2026.
  • Change SPDX-FileCopyrightText years from 2018-2023 to 2018-2026 in SystemInfoModel headers and implementation
src/plugin-systeminfo/operation/systeminfomodel.h
src/plugin-systeminfo/operation/systeminfomodel.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

Copy link
Copy Markdown

@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 found 2 issues, and left some high level feedback:

  • The commit message mentions using QQuickText private APIs for text format detection, but the implementation just checks the file extension; consider aligning the description with the actual behavior or implementing true content-based detection if that was the intent.
  • Since you’re only using QQuickText::TextFormat, you might avoid depending on the private qquicktext_p.h and QuickPrivate library by exposing a simple integer/enum of your own, reducing coupling to Qt private APIs.
  • In setEndUserAgreementPath(), you always emit userLicenseFormatChanged even when the detected format doesn’t actually change; adding a comparison before emitting would avoid unnecessary change notifications in QML.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The commit message mentions using QQuickText private APIs for text format detection, but the implementation just checks the file extension; consider aligning the description with the actual behavior or implementing true content-based detection if that was the intent.
- Since you’re only using QQuickText::TextFormat, you might avoid depending on the private qquicktext_p.h and QuickPrivate library by exposing a simple integer/enum of your own, reducing coupling to Qt private APIs.
- In setEndUserAgreementPath(), you always emit userLicenseFormatChanged even when the detected format doesn’t actually change; adding a comparison before emitting would avoid unnecessary change notifications in QML.

## Individual Comments

### Comment 1
<location path="src/plugin-systeminfo/operation/systeminfomodel.h" line_range="8" />
<code_context>

-#include "qcolor.h"
+#include <QObject>
+#include <private/qquicktext_p.h>
+#include <optional>

</code_context>
<issue_to_address>
**issue:** Avoid depending on Qt private header qquicktext_p in a public header.

This public header now depends on Qt’s private API, which has no compatibility guarantees and may break on Qt upgrades. Use a public type (e.g. `int` or a local enum) in the header and convert to `QQuickText::TextFormat` inside the implementation instead.
</issue_to_address>

### Comment 2
<location path="src/plugin-systeminfo/operation/systeminfomodel.h" line_range="38" />
<code_context>
     Q_PROPERTY(QString gnuLinceseTitle READ gnuLinceseTitle NOTIFY gnuLinceseTitleChanged FINAL)
     Q_PROPERTY(QString gnuLinceseContent READ gnuLinceseContent NOTIFY gnuLinceseContentChanged FINAL)
     Q_PROPERTY(QString userLicense READ userLicense NOTIFY userLicenseChanged FINAL)
+    Q_PROPERTY(QQuickText::TextFormat userLicenseFormat READ userLicenseFormat NOTIFY userLicenseFormatChanged FINAL)
     Q_PROPERTY(QString userExperienceProgramText READ userExperienceProgramText NOTIFY userExperienceProgramTextChanged FINAL)
     Q_PROPERTY(bool joinUeProgram READ joinUeProgram NOTIFY joinUeProgramChanged FINAL)
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Exposing QQuickText::TextFormat directly in the public QObject API may cause stability and compatibility issues.

This makes the QML API depend on an internal QtQuick type, which may change or disappear between Qt versions. Prefer exposing a plain `int`/`enum` on `SystemInfoModel` and converting to/from `QQuickText::TextFormat` internally to keep the private type out of the public API surface.

Suggested implementation:

```c
    Q_PROPERTY(QString gnuLinceseTitle READ gnuLinceseTitle NOTIFY gnuLinceseTitleChanged FINAL)
    Q_PROPERTY(QString gnuLinceseContent READ gnuLinceseContent NOTIFY gnuLinceseContentChanged FINAL)
    Q_PROPERTY(QString userLicense READ userLicense NOTIFY userLicenseChanged FINAL)
    Q_PROPERTY(int userLicenseFormat READ userLicenseFormat NOTIFY userLicenseFormatChanged FINAL)
    Q_PROPERTY(QString userExperienceProgramText READ userExperienceProgramText NOTIFY userExperienceProgramTextChanged FINAL)
    Q_PROPERTY(bool joinUeProgram READ joinUeProgram NOTIFY joinUeProgramChanged FINAL)

```

```c
    QString hostName() const { return  m_hostName;}

    // Exposed as a plain int in the public API to avoid depending on QQuickText::TextFormat
    enum UserLicenseFormat {
        UserLicensePlainText = 0,
        UserLicenseRichText = 1,
        UserLicenseAutoText = 2
    };

    inline std::optional<QString> endUserAgreementPath() const { return m_endUserAgreementTextPath; }
    inline int userLicenseFormat() const { return static_cast<int>(m_userLicenseFormat); }
    inline ActiveState licenseState() const { return m_licenseState; }

```
</issue_to_address>

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.

18202781743
18202781743 previously approved these changes Apr 3, 2026
1. Added QT_NS::QuickPrivate to CMakeLists.txt to access QQuickText
private API for text format detection
2. Updated copyright years from 2023 to 2026 in source files
3. Enhanced SystemInfoModel to detect markdown format based on file
extension (.md) in setEndUserAgreementPath()
4. Added userLicenseFormat property with QQuickText::TextFormat type to
expose format information to QML
5. Modified UserLicensePage.qml to use dynamic textFormat from model
instead of hardcoded MarkdownText
6. This ensures proper rendering of both plain text and markdown license
files based on actual file type

Log: User license page now automatically detects and renders markdown
format for .md files

fix: 用户许可协议添加对markdown格式的支持

1. 在CMakeLists.txt中添加QT_NS::QuickPrivate以访问QQuickText私有API进行
文本格式检测
2. 将源文件中的版权年份从2023年更新到2026年
3. 增强SystemInfoModel,在setEndUserAgreementPath()中基于文件扩展名(.md)
检测markdown格式
4. 添加userLicenseFormat属性(QQuickText::TextFormat类型)将格式信息暴露
给QML
5. 修改UserLicensePage.qml使用模型中的动态textFormat,而不是硬编码
的MarkdownText
6. 确保根据实际文件类型正确渲染纯文本和markdown格式的许可文件

Log: 用户许可协议页面现在能自动检测并渲染.md文件的markdown格式

PMS: TASK-388139
@deepin-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743, 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

@mhduiy mhduiy merged commit 5631214 into linuxdeepin:master Apr 3, 2026
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