fix: add support for markdown format in user license#3152
Merged
mhduiy merged 1 commit intolinuxdeepin:masterfrom Apr 3, 2026
Merged
fix: add support for markdown format in user license#3152mhduiy merged 1 commit intolinuxdeepin:masterfrom
mhduiy merged 1 commit intolinuxdeepin:masterfrom
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdds 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 renderingsequenceDiagram
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
Class diagram for updated SystemInfoModel user license format handlingclassDiagram
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()
}
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
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>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
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
e92acd5 to
4298630
Compare
18202781743
approved these changes
Apr 3, 2026
|
[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. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Log: User license page now automatically detects and renders markdown format for .md files
fix: 用户许可协议添加对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:
Enhancements:
Build: