Skip to content

feat: add ComboBox blur preference#626

Closed
fly602 wants to merge 1 commit into
linuxdeepin:masterfrom
fly602:master
Closed

feat: add ComboBox blur preference#626
fly602 wants to merge 1 commit into
linuxdeepin:masterfrom
fly602:master

Conversation

@fly602
Copy link
Copy Markdown

@fly602 fly602 commented May 26, 2026

  1. Add a DTK configuration binding in ComboBox.qml using org.deepin.dtk.preference
  2. Introduce the enableComboBoxBlur boolean preference with a default value of true
  3. Bind the popup menu's enableBlur property to the new configuration so the ComboBox dropdown blur effect can be turned on or off dynamically
  4. This change makes the dropdown visual effect configurable, allowing environments or users with different performance or visual preference requirements to control blur behavior without modifying component logic

Log: Added a configurable blur effect option for ComboBox dropdowns

Influence:

  1. Verify that ComboBox dropdowns still display blur by default when no custom preference is set
  2. Disable enableComboBoxBlur in org.deepin.dtk.preference and confirm the dropdown background renders without blur
  3. Re-enable the preference and confirm the blur effect is restored immediately or after expected configuration reload timing
  4. Test multiple ComboBox instances to ensure the configuration is applied consistently across all dropdown menus
  5. Verify no regression in dropdown rendering, sizing, radius, background color, and open/close interaction
  6. Check behavior on low-performance or blur-unsupported environments to confirm the dropdown degrades gracefully

feat: 新增 ComboBox 模糊效果配置

  1. 在 ComboBox.qml 中新增 DTK 配置绑定,使用 org.deepin.dtk.preference 配置项
  2. 引入 enableComboBoxBlur 布尔配置项,默认值为 true
  3. 将下拉弹出菜单的 enableBlur 属性绑定到该配置,使 ComboBox 下拉框模糊 效果可以动态开启或关闭
  4. 该变更将下拉视觉效果改为可配置项,便于在不同性能环境或不同用户视觉偏 好下控制模糊行为,而无需修改组件本身逻辑

Log: 为 ComboBox 下拉框新增可配置的模糊效果选项

Influence:

  1. 验证在未设置自定义偏好时,ComboBox 下拉框默认仍会显示模糊效果
  2. 在 org.deepin.dtk.preference 中关闭 enableComboBoxBlur,确认下拉框背 景渲染为无模糊效果
  3. 重新开启该配置,确认模糊效果可立即恢复或按预期的配置刷新时机恢复
  4. 测试多个 ComboBox 实例,确保所有下拉菜单都能一致应用该配置
  5. 验证下拉框渲染、尺寸、圆角、背景色以及展开/收起交互没有回归
  6. 检查在低性能环境或不支持模糊的环境下的表现,确认下拉框能够平滑降级

PMS: BUG-358837
Change-Id: Ifd7255009fa87539481ebb515f93f89ac5958ce5

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.

Sorry @fly602, 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
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: fly602

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

1. Added new `hasInWindowBlur` property to `DQMLGlobalObject` for QML
access
2. Updated InWindowBlur component to use `hasInWindowBlur` for blur
disabling
3. Updated debian/control with minimum version requirements for dtk
dependencies
4. Changed copyright year to 2023-2026

Log: Added hasInWindowBlur QML property for blur availability check

Influence:
1. Test hasInWindowBlur property returns correct boolean on various
platforms
2. Verify InWindowBlur component disables blur when hasInWindowBlur
is false
3. Test build and installation with different dtk versions
4. Verify version dependency requirements in debian/control
5. Test blur rendering behavior with software renderer
6. Verify signal emission when hasInWindowBlur changes

feat: 添加 hasInWindowBlur QML 属性和版本依赖

1. 为 DQMLGlobalObject 添加了新的 hasInWindowBlur 属性供 QML 访问
2. 更新 InWindowBlur 组件使用 hasInWindowBlur 来控制模糊效果开关
3. 更新 debian/control 文件增加 dtk 依赖的最低版本要求
4. 将版权年份更新为 2023-2026

Log: 新增 hasInWindowBlur QML 属性用于检测模糊可用性

Influence:
1. 测试 hasInWindowBlur 属性在不同平台上返回正确布尔值
2. 验证当 hasInWindowBlur 为 false 时 InWindowBlur 组件正确关闭模糊效果
3. 测试不同 dtk 版本下的构建和安装
4. 验证 debian/control 中的版本依赖要求
5. 测试配合软件渲染器时模糊效果的行为
6. 验证 hasInWindowBlur 变化时信号正确发射

PMS: TASK-390117
@deepin-ci-robot
Copy link
Copy Markdown
Contributor

deepin pr auto review

你好!我是CodeGeeX。我已仔细审查了你提供的 Git Diff。本次修改主要涉及三个方面:Debian 打包依赖版本约束更新、版权声明年份更新、以及为 DTK 新增 hasInWindowBlur 属性并在 QML 中使用该属性来控制窗口内模糊效果。

以下是针对语法逻辑、代码质量、代码性能和代码安全四个维度的详细审查意见和改进建议:

1. 语法与逻辑

  • Q_PROPERTY 的 NOTIFY 信号缺失实现 (严重)

    • 问题:在 dqmlglobalobject_p.h 中,新增了 Q_PROPERTY(bool hasInWindowBlur READ hasInWindowBlur NOTIFY hasInWindowBlurChanged),并在 signals 区域声明了 void hasInWindowBlurChanged();。但是,在 dqmlglobalobject.cpphasInWindowBlur() 函数实现中,并没有任何触发 (emit) 该信号的逻辑。如果 HasInWindowBlur 这个属性在运行期间发生变化,QML 层将无法得到通知,导致 UI 状态不同步。
    • 建议:需要确认 DGuiApplicationHelper::HasInWindowBlur 属性是否为运行时可变。如果可变,需要在 C++ 层监听 DGuiApplicationHelper 的属性变化并 emit hasInWindowBlurChanged();;如果该属性在应用启动后终生不变(像 isSoftwareRender 一样),建议将属性声明为 CONSTANT,即:Q_PROPERTY(bool hasInWindowBlur READ hasInWindowBlur CONSTANT),并移除 NOTIFY hasInWindowBlurChanged 信号声明。
  • 函数静态属性与 Q_PROPERTY 的潜在冲突

    • 问题:在头文件中,hasInWindowBlur() 被声明为 static bool hasInWindowBlur();,而 hasAnimation() 也是 static 的。但是 Q_PROPERTY 系统是基于 QObject 实例的,通常 READ 函数不应为 static(尽管 Qt5/6 允许在语法上通过,但这违反了面向对象的设计原则,且容易导致后续维护混乱)。
    • 建议:如果该属性与特定对象实例无关,建议去掉函数的 static 修饰符,改为普通的 bool hasInWindowBlur() const;,保持与 Q_PROPERTY 的一致性。
  • Debian 依赖版本运算符使用不规范 (debian/control)

    • 问题libdtk6gui-dev (>> 6.7.42) 使用了 >> 运算符。在 Debian 控制文件规范中,>> 表示“严格大于且不包括该版本”,这通常不是预期的行为。一般我们希望包含该版本及以后的版本。
    • 建议:如果希望版本 >= 6.7.42,应该使用 >= 运算符,即修改为:libdtk6gui-dev (>= 6.7.42)libdtkcommon-dev (>= 6.7.42)

2. 代码质量

  • QML 逻辑判断的健壮性
    • 问题:在 InWindowBlur.qml 中,修改为 blitterEnabled: !D.DTK.isSoftwareRender && D.DTK.hasInWindowBlur。逻辑上没问题,但需确保 D.DTK.hasInWindowBlur 在 QML 上下文中是可靠可访问的。由于 hasInWindowBlur 是新增属性,需确保 QML 引擎启动时该值已正确初始化,否则可能出现短暂的闪烁(默认值通常为 false,随后变为 true)。
    • 建议:结合上面提到的 CONSTANT 属性,如果该值是启动时确定的,使用 CONSTANT 可以让 QML 引擎在初始化时就确定值,避免不必要的属性绑定评估和更新。

3. 代码性能

  • 属性查询的缓存优化
    • 问题hasInWindowBlur() 内部调用了 DGuiApplicationHelper::testAttribute(DGuiApplicationHelper::HasInWindowBlur)。对比同文件中的 isSoftwareRender(),后者使用了 static bool isSoftware = ... 进行了进程级别的缓存,因为渲染后端启动后不会变。
    • 建议:如果 HasInWindowBlur 也是启动后不再变化的属性,建议参考 isSoftwareRender() 的实现,加上 static 缓存,避免每次 QML 评估绑定时的函数调用开销:
      bool DQMLGlobalObject::hasInWindowBlur()
      {
          static bool hasBlur = DGuiApplicationHelper::testAttribute(DGuiApplicationHelper::HasInWindowBlur);
          return hasBlur;
      }

4. 代码安全

  • 版权年份的过度预测
    • 问题InWindowBlur.qml 中的版权声明从 2023 修改为了 2023 - 2026。包含未来的年份在开源协议和版权声明中通常是不推荐的,因为版权保护期是基于实际发表/修改年份的,提前写未来的年份缺乏法律依据且可能引发合规扫描工具的警告。
    • 建议:如果今年是 2024 年且你正在修改该文件,建议改为 2023 - 2024;如果只是今年修改,也可以直接写 2024,或者让 CI/CD 工具在发布时自动更新年份。

综合修改建议代码片段

1. C++ 头文件 (dqmlglobalobject_p.h)

// 假设该属性运行时不变,建议移除 NOTIFY 并改为 CONSTANT,移除函数的 static
Q_PROPERTY(bool hasInWindowBlur READ hasInWindowBlur CONSTANT)
// ...
bool hasInWindowBlur() const; // 移除 static
// ...
// 移除 void hasInWindowBlurChanged(); 信号声明

2. C++ 源文件 (dqmlglobalobject.cpp)

bool DQMLGlobalObject::hasInWindowBlur() const // 移除 static
{
    // 引入 static 缓存,提升性能
    static bool hasBlur = DGuiApplicationHelper::testAttribute(DGuiApplicationHelper::HasInWindowBlur);
    return hasBlur;
}

3. Debian 控制文件 (debian/control)

- libdtk6gui-dev (>> 6.7.42),
- libdtkcommon-dev (>> 6.7.42),
+ libdtk6gui-dev (>= 6.7.42),
+ libdtkcommon-dev (>= 6.7.42),

4. QML 文件 (InWindowBlur.qml)

- // SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd.
+ // SPDX-FileCopyrightText: 2023 - 2024 UnionTech Software Technology Co., Ltd.

@fly602 fly602 closed this May 28, 2026
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