Skip to content

fix: enable antialiasing for photo/video buttons.#406

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
add-uos:master
Oct 20, 2025
Merged

fix: enable antialiasing for photo/video buttons.#406
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
add-uos:master

Conversation

@add-uos

@add-uos add-uos commented Oct 20, 2025

Copy link
Copy Markdown
Contributor

The photo and video buttons were displaying with
blurry edges due to missing antialiasing settings in Qt6. The paintEvent method only set HighQualityAntialiasing for Qt5 and below, leaving Qt6 versions without any antialiasing. This fix adds proper antialiasing support for Qt6 using the standard Antialiasing render hint.

Log: adapt Qt6 antialiasing
Bug: https://pms.uniontech.com/bug-view-307777.html

Summary by Sourcery

Bug Fixes:

  • Add QPainter::Antialiasing render hint for Qt6 in paintEvent

The photo and video buttons were displaying with
blurry edges due to missing antialiasing settings in Qt6.
The paintEvent method only set HighQualityAntialiasing
for Qt5 and below, leaving Qt6 versions without any antialiasing.
This fix adds proper antialiasing support for Qt6 using
the standard Antialiasing render hint.

Log: adapt Qt6 antialiasing
Bug: https://pms.uniontech.com/bug-view-307777.html
@sourcery-ai

sourcery-ai Bot commented Oct 20, 2025

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

Reviewer's Guide

Extend photoRecordBtn paintEvent to enable QPainter antialiasing under Qt6, matching existing Qt5 behavior and eliminating blurry button edges.

Class diagram for updated photoRecordBtn antialiasing logic

classDiagram
    class photoRecordBtn {
        +void paintEvent(QPaintEvent *event)
    }
    class QPainter {
        +void setRenderHint(RenderHint, bool)
    }
    photoRecordBtn --> QPainter : uses
Loading

Flow diagram for antialiasing selection in paintEvent

flowchart TD
    A["paintEvent() called"] --> B{Qt Version}
    B -- "Qt5 or below" --> C["setRenderHint(HighQualityAntialiasing, true)"]
    B -- "Qt6 or above" --> D["setRenderHint(Antialiasing, true)"]
    C --> E["Continue painting"]
    D --> E
Loading

File-Level Changes

Change Details Files
Enable antialiasing support for Qt6 in paintEvent
  • Added an #else branch to apply QPainter::Antialiasing when QT_VERSION_MAJOR > 5
  • Kept existing HighQualityAntialiasing setting for Qt5 and below
src/src/photorecordbtn.cpp

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 there - I've reviewed your changes and they look great!


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.

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

我来对这个代码修改进行审查:

  1. 语法逻辑:
  • 代码语法正确,使用了条件编译来适配不同Qt版本
  • 逻辑清晰,针对Qt5和Qt6+版本分别设置了不同的抗锯齿渲染提示
  1. 代码质量:
  • 优点:
    • 使用了条件编译确保跨版本兼容性
    • 代码结构清晰,易于理解
  • 可改进点:
    • 可以考虑使用QPainter::RenderHint枚举值而不是字符串常量
    • 建议添加注释说明为什么需要区分Qt版本
  1. 代码性能:
  • 性能影响较小,因为这是在绘制事件中的设置
  • 抗锯齿渲染会略微影响性能,但这是为了提升视觉效果所必需的
  1. 代码安全:
  • 代码安全性良好,没有发现明显的安全隐患

改进建议:

void photoRecordBtn::paintEvent(QPaintEvent *event)
{
    QPainter painter(this);
    
    // 设置抗锯齿渲染,适配不同Qt版本
#if QT_VERSION_MAJOR <= 5
    painter.setRenderHint(QPainter::HighQualityAntialiasing);
#else
    painter.setRenderHint(QPainter::Antialiasing);
#endif
    
    painter.setBrush(Qt::NoBrush);
    // ... 其余绘制代码
}

主要改进点:

  1. 添加了注释说明版本差异的原因
  2. 移除了多余的true参数(setRenderHint默认就是启用)
  3. 保持了代码的缩进一致性

这些改动虽然不大,但能提高代码的可读性和维护性。

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: add-uos, lzwind

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

@add-uos

add-uos commented Oct 20, 2025

Copy link
Copy Markdown
Contributor Author

/merge

@deepin-bot deepin-bot Bot merged commit 959d67c into linuxdeepin:master Oct 20, 2025
18 checks passed
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