Skip to content

fix: 任务栏网络弹窗打开的时候闪烁#500

Merged
deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
ut003640:master
Feb 6, 2026
Merged

fix: 任务栏网络弹窗打开的时候闪烁#500
deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
ut003640:master

Conversation

@ut003640
Copy link
Contributor

@ut003640 ut003640 commented Feb 6, 2026

原因:窗口打开的时候会有窗管特效动画,在这个过程中窗口的大小发生变化可能会发生异常抖动和闪烁的情况。 方案:
1.如果需要改变窗口大小,即时处理,不要在showEvent里面去操作。
2.不要依赖isVisible()的状态,而是使用isVisibleTo()。

Log:
PMS: BIG-336029

Summary by Sourcery

Adjust network panel expansion and sizing behavior to avoid flicker when the popup opens

Bug Fixes:

  • Trigger network items' expand state refresh when rows are inserted instead of only on first show
  • Resize the dock network content widget dynamically instead of using a fixed size to prevent visual jitter during window show/hide

Enhancements:

  • Remove now-unnecessary state tracking for whether expansion needs an initial refresh

原因:窗口打开的时候会有窗管特效动画,在这个过程中窗口的大小发生变化可能会发生异常抖动和闪烁的情况。
方案:
1.如果需要改变窗口大小,即时处理,不要在showEvent里面去操作。
2.不要依赖isVisible()的状态,而是使用isVisibleTo()。

Log:
PMS: BIG-336029
@deepin-ci-robot
Copy link

deepin pr auto review

代码审查报告

经过对提供的 Git diff 进行仔细审查,以下是我的分析意见:

整体评估

本次修改主要涉及两个部分:

  1. dockcontentwidget.h 中的 setFixedSize 改为 resize
  2. 移除 netview 中的 m_shouldUpdateExpand 成员变量及其相关逻辑,并调整了展开状态更新的时机

详细分析

1. dockcontentwidget.h 修改

-        setFixedSize(m_netView->width(), qMax(m_minHeight, m_netView->height() + 20 + m_mainLayout->contentsMargins().top() + (m_netCheckBtn->isVisibleTo(this) ? (m_netSetBtn->height() + m_netCheckBtn->height() + 10) : m_netSetBtn->height())));
+        resize(m_netView->width(), qMax(m_minHeight, m_netView->height() + 20 + m_mainLayout->contentsMargins().top() + (m_netCheckBtn->isVisibleTo(this) ? (m_netSetBtn->height() + m_netCheckBtn->height() + 10) : m_netSetBtn->height())));

问题与建议:

  • 语法逻辑:修改是正确的,将 setFixedSize 改为 resize 允许窗口大小在后续可以再次调整
  • 代码质量:表达式过于复杂,建议将其拆分为可读性更好的代码:
    int height = m_netView->height() + 20 + m_mainLayout->contentsMargins().top();
    if (m_netCheckBtn->isVisibleTo(this)) {
        height += m_netSetBtn->height() + m_netCheckBtn->height() + 10;
    } else {
        height += m_netSetBtn->height();
    }
    resize(m_netView->width(), qMax(m_minHeight, height));

2. netview.h 和 netview.cpp 修改

问题与建议:

  • 语法逻辑:移除 m_shouldUpdateExpand 成员变量是合理的,简化了代码逻辑
  • 代码逻辑:将展开状态更新移到 rowsInserted 中处理,这样每次插入新行时都会更新展开状态,比原来的只在首次显示时更新更及时
  • 代码性能:新增的 m_manager->exec(NetManager::ToggleExpand, ""); 调用会在每次插入特定类型的行时触发,可能导致频繁的展开状态更新,建议评估是否每次插入都需要更新

潜在问题:

  • rowsInserted 中添加的 m_manager->exec(NetManager::ToggleExpand, ""); 调用可能会导致性能问题,特别是在插入大量行时
  • 原来的实现在 showEvent 中只更新一次展开状态,现在改为在每次插入时更新,可能导致不必要的操作

安全性考虑

  • 修改不涉及明显的安全问题,但需要确保 m_manager->exec 调用不会导致意外的状态变化或资源泄漏

总结建议

  1. 对于 dockcontentwidget.h 中的复杂表达式,建议重构为更易读的代码
  2. 对于 netview 中的修改,建议进一步评估 m_manager->exec(NetManager::ToggleExpand, "") 调用的频率和必要性,考虑是否需要添加条件判断来避免不必要的调用
  3. 建议添加单元测试来验证修改后的行为是否符合预期,特别是在插入大量行时的性能表现

总体而言,这些修改简化了代码逻辑,但可能引入性能问题,建议在实际使用中进行充分测试。

@sourcery-ai
Copy link

sourcery-ai bot commented Feb 6, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Refactors when and how the network panel tree view updates expansion state and widget sizing to avoid flicker during window show animations, by removing deferred expand toggling in showEvent, triggering it on row insertion instead, and resizing the container widget directly rather than changing its fixed size.

Sequence diagram for updated network panel expansion and sizing behavior

sequenceDiagram
    actor User
    participant Dock
    participant DockContentWidget
    participant NetView
    participant NetManager

    User->>Dock: Click network icon
    Dock->>DockContentWidget: Show network popup
    DockContentWidget->>NetView: Show
    activate NetView
    NetView->>NetManager: setAutoScanEnabled(true)
    deactivate NetView

    NetManager-->>NetView: Insert rows into model
    activate NetView
    NetView->>NetView: rowsInserted(parent, start, end)
    alt WirelessOtherItem or WirelessMineItem inserted
        NetView->>NetManager: exec(ToggleExpand, "")
        NetView->>NetView: updateItemExpand(item)
    else Other item types
        NetView->>NetView: updateItemExpand(item)
    end
    deactivate NetView

    loop User resizes content indirectly
        DockContentWidget->>NetView: setMaxHeight(h)
        DockContentWidget->>NetView: setFixedHeight(h) if needed
        DockContentWidget->>DockContentWidget: resize(width, computedHeight)
    end

    User->>Dock: Close network popup
    Dock->>DockContentWidget: Hide network popup
    DockContentWidget->>NetView: hide
    activate NetView
    NetView->>NetManager: exec(ToggleExpand, "")
    NetView->>NetManager: setAutoScanEnabled(false)
    NetView->>NetView: clear() after delay
    deactivate NetView
Loading

Class diagram for updated NetView and DockContentWidget sizing and expand logic

classDiagram
    class NetManager {
        <<QObject>>
        +exec(action, argument)
        +setAutoScanEnabled(enabled)
    }

    class NetView {
        <<QTreeView>>
        -NetManager* m_manager
        -NetModel* m_model
        -NetDelegate* m_delegate
        -bool m_closeOnClear
        -int m_maxHeight
        +clear()
        +rowsInserted(parent, start, end)
        +showEvent(event)
        +hideEvent(event)
        +updateItemExpand(item)
        +onExpandStatusChanged()
    }

    class DockContentWidget {
        <<QWidget>>
        -NetView* m_netView
        -QPushButton* m_netCheckBtn
        -QPushButton* m_netSetBtn
        -QLayout* m_mainLayout
        -int m_minHeight
        +setNetCheckBtnVisible(visible)
        +updateSize(h)
    }

    NetView --> NetManager : uses
    DockContentWidget --> NetView : contains

    class UpdateSizeBehaviorBefore {
        +updateSize(h)
        +setFixedSize(width, height)
    }

    class UpdateSizeBehaviorAfter {
        +updateSize(h)
        +resize(width, height)
    }

    DockContentWidget ..> UpdateSizeBehaviorBefore : replaced
    DockContentWidget ..> UpdateSizeBehaviorAfter : now uses

    class ExpandBehaviorBefore {
        +showEvent(event)
        +execToggleExpandOnFirstShow()
        -bool m_shouldUpdateExpand
    }

    class ExpandBehaviorAfter {
        +rowsInserted(parent, start, end)
        +execToggleExpandOnRowInsert()
    }

    NetView ..> ExpandBehaviorBefore : behavior removed
    NetView ..> ExpandBehaviorAfter : behavior added
    NetView --|> QTreeView
    DockContentWidget --|> QWidget
Loading

File-Level Changes

Change Details Files
Move expansion-state refresh from first showEvent into row insertion handling to avoid size changes during show animations.
  • Removed m_shouldUpdateExpand member and its initialization in NetView
  • Stopped setting m_shouldUpdateExpand in clear() and hideEvent()
  • Deleted showEvent logic that conditionally called NetManager::ToggleExpand and updateGeometries based on m_shouldUpdateExpand
  • Invoke NetManager::ToggleExpand immediately in rowsInserted for WirelessOtherItem and WirelessMineItem before calling updateItemExpand
net-view/window/netview.cpp
net-view/window/netview.h
Adjust dock network content widget sizing to resize instead of resetting fixed size to reduce visual jitter when height changes.
  • Replaced setFixedSize(...) with resize(...) when updating DockContentWidget dimensions in response to NetView height changes
  • Kept max height and fixed height logic on m_netView itself unchanged
dock-network-plugin/dockcontentwidget.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!

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

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 - I've left some high level feedback:

  • In rowsInserted, m_manager->exec(NetManager::ToggleExpand, "") is now invoked on every insertion of WirelessOtherItem/WirelessMineItem; if multiple rows are inserted in a batch this may cause redundant expand toggles, so consider coalescing the calls (e.g., only once per rowsInserted invocation or deferring via a single-shot timer).
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `rowsInserted`, `m_manager->exec(NetManager::ToggleExpand, "")` is now invoked on every insertion of `WirelessOtherItem`/`WirelessMineItem`; if multiple rows are inserted in a batch this may cause redundant expand toggles, so consider coalescing the calls (e.g., only once per `rowsInserted` invocation or deferring via a single-shot timer).

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

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: caixr23, ut003640

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

@ut003640
Copy link
Contributor Author

ut003640 commented Feb 6, 2026

/forcemerge

@deepin-bot
Copy link
Contributor

deepin-bot bot commented Feb 6, 2026

This pr force merged! (status: unstable)

@deepin-bot deepin-bot bot merged commit 6def30e into linuxdeepin:master Feb 6, 2026
16 of 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.

4 participants