Skip to content

feat(ui): update button appearance by setting ColorSelector inactive …#504

Open
add-uos wants to merge 1 commit intolinuxdeepin:masterfrom
add-uos:master
Open

feat(ui): update button appearance by setting ColorSelector inactive …#504
add-uos wants to merge 1 commit intolinuxdeepin:masterfrom
add-uos:master

Conversation

@add-uos
Copy link

@add-uos add-uos commented Feb 11, 2026

…state

Set D.ColorSelector.inactived: false on buttons and input fields across update module QML files to ensure consistent visual appearance and prevent unintended inactive styling.

log: button appearance by setting ColorSelector inactive state
bug: PMS-298841

…state

Set D.ColorSelector.inactived: false on buttons and input fields
across update module QML files to ensure consistent visual
appearance and prevent unintended inactive styling.

log: button appearance by setting ColorSelector inactive state
bug: PMS-298841
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.

Sorry @add-uos, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: add-uos

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

@deepin-ci-robot
Copy link

deepin pr auto review

这段代码的修改主要是为了统一和修复 Deepin DTK (Deepin Tool Kit) 控件库中的颜色主题行为。通过在各个控件(如 Button, LineEdit, ItemDelegate)中添加 D.ColorSelector.inactived: false,确保这些控件即使在非活动状态下也能保持正常的颜色显示,而不是变灰。

以下是对这段 diff 的详细审查和改进意见:

1. 语法逻辑审查

  • 主要变更:在多个 QML 文件中,为 ButtonD.LineEditD.ItemDelegate 等控件添加了 D.ColorSelector.inactived: false 属性。
  • 逻辑分析
    • D.ColorSelector 是 DTK 提供的附加属性,用于动态选择颜色。
    • inactived 属性控制控件在非活动状态下的颜色表现。将其设置为 false 意味着即使窗口失去焦点(非活动),这些控件也不应呈现为"非活动"(通常是灰色)的样式,而是保持正常颜色。
    • 这解决了用户在切换窗口或操作其他应用时,网络设置界面的输入框和按钮看起来像被禁用(变灰)的视觉问题,提升了用户体验。
  • 潜在问题:在 SectionIPv6.qml 中有一处拼写错误:
    +            D.ColorSelector.inactived: falsegit
    这里行尾多了一个 "git" 字符串,这会导致 QML 语法错误,必须修复。

2. 代码质量审查

  • 重复代码:修改涉及大量文件,且在每个控件中重复添加 D.ColorSelector.inactived: false。虽然这是必要的修改,但显得有些冗余。
  • 一致性:修改非常一致,对所有相关的 UI 控件都进行了相同的处理,保证了界面风格统一。
  • 拼写错误:如上所述,SectionIPv6.qml 中的 falsegit 是明显的代码质量问题,属于复制粘贴或提交时的错误。

3. 代码性能审查

  • 性能影响:添加布尔属性绑定对性能的影响微乎其微。D.ColorSelector 内部处理颜色选择,设置 inactived 主要是改变了颜色查找的逻辑路径,不会引起频繁的重绘或大量的计算。
  • 结论:此修改对性能无负面影响。

4. 代码安全审查

  • 安全性:此修改仅涉及 UI 表现层(QML),不涉及后端逻辑、数据处理或网络通信,因此没有引入新的安全风险。
  • 稳定性:唯一的稳定性风险是 SectionIPv6.qml 中的拼写错误,这会导致该文件无法加载,进而导致 IPv6 设置页面崩溃或无法显示。

5. 改进意见

  1. 修复拼写错误(必须)
    dcc-network/qml/SectionIPv6.qml 文件中,找到以下行:

    D.ColorSelector.inactived: falsegit

    修改为:

    D.ColorSelector.inactived: false
  2. 考虑使用样式继承或自定义组件(可选/优化)
    为了减少代码重复并便于维护,可以考虑以下两种优化方案之一:

    • 方案 A(自定义基类组件):创建一个自定义的 D.LineEditButton 子组件(例如 NetLineEdit),在该组件中统一设置 D.ColorSelector.inactived: false,然后在各个页面中使用这个自定义组件替代原始的 D.LineEdit
      // NetLineEdit.qml
      import org.deepin.dtk 1.0 as D
      D.LineEdit {
          D.ColorSelector.inactived: false
          // 其他通用配置...
      }
    • 方案 B(全局样式/主题):检查 DTK 是否支持通过全局主题或样式表来配置 ColorSelector 的默认行为。如果支持,在应用初始化时统一设置会更优雅,但这取决于 DTK 的 API 能力。
  3. 代码审查检查点

    • 建议在代码合并前,重点检查 SectionIPv6.qml 文件,确保 "git" 后缀已被移除。
    • 建议进行手动测试,特别是窗口切换场景,确认控件颜色行为符合预期(即非活动窗口中控件不再变灰)。

总结

这段代码的主要目的是改进 UI 在非活动状态下的视觉反馈,逻辑是合理的,但包含一个关键的语法错误(falsegit)。修复该错误后,代码是安全且有效的。从长远维护角度看,建议通过封装自定义组件来减少这种重复性的属性设置。

import QtQuick 2.15
import QtQuick.Controls 2.15

import org.deepin.dtk 1.0 as D
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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