Skip to content

fix(dciicon): restore smooth filtering for mixed-DPI scaling - #677

Open
gugullll wants to merge 1 commit into
linuxdeepin:masterfrom
gugullll:master
Open

fix(dciicon): restore smooth filtering for mixed-DPI scaling#677
gugullll wants to merge 1 commit into
linuxdeepin:masterfrom
gugullll:master

Conversation

@gugullll

@gugullll gugullll commented Sep 4, 2026

Copy link
Copy Markdown

Remove the scale-based setSmooth(false) overrides in DQuickDciIconImage so icons fall back to the default smooth=true filtering, eliminating jaggies when the scene is downsampled to lower-DPI outputs. Forward IconLabel's smooth to its internal image and bind smooth: control.smooth in controls.

移除DQuickDciIconImage中基于scale的smooth强制覆盖,恢复默认平滑过滤,
修复混合DPI下场景降采样导致的图标锯齿。IconLabel的smooth转发到内部
图像,并在各控件中绑定smooth: control.smooth。

Log: 修复混合DPI下图标锯齿,恢复DciIcon平滑渲染
Influence: 所有使用DciIcon/IconLabel的控件(Button/ToolButton/CheckDelegate/ItemDelegate/MenuItem/AboutDialog等)在混合DPI下图标平滑渲染;外部可通过smooth属性控制图标过滤。

Summary by Sourcery

Restore smooth filtering for DCI icons and propagate smoothing controls throughout the QML control set.

Bug Fixes:

  • Restore smooth icon filtering to prevent jagged rendering when mixed-DPI scenes are downsampled.

Enhancements:

  • Expose IconLabel.smooth through its internal icon image and propagate control smooth settings across Qt 5 and Qt 6 icon-bearing controls.

Remove the scale-based setSmooth(false) overrides in DQuickDciIconImage so
icons fall back to the default smooth=true filtering, eliminating jaggies
when the scene is downsampled to lower-DPI outputs. Forward IconLabel's
smooth to its internal image and bind smooth: control.smooth in controls.

移除DQuickDciIconImage中基于scale的smooth强制覆盖,恢复默认平滑过滤,
修复混合DPI下场景降采样导致的图标锯齿。IconLabel的smooth转发到内部
图像,并在各控件中绑定smooth: control.smooth。

Log: 修复混合DPI下图标锯齿,恢复DciIcon平滑渲染
Influence: 所有使用DciIcon/IconLabel的控件(Button/ToolButton/CheckDelegate/ItemDelegate/MenuItem/AboutDialog等)在混合DPI下图标平滑渲染;外部可通过smooth属性控制图标过滤。
@deepin-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: gugullll

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

@sourcery-ai

sourcery-ai Bot commented Sep 4, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Restores smooth texture filtering for DCI icons by removing scale-dependent overrides, then propagates IconLabel and control smooth properties through the internal image and affected QML controls to prevent mixed-DPI downsampling artifacts while preserving caller control.

Sequence diagram for IconLabel smooth filtering propagation

sequenceDiagram
    participant Control as QMLControl
    participant Label as IconLabel
    participant Image as DQuickDciIconImage
    participant Texture as QQuickImage
    Control->>Label: smoothChanged
    Label->>Image: setSmooth()
    Image->>Texture: setSmooth()
    Texture-->>Image: smooth filtering updated
Loading

File-Level Changes

Change Details Files
Restore default smooth filtering in DCI icon rendering instead of overriding it based on item scale.
  • Remove scale-change and component-completion logic that forced smooth based on scale.
  • Retain the existing smoothChanged connection from the public icon image to its internal QQuickImage.
src/private/dquickdciiconimage.cpp
Propagate IconLabel.smooth to the internal icon image so callers can control texture filtering.
  • Initialize the internal image from the label's current smooth value.
  • Connect label smooth changes to the internal image setter.
src/private/dquickiconlabel.cpp
Forward each control's smooth setting to its embedded IconLabel.
  • Bind smooth: control.smooth for button, tool button, delegate, menu item, and about dialog icon labels.
  • Apply the propagation consistently in both Qt 6 and non-Qt 6 QML implementations.
qt6/src/qml/AboutDialog.qml
qt6/src/qml/Button.qml
qt6/src/qml/CheckDelegate.qml
qt6/src/qml/ItemDelegate.qml
qt6/src/qml/MenuItem.qml
qt6/src/qml/ToolButton.qml
src/qml/AboutDialog.qml
src/qml/Button.qml
src/qml/CheckDelegate.qml
src/qml/ItemDelegate.qml
src/qml/MenuItem.qml
src/qml/ToolButton.qml

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 found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="src/private/dquickdciiconimage.cpp" line_range="269" />
<code_context>
     connect(this, &DQuickDciIconImage::smoothChanged, d->imageItem, &QQuickImage::setSmooth);
     connect(d->imageItem, &QQuickItem::widthChanged, this, [d]() { d->scheduleLayout(); });
     connect(d->imageItem, &QQuickItem::heightChanged, this, [d]() { d->scheduleLayout(); });
-    connect(this, &QQuickItem::scaleChanged, this, [this]() {setSmooth(!qFuzzyCompare(scale(), 1.0)); });
 }

</code_context>
<issue_to_address>
**issue (bug_risk):** DQuickDciIconImage no longer enables smooth filtering when it is created or completed. Its inherited QQuickItem smooth property defaults to false, and IconLabel now copies that false default into the internal image; the new control bindings likewise propagate each control's false default, so icons remain unsmoothed instead of falling back to smooth=true.

**Triggers:** When the caller does not explicitly set smooth: true.

**Suggested fix:** Initialize DQuickDciIconImage/ DQuickIconLabel smooth to true, or preserve an explicit true default before forwarding the property.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

connect(this, &DQuickDciIconImage::smoothChanged, d->imageItem, &QQuickImage::setSmooth);
connect(d->imageItem, &QQuickItem::widthChanged, this, [d]() { d->scheduleLayout(); });
connect(d->imageItem, &QQuickItem::heightChanged, this, [d]() { d->scheduleLayout(); });
connect(this, &QQuickItem::scaleChanged, this, [this]() {setSmooth(!qFuzzyCompare(scale(), 1.0)); });

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (bug_risk): DQuickDciIconImage no longer enables smooth filtering when it is created or completed. Its inherited QQuickItem smooth property defaults to false, and IconLabel now copies that false default into the internal image; the new control bindings likewise propagate each control's false default, so icons remain unsmoothed instead of falling back to smooth=true.

Triggers: When the caller does not explicitly set smooth: true.

Suggested fix: Initialize DQuickDciIconImage/ DQuickIconLabel smooth to true, or preserve an explicit true default before forwarding the property.

@deepin-ci-robot

Copy link
Copy Markdown
Contributor

deepin pr auto review

🤖 AI 代码审查报告

总体评分: 98 分 (通过阈值: 70分)

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 总体评分 98 分,大于 70 分通过阈值,代码质量符合要求。变更逻辑清晰,无安全漏洞,有效修复了混合DPI下图标锯齿问题。

🔍 详细分析

1. 语法逻辑 ✅

评价: 优秀 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: 无需修改,语法正确,逻辑清晰,边界处理完善


2. 代码质量 ✅

评价: 优秀 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: 建议在dquickdciiconimage.cpp中移除scaleChanged连接处添加简要注释说明移除原因,便于后续维护者理解历史变更


3. 代码性能 ✅

评价: 优秀 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: 无需修改,性能良好,资源使用合理


4. 代码安全 🔒

评价: 优秀 ✅ 通过

🔐 发现 0 个安全漏洞

安全漏洞详情:
✅ 未发现安全漏洞

建议: 无需安全加固,安全合规


💡 改进建议代码示例

// dquickdciiconimage.cpp - 变更说明(无需修改,当前实现已正确)
// 移除的代码(旧逻辑,已正确删除):
// 构造函数中: connect(this, &QQuickItem::scaleChanged, this, [this]() { setSmooth(!qFuzzyCompare(scale(), 1.0)); });
// componentComplete()中: setSmooth(!qFuzzyCompare(scale(), 1.0));

// dquickiconlabel.cpp - 新增代码(已正确实现):
void DQuickIconLabelPrivate::createIconImage()
{
    // ... 现有代码 ...
    image->imageItem()->setFallbackSource(icon.source());
    
    // 新增:同步smooth属性到内部图标图像
    image->setSmooth(q->smooth());
    QObject::connect(q, &QQuickItem::smoothChanged, image, &QQuickItem::setSmooth);
    
    // ... 后续代码 ...
}

// QML文件变更示例 (Button.qml) - 新增 smooth 绑定:
D.IconLabel {
    spacing: control.spacing
    mirrored: control.mirrored
    smooth: control.smooth  // 新增:绑定控件的smooth属性
    display: control.display
    // ...
}

本报告由 AI 代码审查工具自动生成

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