Skip to content

fix: disable icon smooth to prevent blur at fractional scaling#728

Merged
BLumia merged 1 commit intolinuxdeepin:masterfrom
re2zero:bugfix
Mar 10, 2026
Merged

fix: disable icon smooth to prevent blur at fractional scaling#728
BLumia merged 1 commit intolinuxdeepin:masterfrom
re2zero:bugfix

Conversation

@re2zero
Copy link
Contributor

@re2zero re2zero commented Mar 10, 2026

Set smooth: false on icon items to fix rendering artifacts.
禁用图标组件的平滑属性以解决小图标模糊。

Log: 禁用图标平滑渲染
PMS: BUG-271229
Influence: 提升启动器图标渲染性能,显示更加清晰锐利。

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Sorry @re2zero, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

Set smooth: false on icon items to fix rendering artifacts.
禁用图标组件的平滑属性以解决小图标模糊。

Log: 修复图标渲染模糊问题
PMS: BUG-271229
Influence: 小图标渲染更清晰,避免模糊伪影。
@deepin-ci-robot
Copy link

deepin pr auto review

这段代码的 diff 主要涉及 QML 文件 SideBar.qml 的修改,主要是关于图标和内容项的抗锯齿设置。以下是对这段代码的详细审查和改进建议:

1. 语法逻辑审查

代码语法是正确的,没有明显的语法错误。修改主要是为 Image 类型的组件和 contentItem 添加了 smooth: false 属性,这在 QML 中是合法的。

2. 代码质量审查

  • 代码风格:代码风格与项目保持一致,使用了 DTK (Deepin Tool Kit) 的组件。
  • 可读性:修改点清晰,但 Component.onCompleted 中的逻辑可以进一步优化。

3. 代码性能审查

  • 性能影响
    • smooth: false 会禁用抗锯齿,这可能会提高渲染性能,特别是对于图标这类不需要抗锯齿的图形。
    • Component.onCompleted 中的逻辑会在组件创建时执行一次,对性能影响较小。

4. 代码安全审查

  • 潜在问题
    • contentItem 可能不是 Image 类型,直接设置 smooth 属性可能会导致运行时错误。建议添加类型检查。

改进建议

  1. 类型检查:在设置 contentItem.smooth 之前,检查 contentItem 是否是 Image 类型。
  2. 代码复用:可以考虑将 smooth: false 的设置封装成一个可复用的组件或属性。

改进后的代码示例

// SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

ColumnLayout {
    // ... 其他代码 ...

    Image {
        id: icon
        source: "..."
        palette: D.DTK.makeIconPalette(title.palette)
        theme: D.DTK.toColorType(title.palette.window)
        Layout.alignment: Qt.AlignHCenter
        smooth: false // 禁用抗锯齿以提高性能
    }

    D.DciIcon {
        id: dciIcon
        source: "..."
        palette: D.DTK.makeIconPalette(title.palette)
        theme: D.DTK.toColorType(title.palette.window)
        Layout.alignment: Qt.AlignHCenter
        smooth: false // 禁用抗锯齿以提高性能
    }

    // ... 其他代码 ...

    Button {
        id: btn
        // ... 其他属性 ...
        Component.onCompleted: {
            if (contentItem && typeof contentItem.smooth !== 'undefined') {
                contentItem.smooth = false
            }
        }
        background: ItemBackground {
            button: btn
        }
    }
}

详细解释

  1. 版权年份更新:将版权年份从 2024 更新为 2024 - 2026,表示代码的有效期延长。
  2. 禁用抗锯齿
    • ImageD.DciIcon 添加 smooth: false,禁用抗锯齿以提高渲染性能。
    • ButtonComponent.onCompleted 中检查 contentItem 是否存在并支持 smooth 属性,然后设置为 false
  3. 类型检查
    • 使用 typeof contentItem.smooth !== 'undefined' 确保 contentItem 支持 smooth 属性,避免运行时错误。

总结

这段代码的修改主要是为了性能优化,通过禁用抗锯齿来提高渲染速度。改进后的代码增加了类型检查,提高了代码的健壮性。建议在实际应用中测试渲染效果,确保禁用抗锯齿不会影响视觉体验。

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: BLumia, re2zero

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

@BLumia BLumia merged commit c39aac4 into linuxdeepin:master Mar 10, 2026
9 of 11 checks passed
@re2zero re2zero deleted the bugfix branch March 10, 2026 09:17
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.

3 participants