Repository navigation
fix: replace QIcon(svg) with DDciIcon for icon aliasing under Wayland fractional scaling - #100
tianming-1996 wants to merge 1 commit into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: tianming-1996 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 GuideThe PR fixes blurry titlebar icons under Wayland fractional scaling by replacing direct SVG loading with a themed Sequence diagram for fractional-DPR titlebar icon renderingsequenceDiagram
participant MainWidget
participant DDciIcon
participant App
participant Titlebar
MainWidget->>DDciIcon: pixmap(App->devicePixelRatioF(), 32, theme)
DDciIcon-->>MainWidget: themed high-resolution QPixmap
MainWidget->>App: setWindowIcon(QIcon(pixmap))
MainWidget->>Titlebar: setIcon(QIcon(pixmap))
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
CLA Assistant Lite bot: deepin seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. |
… fractional scaling 1. Root cause: QIcon(svg) renders via DStyle SI_QIcon path which does not pass devicePixelRatioF(), 32x32 physical pixels upscaled to 48x48 under Wayland fractional scaling 2. Fix: create appicon.dci (DCI format) with dark/light themes at 3x scale, use DDciIcon::pixmap() to render at correct DPR before wrapping in QIcon for setWindowIcon/titlebar setIcon 3. Cleanup: update SPDX copyright year to 2022-2026, remove unused appicon_dark.svg and appicon_light.svg from resource.qrc 4. Impact: titlebar icon renders at correct physical pixel size under Wayland fractional scaling, no aliasing Log: fix OCR app icon aliasing under Wayland fractional scaling Influence: 1. Test icon display at 1x/1.25x/1.5x/2x scaling on Wayland 2. Verify icon in both dark and light themes 3. Check icon when switching theme at runtime fix: 修复Wayland分数缩放下OCR标题栏图标锯齿问题 1. 根因:QIcon(svg)经DStyle的SI_QIcon路径渲染,未传递 devicePixelRatioF(),32x32物理像素被放大到48x48产生锯齿 2. 方案:创建appicon.dci(DCI格式,含深色/浅色主题,3倍缩放), 使用DDciIcon::pixmap()按正确DPR渲染后包装为QIcon 3. 清理:更新SPDX版权年份至2022-2026,移除resource.qrc中 已无引用的appicon_dark.svg和appicon_light.svg 4. 影响:标题栏图标在Wayland分数缩放下按正确物理像素渲染, 消除锯齿 Log: 修复OCR识别图标在Wayland分数缩放下锯齿严重的问题 Influence: 1. 测试Wayland下1x/1.25x/1.5x/2x缩放的图标显示 2. 验证深色和浅色主题下的图标 3. 检查运行时切换主题时的图标显示 PMS: BUG-193447
b42c8d1 to
9539bba
Compare
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 语法正确,逻辑清晰 ✅ 通过 潜在问题: 建议: ['无需修改,语法逻辑完全正确。'] 2. 代码质量 ✅评价: 代码结构清晰,存在轻微重复代码 ✅ 通过 潜在问题: 建议: ['可将 DDciIcon 对象的创建提升到 if/else 分支之前,避免重复创建;或在分支内仅确定主题参数后统一调用,减少重复代码。例如:先创建 DDciIcon appDci,再根据 themeType 选择 DDciIcon::Theme,最后统一生成 pixmap。'] 3. 代码性能 ✅评价: 性能良好,存在轻微优化空间 ✅ 通过 潜在问题: 建议: ['在每个分支内将 pixmap 结果保存到局部变量,复用于 setWindowIcon 和 titlebar->setIcon,避免重复生成。例如:QPixmap iconPixmap = appDci.pixmap(App->devicePixelRatioF(), 32, DDciIcon::Theme::Dark); App->setWindowIcon(QIcon(iconPixmap)); ... mainWindow->titlebar()->setIcon(QIcon(iconPixmap));'] 4. 代码安全 🔒评价: 存在0个安全漏洞 ✅ 通过
安全漏洞详情: 建议: ['无安全风险,无需额外安全加固。'] 💡 改进建议代码示例// 优化示例:减少重复代码和重复 pixmap 生成
void MainWidget::setIcons(DGuiApplicationHelper::ColorType themeType)
{
// ... 前置代码不变 ...
DDciIcon appDci(QStringLiteral(":/assets/appicon.dci"));
DDciIcon::Theme dciTheme = (themeType == DGuiApplicationHelper::DarkType)
? DDciIcon::Theme::Dark
: DDciIcon::Theme::Light;
QPixmap iconPixmap = appDci.pixmap(App->devicePixelRatioF(), 32, dciTheme);
App->setWindowIcon(QIcon(iconPixmap));
DMainWindow *mainWindow = static_cast<DMainWindow *>(this->parent());
if (mainWindow) {
mainWindow->titlebar()->setIcon(QIcon(iconPixmap));
}
// ... 后续代码不变 ...
}本报告由 AI 代码审查工具自动生成 |
Root Cause Analysis
The OCR app window titlebar icon is set via
QIcon(svg)(src/mainwidget.cpp:692,695,746,749). TheDStyle::PE_IconSI_QIconrendering path callsicon.paint(p, rect)without passingdevicePixelRatioF(). Under Wayland fractional scaling (1.5x),devicePixelRatio()returns integer 1, so the 32×32 SVG renders at only 32×32 physical pixels and gets upscaled to 48×48, causing severe aliasing.Key evidence: dtkwidget
dstyle.cpp:1257-1271(SI_QIcon path, no DPR) vs:1273-1285(SI_DciIcon path, passesdevicePixelRatioF()); KB_shared/spec/technical-facts/qt-wayland-fractional-dpr.mdconfirms Wayland fractional DPR returns integer.Fix Approach
Replace
QIcon(svg)withDDciIcon/DCI format. Createdappicon.dciwith dark/light themes at 3x scale (96×96 physical pixels for 32px logical icon). UseDDciIcon::pixmap(App->devicePixelRatioF(), 32, theme)to pre-render at correct DPR, then wrap the resultingQPixmapinQIconforsetWindowIcon()andtitlebar()->setIcon(). This follows the existingicon_tips.dcipattern already used in the same file.Change Safety Assessment
Code Safety
c12efa8), not a historical bug fix — this change does not revert any existing fixsetIcons()use the same function signature unchanged; no caller behavior affectedBusiness Impact Scope
Affected module: window titlebar icon display (dark/light themes). User scenarios: viewing the OCR app titlebar icon at different scaling factors (especially 1.5x on Wayland), and switching between dark/light themes.
Verification Suggestion
Focus on verifying the titlebar icon is sharp at Wayland 1.5x scaling. Regression test: 1x/2x scaling, dark/light theme switching, icon display on window open and image open.
根因分析
OCR 应用窗口标题栏图标通过
QIcon(svg)设置(src/mainwidget.cpp:692,695,746,749)。DStyle::PE_Icon的SI_QIcon渲染路径调用icon.paint(p, rect)时未传devicePixelRatioF()。Wayland 分数缩放(1.5x)下devicePixelRatio()返回整数 1,32×32 SVG 仅按 32×32 物理像素渲染后被放大到 48×48,导致严重锯齿。关键证据:dtkwidget
dstyle.cpp:1257-1271(SI_QIcon 无 DPR)vs:1273-1285(SI_DciIcon 有devicePixelRatioF());KB_shared/spec/technical-facts/qt-wayland-fractional-dpr.md确认 Wayland 分数 DPR 返回整数。修复方案
将
QIcon(svg)替换为DDciIcon/DCI 格式。创建appicon.dci(含深色/浅色主题,3 倍缩放 = 96×96 物理像素),使用DDciIcon::pixmap(App->devicePixelRatioF(), 32, theme)按正确 DPR 渲染后包装为QIcon。与同文件已有的icon_tips.dci用法一致。改动安全评估
代码安全评估
c12efa8),非历史修复产物,本次改动不撤销任何已有修复setIcons()的 4 个调用方使用相同函数签名,不受影响业务影响范围
受影响模块:窗口标题栏图标显示(深色/浅色主题)。用户场景:不同缩放比例(特别是 Wayland 1.5x)下查看 OCR 应用标题栏图标,以及深色/浅色主题切换。
验证建议
重点验证 Wayland 1.5x 缩放下标题栏图标无锯齿。回归验证:1x/2x 缩放、深色/浅色主题切换、窗口打开和图片打开时图标显示。
Summary by Sourcery
Render the application titlebar icons through device-pixel-ratio-aware DCI assets to keep them sharp across display scaling modes.
Bug Fixes:
Enhancements:
Build: