Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Prevent palette flickering during sidebar item expansion #2670

Merged
merged 2 commits into from
Mar 12, 2025

Conversation

Johnson-zs
Copy link
Contributor

@Johnson-zs Johnson-zs commented Mar 12, 2025

Implement transparent palette handling during sidebar item expansion to prevent visual artifacts. Store the original palette and temporarily set a transparent background when expanding/collapsing items.

Log: Improve sidebar view rendering stability

Bug: https://pms.uniontech.com/bug-view-307543.html
Bug: https://pms.uniontech.com/bug-view-307537.html

Summary by Sourcery

Implements transparent palette handling during sidebar item expansion and collapsing to prevent visual artifacts such as flickering. It stores the original palette and temporarily sets a transparent background when expanding/collapsing items.

Bug Fixes:

  • Fixes palette flickering during sidebar item expansion.
  • Fixes palette flickering during sidebar item collapsing.

Implement transparent palette handling during sidebar item expansion to prevent visual artifacts. Store the original palette and temporarily set a transparent background when expanding/collapsing items.

Log: Improve sidebar view rendering stability

Bug: https://pms.uniontech.com/bug-view-307543.html
Bug: https://pms.uniontech.com/bug-view-307537.html
Copy link

sourcery-ai bot commented Mar 12, 2025

Reviewer's Guide by Sourcery

This pull request addresses a visual flickering issue during sidebar item expansion by implementing transparent palette handling. The original palette is stored, a transparent background is applied during expansion/collapse, and the original palette is then restored.

Sequence diagram for sidebar item expansion with transparent palette

sequenceDiagram
    participant SideBarView
    participant SideBarViewPrivate

    SideBarView->>SideBarView: onChangeExpandState(index, expand)
    activate SideBarView
    SideBarView->>SideBarViewPrivate: d->setTransparentPalette()
    activate SideBarViewPrivate
    SideBarViewPrivate->>SideBarView: setPalette(transparentPalette)
    deactivate SideBarViewPrivate
    SideBarView->>SideBarView: setExpanded(index, expand)
    SideBarView->>SideBarViewPrivate: d->restorePalette()
    activate SideBarViewPrivate
    SideBarViewPrivate->>SideBarView: setPalette(originPalette)
    deactivate SideBarViewPrivate
    deactivate SideBarView
Loading

Updated class diagram for SideBarView and SideBarViewPrivate

classDiagram
    class SideBarView{
        +onChangeExpandState(index, expand)
    }
    class SideBarViewPrivate{
        -QPalette originPalette
        +setTransparentPalette()
        +restorePalette()
        -onItemDoubleClicked(index)
    }

    SideBarView -- SideBarViewPrivate: has a
Loading

File-Level Changes

Change Details Files
Implemented transparent palette handling during sidebar item expansion to prevent visual artifacts.
  • Stored the original palette in a member variable.
  • Created methods to set a transparent background and restore the original palette.
  • Applied the transparent background before expanding/collapsing items and restored the original palette afterward.
src/plugins/filemanager/dfmplugin-sidebar/treeviews/sidebarview.cpp
src/plugins/filemanager/dfmplugin-sidebar/treeviews/private/sidebarview_p.h

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!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

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

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Johnson-zs

The full list of commands accepted by this bot can be found here.

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

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.

Hey @Johnson-zs - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider adding a comment explaining why a transparent palette is needed to prevent flickering.
  • It might be more efficient to store and restore the base color of the palette instead of the entire palette.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

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.

Prevent UI flickering during sidebar expansion, improve Unicode sorting in file comparison, simplify file info creation and speedtimer management, ensure proper initialization, and replace abort() with Q_ASSERT_X for plugin loading failures.

Log: tag 6.5.39
@deepin-ci-robot
Copy link

deepin pr auto review

关键摘要:

  • sidebarview_p.h文件中新增了QPalette originPalette成员变量,但没有看到对应的初始化代码,可能会导致未定义行为。
  • setTransparentPaletterestorePalette函数在SideBarViewPrivate类中实现,但没有在sidebarview.cpp文件中看到调用这些函数的地方,可能是未完成的功能。
  • SideBarView::SideBarView(QWidget *parent)构造函数中,d->originPalette = palette();的调用位置可能不正确,应该在setPalette之后。
  • SideBarView::onChangeExpandState函数中,setExpanded的调用被包裹在d->setTransparentPalette();d->restorePalette();之间,这可能会影响性能,因为每次展开或折叠都会重新设置背景色。

是否建议立即修改:

  • 确保所有新增的成员变量和函数都有正确的初始化和调用。
  • 优化SideBarView::onChangeExpandState函数中的代码,避免不必要的性能开销。
  • 检查setTransparentPaletterestorePalette函数的实现是否满足预期的功能,并确保它们在适当的地方被调用。

Copy link

TAG Bot

TAG: 6.5.39
EXISTED: no
DISTRIBUTION: unstable

@Johnson-zs
Copy link
Contributor Author

/forcemerge

@deepin-bot
Copy link
Contributor

deepin-bot bot commented Mar 12, 2025

This pr force merged! (status: blocked)

@deepin-bot deepin-bot bot merged commit 6d9eaba into linuxdeepin:master Mar 12, 2025
19 of 21 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.

2 participants