Skip to content

fix: render titlebar icons with fractional DPR to fix aliasing (PMS 193447) - #103

Draft
tianming-1996 wants to merge 1 commit into
linuxdeepin:release/eaglefrom
tianming-1996:fix/titlebar-icon-fractional-dpr-193447
Draft

tianming-1996 wants to merge 1 commit into
linuxdeepin:release/eaglefrom
tianming-1996:fix/titlebar-icon-fractional-dpr-193447

Conversation

@tianming-1996

@tianming-1996 tianming-1996 commented Nov 6, 2026 •

Copy link
Copy Markdown

修复说明

问题

2560×1600 1.5倍缩放(Wayland 分数缩放)下,截图进入OCR后左上角标题栏图标锯齿模糊严重。

根因

deepin-ocr src/mainwidget.cpp 中 MainWidget::setIcons() 使用 QIcon(svg) 设置标题栏图标。该 QIcon 经 DTK DStyle::PE_Icon 的 SI_QIcon 分支绘制时,不传 devicePixelRatioF()(仅 SI_DciIcon 分支显式传分数 DPR)。Wayland 1.5x 分数缩放下 devicePixelRatio() 返回整数 1,图标按 1× 光栅化后合成器上采样至 1.5×,产生锯齿。

修复方案(方案 A)

  1. 标题栏图标(行 692/695/746/749):将 QIcon(svg) 改为使用 QIcon::pixmap(QSize(32, 32), devicePixelRatioF()) 按 devicePixelRatioF() 预光栅化 SVG 为高分辨率 QPixmap,再包成 QIcon 传入 setWindowIcon() / titlebar()->setIcon()。预渲染的 pixmap 携带正确的分数 DPR,DTK SI_QIcon 分支绘制时直接使用该高分辨率 pixmap,消除锯齿。

  2. 提示图标(行 688/742):现有 DDciIcon::pixmap() 调用从 devicePixelRatio() 改为 devicePixelRatioF(),消除同类分数 DPR 隐患。

改动范围

仅 src/mainwidget.cpp MainWidget::setIcons(),不涉及 DTK 全局渲染路径。

验证

  • 代码审查确认 devicePixelRatioF() 替换 devicePixelRatio() 正确
  • QIcon::pixmap(QSize, qreal dpr) 为 Qt 5.1+ 标准 API
  • 不影响整数 DPR 环境下行为(devicePixelRatioF() == devicePixelRatio())

PMS: 193447

Summary by Sourcery

Enable high-DPI rendering support to improve application visuals on fractional-scale displays.

Bug Fixes:

  • Enable Qt high-DPI scaling and high-DPI pixmaps to improve rendering on fractional display scaling environments.

Chores:

  • Update the copyright year range in the application entry point.

@tianming-1996
tianming-1996 marked this pull request as draft November 6, 2026 16:48
@sourcery-ai

sourcery-ai Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Configuration

Enable Qt high-DPI scaling and pixmaps before application construction so icons render at the display’s actual device-pixel ratio.

  • src/main.cpp L1, L17, L32-33

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@tianming-1996
tianming-1996 force-pushed the fix/titlebar-icon-fractional-dpr-193447 branch 2 times, most recently from acfac38 to 91f4d67 Compare November 9, 2026 03:38
@deepin-ci-robot

Copy link
Copy Markdown

[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.

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

Under Wayland fractional scaling the window reports a device pixel ratio
of 1.5, but Qt's icon painting path ignores it unless
Qt::AA_UseHighDpiPixmaps is enabled. The SVG titlebar icon was therefore
rasterized at 32x32 and scaled up to the 48x48 device pixels of its slot,
which made it look aliased.

Enable Qt::AA_EnableHighDpiScaling and Qt::AA_UseHighDpiPixmaps before
constructing the application, so QIcon requests and rasterizes icons at
the real device pixel ratio.

Bug: https://pms.uniontech.com/bug-view-193447.html
@tianming-1996
tianming-1996 force-pushed the fix/titlebar-icon-fractional-dpr-193447 branch from 91f4d67 to c7f4c2c Compare November 9, 2026 09:59
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.

2 participants