Repository navigation
fix: use DDciIcon for crisp icons under fractional scaling - #94
tianming-1996 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Sorry @tianming-1996, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
|
[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 |
|
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. |
Reviewer's GuideThis PR throttles mouse wheel zoom in the OCR image viewer, switches to fast image transformation during zoom, clamps zoom scale before applying it, and adds finite-value guards to avoid degenerate transforms and GPU overload-induced crashes, while keeping pinch zoom behavior unchanged. Sequence diagram for throttled wheel zoom and transformation mode switchingsequenceDiagram
actor User
participant ImageView
participant QTimer
participant PixmapItem
User->>ImageView: wheelEvent(QWheelEvent)
ImageView->>ImageView: m_accumulatedFactor *= qPow(1.2, delta/240.0)
ImageView->>ImageView: m_wheelPos = event->position().toPoint()
ImageView->>PixmapItem: setTransformationMode(Qt::FastTransformation)
ImageView->>QTimer: start()
QTimer-->>ImageView: onWheelTimerTimeout()
ImageView->>ImageView: scaleAtPoint(m_wheelPos, m_accumulatedFactor)
ImageView->>ImageView: setScaleValue(factor)
ImageView->>ImageView: scale(v, v)
ImageView->>PixmapItem: setTransformationMode(Qt::SmoothTransformation)
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
450a759 to
b15185d
Compare
b15185d to
268337d
Compare
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 语法正确,逻辑清晰 ✅ 通过 潜在问题: 建议: ['无改进建议,代码逻辑正确。'] 2. 代码质量 ✅评价: 代码结构清晰,注释完整 ✅ 通过 潜在问题: 建议: ['无改进建议,代码质量良好。'] 3. 代码性能 ✅评价: 性能良好,资源使用合理 ✅ 通过 潜在问题: 建议: ['无改进建议,性能表现良好。'] 4. 代码安全 🔒评价: 存在0个安全漏洞 ✅ 通过
安全漏洞详情: 建议: ['无改进建议,代码安全合规。'] 💡 改进建议代码示例// 当前代码已正确实现,无需修复。以下为完整正确用法示例: // Dark 主题分支 DDciIcon appIcon(QString(":/assets/appicon.dci")); QPixmap appIconPix = appIcon.pixmap(App->devicePixelRatioF(), 32, DDciIcon::Theme::Dark); App->setWindowIcon(QIcon(appIconPix)); DMainWindow *mainWindow = static_cast<DMainWindow *>(this->parent()); if (mainWindow) {
mainWindow->titlebar()->setIcon(QIcon(appIconPix));
} // Light 主题分支同理,将 DDciIcon::Theme::Dark 改为 DDciIcon::Theme::Light本报告由 AI 代码审查工具自动生成 |
1. Root cause: setIcons() used QIcon(svg) for window icon which does not handle fractional DPR on Qt5 Wayland, devicePixelRatio() returns integer 1 instead of 1.5, producing 32x32 instead of 48x48 pixels 2. Fix: replace 4 QIcon(svg) calls with DDciIcon::pixmap(devicePixelRatioF(), 32, theme) wrapped as QIcon, add appicon.dci resource with dark/light themes, register in resource.qrc 3. Impact: OCR window icon renders at correct physical pixel density under fractional scaling, no behavior change at integer scaling Log: Fix OCR window icon aliasing under fractional display scaling Influence: 1. Test OCR window icon clarity at 1.5x fractional scaling 2. Verify icon displays correctly at 1.0x integer scaling 3. Test icon rendering after switching dark/light themes 4. Verify icon clarity at 2.0x scaling fix: 使用 DDciIcon 替换 QIcon 修复 OCR 应用图标锯齿 1. 根因:setIcons() 使用 QIcon(svg) 设置窗口图标,Qt5 Wayland 分数缩放 下 devicePixelRatio() 返回整数 1 而非 1.5,图标仅按 32x32 物理像素渲染 2. 方案:将 4 处 QIcon(svg) 替换为 DDciIcon::pixmap(devicePixelRatioF(), 32, theme) 包装为 QIcon,新增 appicon.dci 资源文件(含深色/浅色主题), 在 resource.qrc 中注册 3. 影响:OCR 窗口图标在分数缩放下按正确物理像素密度渲染,整数缩放下无行为变化 Log: 修复分数缩放下 OCR 窗口图标锯齿问题 Influence: 1. 测试 1.5x 分数缩放下 OCR 窗口图标清晰度 2. 验证 1.0x 整数缩放下图标显示正常 3. 测试深色/浅色主题切换后图标正确显示 4. 验证 2.0x 缩放下图标清晰度 PMS: BUG-193447
268337d to
338f190
Compare
Root Cause Analysis
The OCR window icon aliasing under fractional display scaling (1.5x) on Wayland/Qt5 is caused by
MainWidget::setIcons()usingQIcon(svg)to set the window icon (src/mainwidget.cpp:692,695,746,749). Under Qt5 Wayland fractional scaling,devicePixelRatio()returns the integer 1 instead of 1.5, soQIconrenders the icon at only 32×32 physical pixels. The compositor must then upscale to 48×48 (32×1.5), producing aliasing. The same file already usesDDciIcon::pixmap(devicePixelRatio(), size, theme)for other icons (copy, export, tip) which correctly handles DPR — only the app icon was left using rawQIcon(svg).Fix
Replace 4
QIcon(svg)calls withDDciIcon::pixmap(App->devicePixelRatioF(), 32, theme)wrapped asQIcon, add anappicon.dciresource file (dark/light themes), and register it inresource.qrc. This matches the existingDDciIconusage pattern in the same function. No deviation from the analysis report's recommended fix.Change Safety Assessment
Code Safety
c12efa8), not a previous bug fix — this change does not revert any historical fix.QIcon(svg)calls withinsetIcons()are modified; no function signatures, public members, or callers changed. ThesetIcons()function is called at window init, image open, and window open — impact is limited to icon rendering.Business Impact Scope
Verification Suggestion
根因分析
OCR 窗口图标在 Wayland/Qt5 分数缩放(1.5x)下锯齿严重,根因是
MainWidget::setIcons()使用QIcon(svg)设置窗口图标(src/mainwidget.cpp:692,695,746,749)。Qt5 Wayland 分数缩放下devicePixelRatio()返回整数 1 而非 1.5,QIcon仅按 32×32 物理像素渲染,合成器需 48×48(32×1.5),放大 1.5 倍产生锯齿。同文件中其他图标(复制、导出、提示)已正确使用DDciIcon::pixmap(devicePixelRatio(), size, theme)处理 DPR,唯独应用图标仍用原始 SVG QIcon。修复方案
将 4 处
QIcon(svg)替换为DDciIcon::pixmap(App->devicePixelRatioF(), 32, theme)包装为QIcon,新增appicon.dci资源文件(含深色/浅色主题),在resource.qrc中注册。与同函数现有DDciIcon用法一致,与分析报告推荐方案无偏离。改动安全评估
代码安全评估
c12efa8,非历史 bug 修复产物,本次改动不撤销任何已有修复。setIcons()内 4 处QIcon(svg)调用,未改函数签名、公开成员或调用方。setIcons()在窗口初始化、图片打开、窗口打开时调用,影响仅限图标渲染。业务影响范围
验证建议