Repository navigation
fix: adapt search edit icon size to size mode - #798
Draft
GongHeng2017 wants to merge 1 commit into
Draft
GongHeng2017 wants to merge 1 commit into
GongHeng2017 wants to merge 1 commit into
Conversation
GongHeng2017
marked this pull request as draft
October 29, 2026 20:55
Contributor
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: GongHeng2017 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideUpdates DSearchEdit to use DSizeModeHelper for compact/normal search icon sizing and connects to sizeModeChanged so both icon-button instances stay synchronized when the application size mode changes. Sequence diagram for dynamic DSearchEdit icon sizingsequenceDiagram
participant DSearchEdit
participant DGuiApplicationHelper
participant DSizeModeHelper
participant iconbtn
participant iconAction
DSearchEdit->>DSizeModeHelper: element(QSize(16, 16), QSize(20, 20))
DSizeModeHelper-->>DSearchEdit: iconSize
DSearchEdit->>iconbtn: setIconSize(iconSize)
DSearchEdit->>iconAction: setIconSize(iconSize)
DSearchEdit->>DGuiApplicationHelper: connect(sizeModeChanged, updateIconSize)
DGuiApplicationHelper-->>DSearchEdit: sizeModeChanged
DSearchEdit->>DSizeModeHelper: element(QSize(16, 16), QSize(20, 20))
DSizeModeHelper-->>DSearchEdit: iconSize
DSearchEdit->>iconbtn: setIconSize(iconSize)
DSearchEdit->>iconAction: setIconSize(iconSize)
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
1. Root cause: DSearchEditPrivate::init() hardcoded icon size to QSize(20, 20) without DSizeMode awareness, causing oversized icon in compact mode 2. Fix: use DSizeModeHelper::element() for adaptive sizing and connect sizeModeChanged signal for dynamic updates 3. Impact: all DSearchEdit instances now adapt icon size to compact/normal mode Log: Fix search edit icon not adapting to compact mode Influence: 1. Test DSearchEdit icon display in normal mode 2. Test DSearchEdit icon display in compact mode 3. Verify icon updates when switching size modes at runtime fix: 搜索框图标尺寸适配紧凑模式 1. 根因:DSearchEditPrivate::init() 硬编码图标尺寸为 QSize(20, 20),不随 DSizeMode 自适应 2. 方案:使用 DSizeModeHelper::element() 实现自适应尺寸, 并监听 sizeModeChanged 信号动态更新 3. 影响:所有 DSearchEdit 实例的图标尺寸将随紧凑/正常模式自适应 Log: 修复搜索框图标在紧凑模式下过大的问题 Influence: 1. 测试正常模式下搜索框图标显示 2. 测试紧凑模式下搜索框图标显示 3. 验证运行时切换尺寸模式时图标是否动态更新 PMS: BUG-224407
GongHeng2017
force-pushed
the
fix/search-edit-icon-size-dtkwidget
branch
from
October 29, 2026 21:22
e5484ed to
454516e
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root Cause Analysis
DSearchEdit's search icon button size is hardcoded to QSize(20, 20) in DSearchEditPrivate::init() via createSearchIconButton lambda (src/widgets/dsearchedit.cpp:303). This value does not adapt to DSizeMode (compact/normal), causing the magnifying glass icon to appear oversized when the application is in compact mode. The same issue applies to both icon button instances: the visible search icon (iconbtn) and the leading-position action widget (iconAction).
Fix
Replace the hardcoded QSize(20, 20) with DSizeModeHelper::element(QSize(16, 16), QSize(20, 20)) so the icon size adapts to compact mode (16x16) vs normal mode (20x20). Additionally, connect DGuiApplicationHelper::sizeModeChanged signal to dynamically update both icon buttons when the size mode switches at runtime. This follows the same pattern used in dfloatingmessage.cpp and dfilechooseredit.cpp.
Change Safety Assessment
Code Safety
Business Impact Scope
All DSearchEdit instances across applications (e.g., file manager, control center) will now adapt search icon size to the current size mode. In compact mode, the magnifying glass icon will be 16x16 instead of 20x20, consistent with compact mode visual density. Switching size mode at runtime will dynamically update the icon.
Verification Suggestion
Verify DSearchEdit icon display in both normal and compact modes, and confirm dynamic update when switching size modes at runtime.
根因分析
DSearchEdit 的搜索图标按钮尺寸在 DSearchEditPrivate::init() 的 createSearchIconButton lambda 中被硬编码为 QSize(20, 20)(src/widgets/dsearchedit.cpp:303),不随 DSizeMode 自适应,导致紧凑模式下放大镜图标过大。两个图标按钮实例(iconbtn 和 iconAction)均存在此问题。
修复方案
将硬编码的 QSize(20, 20) 替换为 DSizeModeHelper::element(QSize(16, 16), QSize(20, 20)),使图标尺寸随紧凑模式(16x16)和正常模式(20x20)自适应。同时连接 DGuiApplicationHelper::sizeModeChanged 信号,在运行时切换尺寸模式时动态更新两个图标按钮的尺寸。此方案与 dfloatingmessage.cpp 和 dfilechooseredit.cpp 中的实现模式一致。
改动安全评估
代码安全评估
业务影响范围
所有使用 DSearchEdit 控件的应用(如文件管理器、控制中心等)的搜索框图标将随尺寸模式自适应。紧凑模式下放大镜图标为 16x16(原为 20x20),与紧凑模式视觉密度一致。运行时切换尺寸模式时图标将动态更新。
验证建议
验证正常模式和紧凑模式下搜索框图标显示,并确认运行时切换尺寸模式时图标是否动态更新。
PMS: BUG-224407
Summary by Sourcery
Bug Fixes: