Skip to content

fix(DApplication): wire up applicationHomePage in about dialog - #778

Open
18202781743 wants to merge 2 commits into
linuxdeepin:masterfrom
18202781743:feat/dde-211-custom-website-about-dialog
Open

fix(DApplication): wire up applicationHomePage in about dialog#778
18202781743 wants to merge 2 commits into
linuxdeepin:masterfrom
18202781743:feat/dde-211-custom-website-about-dialog

Conversation

@18202781743

@18202781743 18202781743 commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

背景

DApplication::handleAboutAction() 在自动创建关于对话框时,只设置了 productName / productIcon / version / description / license / acknowledgement,未调用 DAboutDialog::setWebsiteName / setWebsiteLink,导致应用无法自定义网站行,始终回退到发行版默认值。

根因

  • DAboutDialog 本身已具备 setWebsiteName() / setWebsiteLink() 能力,但 DApplication 的自动创建路径没有接线。
  • DApplication 已有 applicationHomePage / setApplicationHomePage 属性,文档明确写着「主要用于在关于对话框中进行展示」,但该属性从未被 handleAboutAction() 读取,属于遗留死 API。

方案(采用 DDE Architect 推荐方案)

复用遗留的 applicationHomePage(作为 link 源),并新增 applicationWebsiteName(作为展示名称):

改动文件

  1. include/widgets/dapplication.h

    • 新增 Q_PROPERTY(QString applicationHomePage ...)(补齐元对象一致性)
    • 新增 Q_PROPERTY(QString applicationWebsiteName ...)
    • 新增 applicationWebsiteName() / setApplicationWebsiteName() 声明
  2. src/widgets/dapplication.cpp

    • 实现 applicationWebsiteName() / setApplicationWebsiteName()(读写 d->websiteName
    • handleAboutAction() 自动建对话框段落,设置完 acknowledgement 后、setAttribute(WA_DeleteOnClose) 前,按「非空才覆盖」插入:
      if (!applicationHomePage().isEmpty())
          aboutDialog->setWebsiteLink(applicationHomePage());
      if (!applicationWebsiteName().isEmpty())
          aboutDialog->setWebsiteName(applicationWebsiteName());
  3. src/widgets/private/dapplication_p.h

    • 新增成员 QString websiteName;
  4. CHANGELOG.md

    • Added: applicationWebsiteName 属性
    • Changed: applicationHomePage 现生效于关于对话框

向后兼容

  • 纯增量 API:新增 applicationWebsiteName getter/setter 与 Q_PROPERTY,以及为 applicationHomePageQ_PROPERTY,均为源码/二进制兼容的加法(DTK6 SONAME 线内)。
  • 默认行为不变:当开发者未设 applicationHomePageapplicationWebsiteName 时,两个 if (!...isEmpty()) 均不触发,对话框仍显示发行版默认网站。
  • applicationHomePage 从死代码变为生效:变更方向符合其文档一直承诺的用途;唯一受影响的是「调用了 setApplicationHomePage 却期望它什么都不做」的极端组合,实际中几乎不存在。
  • 自定义对话框路径不受影响:经 setAboutDialog() 传入的对话框不走新逻辑。
  • 无需 DTK 版本守卫:DTK6 线的新增特性。

测试建议

新增用例覆盖 4 个组合:

  • (name, link) 均空 → 显示发行版默认
  • 仅 link → link 自定义、名称为发行版默认
  • 仅 name → 名称自定义、link 为发行版默认
  • 均设 → 均为自定义值

并回归:

  • 不设任何值时仍显示发行版默认
  • setAboutDialog 自定义对话框不受影响

关联

  • Issue: DDE-211
  • 技术方案:DDE Architect

Summary by Sourcery

Bug Fixes:

  • Apply the configured application homepage to the automatically generated about dialog's website link and display name instead of leaving the documented setting unused.

…dialog

DApplication::handleAboutAction() previously did not call
DAboutDialog::setWebsiteName/setWebsiteLink when auto-creating the
about dialog, so applications could not customize the website row and
always fell back to the distribution default.

This change:
- Wires the existing (previously dead) applicationHomePage property to
  DAboutDialog::setWebsiteLink, fulfilling its documented purpose.
- Adds a new applicationWebsiteName property mapped to
  DAboutDialog::setWebsiteName for the display name.
- Adds Q_PROPERTY declarations for both properties.
- Both are applied only when non-empty, preserving the default
  distribution-fallback behavior.

Closes: DDE-211
@deepin-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743

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 1, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR turns DApplication’s previously unused homepage setting into an effective about-dialog website link and adds an optional website display name, with non-empty overrides preserving distribution defaults and custom about-dialog instances unaffected.

Sequence diagram for customized about dialog website settings

sequenceDiagram
    participant App as DApplication
    participant Dialog as DAboutDialog

    App->>App: handleAboutAction()
    App->>Dialog: setWebsiteLink(applicationHomePage())
    App->>Dialog: setWebsiteName(applicationWebsiteName())
    Dialog-->>App: Display custom values or distribution defaults
Loading

File-Level Changes

Change Details Files
Expose configurable website display metadata on DApplication and wire it into automatically generated about dialogs.
  • Add Q_PROPERTY declarations and getter/setter API for the existing homepage link and new website name.
  • Store the website name in DApplicationPrivate.
  • Apply non-empty homepage and website name values when populating the automatic about dialog, preserving dialog defaults when unset.
  • Document the new property and newly effective homepage behavior.
include/widgets/dapplication.h
src/widgets/dapplication.cpp
src/widgets/private/dapplication_p.h
CHANGELOG.md

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

… fix

Per user feedback (DDE-211): do not add new API, ensure ABI compatibility,
treat as bug fix. Remove the applicationWebsiteName property/methods and
private member added in the previous commit. Only wire up the existing
applicationHomePage() getter in handleAboutAction(): when set (non-empty),
apply it to both the website link and the website display name (same value)
in the about dialog. No new public API, no ABI change.

Fixes DDE-211
@18202781743 18202781743 changed the title feat(DApplication): allow customizing website name/link in the about dialog fix(DApplication): wire up applicationHomePage in about dialog Sep 2, 2026
@deepin-ci-robot

Copy link
Copy Markdown
Contributor

deepin pr auto review

AI 代码审查报告

项目 内容
PR 地址 #778
PR 标题 fix(DApplication): wire up applicationHomePage in about dialog
作者 18202781743
分支 feat/dde-211-custom-website-about-dialog → master
分析模式 全量分析(GitHub PR)
审查时间 2026-09-02 11:14:30

总体评分

维度 评分 满分 结果
语法逻辑 25 25 ✓ 通过
代码质量 23 25 ✓ 通过
代码性能 19 20 ✓ 通过
代码安全 30 30 ✓ 通过
总分 97 100 ✓ 通过

总体评价: 代码审查通过

代码变更简洁明确,正确地将已有的 applicationHomePage() 属性接入关于对话框的网站链接和名称设置。未发现安全漏洞,语法逻辑正确,代码结构清晰。存在轻微的代码质量改进建议和性能优化空间。


提交目的分析

Commit Message: fix(DApplication): wire up applicationHomePage in about dialog as bug fix

Per user feedback (DDE-211): do not add new API, ensure ABI compatibility, treat as bug fix. Remove the applicationWebsiteName property/methods and private member added in the previous commit. Only wire up the existing applicationHomePage() getter in handleAboutAction(): when set (non-empty), apply it to both the website link and the website display name (same value) in the about dialog. No new public API, no ABI change.

Fixes DDE-211

本次提交的目的是Bug 修复:将已有的 applicationHomePage() getter 接入到关于对话框(About Dialog)中,使其能够正确设置网站链接和显示名称。根据用户反馈(DDE-211),不新增公共 API,保持 ABI 兼容性,作为 Bug 修复处理。代码实现与提交目的一致。


修改文件

文件 类型 是否分析
src/widgets/dapplication.cpp C++ 源码 ✓ 分析
CHANGELOG.md 生成文档 ✗ 跳过(自动生成文件)
src/translations/dtkwidget_ar.ts 翻译文件 ✗ 跳过(自动生成文件)
src/translations/dtkwidget_pt.ts 翻译文件 ✗ 跳过(自动生成文件)
src/translations/dtkwidget_sv.ts 翻译文件 ✗ 跳过(自动生成文件)

四维度详细分析

1. 语法逻辑 ✓

评分:25/25 | 评价词:语法正确,逻辑清晰

分析内容:

本次修改在 DApplication::handleAboutAction() 函数中(src/widgets/dapplication.cpp:1453-1456),在关于对话框创建并完成基本配置后、设置感谢页面可见性之前,新增了对 applicationHomePage() 的检查和设置逻辑。

if (!applicationHomePage().isEmpty()) {
    aboutDialog->setWebsiteLink(applicationHomePage());
    aboutDialog->setWebsiteName(applicationHomePage());
}
  • 语法正确,符合 C++ 和 Qt 编码规范
  • applicationHomePage() 返回 QString(内部返回 d->homePage),调用 isEmpty() 进行空值检查逻辑正确
  • setWebsiteLink()setWebsiteName()DAboutDialog 的已有方法,参数类型匹配
  • aboutDialog 在第 1439 行已创建,此处不存在空指针风险
  • 条件判断保证仅在 applicationHomePage() 非空时设置,保留了默认分发回退行为
  • 边界处理完善,无内存泄漏或资源未释放问题

潜在问题:


2. 代码质量 ✓

评分:23/25 | 评价词:代码结构清晰,注释完整

分析内容:

代码放置位置合理,紧接在 applicationAcknowledgementPage 设置之后、acknowledgementVisible 设置之前,与函数中其他属性的设置模式一致。CHANGELOG.md 中有清晰的变更记录。

潜在问题:

  1. src/widgets/dapplication.cpp:1455 - 将 applicationHomePage()(URL 地址)直接用作网站显示名称(setWebsiteName),在关于对话框中会显示原始 URL 作为可点击文本(如 "https://example.com"),用户体验欠佳。通常网站显示名称应为人类可读的标签(如 "My App Homepage")。此问题由 OCR 审查工具同步发现并确认有效,归类为代码质量问题而非安全漏洞。

改进建议:

  1. 考虑不调用 setWebsiteName,让对话框使用默认显示名称
  2. 或从 URL 中提取域名作为显示名称(如从 "https://example.com" 提取 "example.com")
  3. 或保留独立的 applicationWebsiteName 属性以允许设置单独的显示名称
  4. 考虑添加简短注释说明使用 URL 作为显示名称的设计决策原因

3. 代码性能 ✓

评分:19/20 | 评价词:性能良好,资源使用合理

分析内容:

本次修改为简单的属性设置操作,不涉及复杂算法或频繁系统调用,性能影响可忽略。

潜在问题:

  1. src/widgets/dapplication.cpp:1453-1455 - applicationHomePage() 被调用了 3 次(isEmpty() 检查、setWebsiteLinksetWebsiteName)。虽然该 getter 仅返回成员变量 d->homePage,开销极小,但使用局部变量缓存结果可提升代码可读性和微优化性能。

改进建议:

const QString homePage = applicationHomePage();
if (!homePage.isEmpty()) {
    aboutDialog->setWebsiteLink(homePage);
    aboutDialog->setWebsiteName(homePage);
}

4. 代码安全 ✓

存在0个安全漏洞

评分:30/30 | 评价词:安全合规

分析内容:

  • 本次修改不涉及用户输入处理,applicationHomePage() 的值来自应用程序内部配置(通过 setApplicationHomePage() 设置),不存在注入风险
  • 不涉及文件操作、网络请求、命令执行等高风险操作
  • 不涉及敏感信息泄露
  • 不涉及密码学相关操作
  • 不涉及权限控制或认证逻辑

漏洞对比统计: 新增漏洞 0 个,减少漏洞 0 个,持平 0 个

安全漏洞详情:
无安全漏洞


OCR 审查结果

本次审查同步执行了 OpenCodeReview (OCR) 专业代码审查,共发现 3 个问题:

序号 严重程度 问题 处理结果
1 high 将 URL 用作网站显示名称,用户体验不佳 ✓ 有效,归类为代码质量问题
2 high applicationHomePage 的 Q_PROPERTY 被移除 ✗ 误报:头文件在最终 PR diff 中未被修改,中间提交已回退
3 high 同上(私有头文件视角) ✗ 误报:同上

审查结论

本次 PR 代码变更质量优秀,总评分 97 分

  • 代码正确地将已有的 applicationHomePage() 属性接入关于对话框,修复了此前该 API 为"死代码"的问题
  • 实现简洁,仅 4 行新增代码,无新增公共 API,保持 ABI 兼容性
  • 未发现安全漏洞
  • 存在轻微的代码质量改进建议(URL 用作显示名称的 UX 问题)和性能优化空间(getter 多次调用)

建议: 可以合并,建议考虑上述改进建议以进一步提升用户体验。


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

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