Skip to content

fix: fix search icon color inconsistency in DSearchEdit#684

Merged
18202781743 merged 1 commit intolinuxdeepin:masterfrom
18202781743:master
Sep 11, 2025
Merged

fix: fix search icon color inconsistency in DSearchEdit#684
18202781743 merged 1 commit intolinuxdeepin:masterfrom
18202781743:master

Conversation

@18202781743
Copy link
Contributor

The search icon button in DSearchEdit had inconsistent foreground
colors because the action button was drawn by Qt without using the
control's palette foreground color. This change replaces QAction with
QWidgetAction to ensure the search icon inherits the correct palette
colors from the parent widget.

Changed QAction to QWidgetAction and created a DIconButton widget as the
default widget for the action. This allows the search icon to properly
inherit the palette foreground color from DSearchEdit instead of using
Qt's default styling. Also updated all visibility control calls to use
defaultWidget()->setVisible() instead of action->setVisible().

Log: Fixed search icon color inconsistency in search edit controls

Influence:

  1. Test search edit control in different themes to verify icon color
    consistency
  2. Verify search icon visibility transitions during focus changes
  3. Test search functionality remains unchanged
  4. Check accessibility name is preserved for the icon button
  5. Verify placeholder text behavior during mode transitions

fix: 修复DSearchEdit中搜索图标颜色不一致问题

DSearchEdit中的搜索图标按钮存在前景色不一致的问题,因为操作按钮由Qt绘
制,没有使用控件的调色板前景色。本次修改将QAction替换为QWidgetAction,确
保搜索图标正确继承父部件的调色板颜色。

将QAction改为QWidgetAction,并创建DIconButton小部件作为操作的
默认小部件。这使得搜索图标能够正确从DSearchEdit继承调色板前景
色,而不是使用Qt的默认样式。同时更新了所有可见性控制调用,使用
defaultWidget()->setVisible()代替action->setVisible()。

Log: 修复搜索编辑控件中搜索图标颜色不一致问题

Influence:

  1. 在不同主题下测试搜索编辑控件,验证图标颜色一致性
  2. 验证焦点变化时搜索图标可见性转换
  3. 测试搜索功能保持不变
  4. 检查图标按钮的无障碍名称是否保留
  5. 验证模式转换时的占位符文本行为

PMS: BUG-315583

The search icon button in DSearchEdit had inconsistent foreground
colors because the action button was drawn by Qt without using the
control's palette foreground color. This change replaces QAction with
QWidgetAction to ensure the search icon inherits the correct palette
colors from the parent widget.

Changed QAction to QWidgetAction and created a DIconButton widget as the
default widget for the action. This allows the search icon to properly
inherit the palette foreground color from DSearchEdit instead of using
Qt's default styling. Also updated all visibility control calls to use
defaultWidget()->setVisible() instead of action->setVisible().

Log: Fixed search icon color inconsistency in search edit controls

Influence:
1. Test search edit control in different themes to verify icon color
consistency
2. Verify search icon visibility transitions during focus changes
3. Test search functionality remains unchanged
4. Check accessibility name is preserved for the icon button
5. Verify placeholder text behavior during mode transitions

fix: 修复DSearchEdit中搜索图标颜色不一致问题

DSearchEdit中的搜索图标按钮存在前景色不一致的问题,因为操作按钮由Qt绘
制,没有使用控件的调色板前景色。本次修改将QAction替换为QWidgetAction,确
保搜索图标正确继承父部件的调色板颜色。

将QAction改为QWidgetAction,并创建DIconButton小部件作为操作的
默认小部件。这使得搜索图标能够正确从DSearchEdit继承调色板前景
色,而不是使用Qt的默认样式。同时更新了所有可见性控制调用,使用
defaultWidget()->setVisible()代替action->setVisible()。

Log: 修复搜索编辑控件中搜索图标颜色不一致问题

Influence:
1. 在不同主题下测试搜索编辑控件,验证图标颜色一致性
2. 验证焦点变化时搜索图标可见性转换
3. 测试搜索功能保持不变
4. 检查图标按钮的无障碍名称是否保留
5. 验证模式转换时的占位符文本行为

PMS: BUG-315583
@18202781743 18202781743 requested review from BLumia and mhduiy September 8, 2025 07:53
deepin-ci-robot added a commit to linuxdeepin/dtk6widget that referenced this pull request Sep 8, 2025
Synchronize source files from linuxdeepin/dtkwidget.

Source-pull-request: linuxdeepin/dtkwidget#684
@deepin-ci-robot
Copy link
Contributor

deepin pr auto review

这段代码是对DSearchEdit组件的修改,主要改进了搜索按钮的实现方式。以下是我的审查意见:

语法逻辑

  1. 代码整体逻辑清晰,但有一些细节可以优化:
    • 将创建搜索按钮的逻辑封装到了lambda函数createSearchIconButton中,提高了代码复用性,这是个好的改进。
    • 将原来的QAction改为QWidgetAction,这样可以更灵活地控制按钮的显示和隐藏。

代码质量

  1. 优点:

    • 使用lambda函数封装按钮创建逻辑,提高了代码的可读性和可维护性。
    • 通过QWidgetAction封装按钮组件,使得代码结构更加清晰。
  2. 可改进之处:

    • createSearchIconButton lambda函数可以提取为类的私有方法,这样如果需要在其他地方复用会更加方便。
    • _q_toEditMode函数中多次调用action->defaultWidget()->setVisible(true/false),可以考虑将这些操作封装成一个私有方法。

代码性能

  1. 性能方面没有明显问题,但有以下建议:
    • 当前每次切换编辑模式时都会访问defaultWidget(),可以考虑在初始化时保存这个widget的指针,避免重复查找。
    • 动画相关的操作已经使用了QPropertyAnimation,这是比较高效的方式。

代码安全

  1. 安全性方面:
    • 代码中没有明显的安全隐患,但需要注意QWidgetAction的生命周期管理,确保其不会在父对象被删除前被提前释放。
    • 在设置图标和可见性时,应该确保相关对象已经被正确初始化。

其他建议

  1. 可以考虑添加更多的注释,说明为什么从QAction改为QWidgetAction,以及这种改变带来的好处。
  2. 在头文件中添加QWidgetAction的前向声明是个好的做法,但也可以考虑在对应的源文件中包含完整的定义,以提高代码的可维护性。
  3. 可以考虑将按钮的尺寸(20x20)定义为常量,而不是直接写在代码中,这样便于后续修改和维护。

总体来说,这次修改提高了代码的可维护性和灵活性,是一个积极的改进。建议在后续的开发中继续保持这种良好的编码习惯。

@deepin-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743, BLumia

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

@18202781743 18202781743 merged commit d08e74d into linuxdeepin:master Sep 11, 2025
22 of 23 checks passed
18202781743 pushed a commit to linuxdeepin/dtk6widget that referenced this pull request Sep 11, 2025
Synchronize source files from linuxdeepin/dtkwidget.

Source-pull-request: linuxdeepin/dtkwidget#684
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

Comments