Skip to content

style(qml): optimize UI styling and fix copyright year#525

Merged
deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
add-uos:fix-353881
Mar 21, 2026
Merged

style(qml): optimize UI styling and fix copyright year#525
deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
add-uos:fix-353881

Conversation

@add-uos
Copy link
Contributor

@add-uos add-uos commented Mar 21, 2026

Correct SPDX copyright year from 2024-2027 to 2024-2026 and optimize label styling in network settings pages.

修正SPDX版权年份并优化网络设置页面的标签样式。

Log: 修正版权年份并优化UI样式
PMS: BUG-353881
Influence: 优化网络设置页面的UI显示效果,修正版权信息错误。

Summary by Sourcery

Update network settings QML pages to refine label typography and correct SPDX copyright metadata.

Enhancements:

  • Adjust label fonts, weights, colors, and padding in network settings pages to improve visual consistency and readability.

Chores:

  • Correct SPDX copyright year ranges from 2024–2027 to 2024–2026 in affected QML files.

Correct SPDX copyright year from 2024-2027 to 2024-2026 and optimize
label styling in network settings pages.

修正SPDX版权年份并优化网络设置页面的标签样式。

Log: 修正版权年份并优化UI样式
PMS: BUG-353881
Influence: 优化网络设置页面的UI显示效果,修正版权信息错误。
@deepin-ci-robot
Copy link

deepin pr auto review

这段代码主要涉及QML界面的样式调整和版权年份的更新。以下是对代码的审查意见,分为语法逻辑、代码质量、代码性能和代码安全四个方面:

1. 语法逻辑

  • 版权年份修改:

    • 问题: 在所有文件中,版权年份从 2024 - 2027 修改为 2024 - 2026
    • 意见: 这是一个合理的修改,可能是根据项目规划调整了支持周期。逻辑上没有问题。
  • PageDetails.qml 中的字体和颜色变更:

    • 变更: DccLabel 的字体大小从 t4 改为 t5,字重属性从 "bold": true 改为 "weight": 500。同时引入了 textColor 属性来定义颜色,并使用 D.ColorSelector.textColor 应用它。
    • 意见:
      • 逻辑上,将显式的 bold 布尔值改为具体的数字字重 500 (Medium) 是更精确的做法,符合现代字体排版的规范。
      • 引入 D.Palette 并通过 ColorSelector 绑定颜色,实现了对深色/浅色主题的动态适配,逻辑正确。
  • SectionDNS/IPv4/IPv6.qml 中的样式微调:

    • 变更: 给 "Edit"/"Done" 标签添加了 bottomPadding: 0font.pixelSize: D.DTK.fontManager.t8.pixelSize
    • 意见: 逻辑上是为了统一文本样式和消除默认的内边距,使其对齐更精确,逻辑合理。

2. 代码质量

  • 硬编码颜色值:

    • 问题: 在 PageDetails.qml 中,textColor 属性内直接硬编码了 RGBA 值:Qt.rgba(0, 0, 0, 0.9)Qt.rgba(1, 1, 1, 0.9)
    • 改进建议: 虽然代码使用了 D.Palette 进行封装,但具体的颜色值仍然是硬编码的。如果可能,建议检查 D.DTK (Deepin Tool Kit) 是否已经提供了标准的文本颜色常量(如 D.ColorSelector.textNormalColor 等)。使用框架提供的标准颜色常量可以更好地保证UI的一致性,并在未来框架更新主题时自动适配,减少维护成本。
  • 字体属性定义:

    • 问题: font: DccUtils.copyFont(...) 这种写法在 QML 中创建了一个新的字体对象。
    • 改进建议: 这种写法是可接受的,但需确保 DccUtils.copyFont 不会在每次绑定更新时产生不必要的对象分配。如果 displayName 频繁变化,可能会有性能影响(详见性能部分)。

3. 代码性能

  • 属性绑定与对象创建:

    • 问题: 在 PageDetails.qml 中,DccLabel 内部定义了一个 property D.Palette textColor。这意味着每个 DccLabel 实例都会创建一个 D.Palette 对象。
    • 改进建议: 如果这个颜色配置是全局通用的(例如所有详情页的标题颜色都一样),建议将 textColor 定义在单例对象或更高层级的组件中,而不是在每个 Label 实例中重复创建。这能减少内存占用和初始化开销。
  • 字体大小绑定:

    • 问题: 在 SectionDNS.qml 等文件中,使用了 font.pixelSize: D.DTK.fontManager.t8.pixelSize
    • 改进建议: 直接绑定 pixelSize 是高效的。但如果 D.DTK.fontManager.t8 本身是一个复杂对象,确保其访问性能良好。通常这不是大问题,但在性能敏感的列表渲染中需注意。

4. 代码安全

  • 输入验证:

    • 问题: 代码中使用了 dccObj.displayName
    • 意见: QML 的 Text 元素通常会自动处理字符串,基本不存在 XSS 或注入风险。但需确保 dccObj 不为 null,否则可能会导致运行时错误。建议在 dccObj 可能未初始化的地方添加判空保护(例如 text: dccObj ? dccObj.displayName : ""),尽管在 DccObject 的上下文中通常已由框架保证。
  • 版权声明:

    • 意见: 修改版权年份是合规操作,无安全风险。

总结建议

这段代码主要是UI样式的规范化调整,整体逻辑清晰。主要的改进点在于:

  1. 去硬编码化: 建议将 PageDetails.qml 中的 Qt.rgba 硬编码颜色替换为 DTK 框架提供的标准颜色常量(如果存在),以增强主题适配性。
  2. 对象复用: 考虑将通用的 textColor Palette 定义提升到全局或单例中,避免在每个 Label 实例中重复创建相同的对象。
  3. 空值保护: 虽然在当前上下文中可能不是必须的,但保持对 dccObj 的空值检查意识是一个好习惯。

@sourcery-ai
Copy link

sourcery-ai bot commented Mar 21, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjusts SPDX copyright years and refines label styling in several network settings QML pages for more consistent typography and spacing.

File-Level Changes

Change Details Files
Align page header label styling in network details page with design system typography and color tokens.
  • Switch header font base from t4 bold to t5 with medium (weight 500) styling using DccUtils.copyFont
  • Introduce a D.Palette-based textColor property with distinct normal/normalDark RGBA values for light/dark modes
  • Bind label color to D.ColorSelector.textColor instead of implicit defaults
  • Keep left alignment and full-width layout while preserving elide behavior for long titles
dcc-network/qml/PageDetails.qml
Normalize the appearance of "Edit/Done" action labels in network configuration sections.
  • Remove extra bottom spacing on action labels by setting bottomPadding to 0
  • Explicitly set action label font size using D.DTK.fontManager.t8.pixelSize for consistent typography across sections
  • Apply these style adjustments in DNS, IPv4, and IPv6 sections while preserving existing visibility and interaction behavior
dcc-network/qml/SectionDNS.qml
dcc-network/qml/SectionIPv4.qml
dcc-network/qml/SectionIPv6.qml
Correct SPDX copyright year range in QML files.
  • Update SPDX-FileCopyrightText range from 2024-2027 to 2024-2026 to match legal requirements
dcc-network/qml/PageDetails.qml
dcc-network/qml/SectionDNS.qml
dcc-network/qml/SectionIPv4.qml
dcc-network/qml/SectionIPv6.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 - I've left some high level feedback:

  • The DccLabel in PageDetails.qml defines a textColor palette property but sets color to D.ColorSelector.textColor; consider wiring the label color to the new palette entry (or removing it) to avoid unused or confusing styling configuration.
  • The "Done/Edit" Label styling (bottomPadding and font.pixelSize from t8) is duplicated across SectionDNS.qml, SectionIPv4.qml, and SectionIPv6.qml; consider extracting this into a shared component or style helper to keep the UI consistent and easier to maintain.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `DccLabel` in `PageDetails.qml` defines a `textColor` palette property but sets `color` to `D.ColorSelector.textColor`; consider wiring the label color to the new palette entry (or removing it) to avoid unused or confusing styling configuration.
- The "Done/Edit" `Label` styling (bottomPadding and `font.pixelSize` from `t8`) is duplicated across `SectionDNS.qml`, `SectionIPv4.qml`, and `SectionIPv6.qml`; consider extracting this into a shared component or style helper to keep the UI consistent and easier to maintain.

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: add-uos, 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

@add-uos
Copy link
Contributor Author

add-uos commented Mar 21, 2026

/forcemerge

@deepin-bot
Copy link
Contributor

deepin-bot bot commented Mar 21, 2026

This pr force merged! (status: unstable)

@deepin-bot deepin-bot bot merged commit 3af62ca into linuxdeepin:master Mar 21, 2026
17 of 19 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