Skip to content

Conversation

@xionglinlin
Copy link
Contributor

@xionglinlin xionglinlin commented Feb 10, 2026

This reverts commit eacd145.

Log: The plugins should be inserted from the beginning, not appended from the end.
Influence: Plugin sequence display
PMS: BUG-349997

Summary by Sourcery

Bug Fixes:

  • Restore correct tray plugin sequence by inserting new icons at the start of the section rather than appending them at the end.

This reverts commit eacd145.

Log: The plugins should be inserted from the beginning, not appended from the end.
Influence: Plugin sequence display
PMS: BUG-349997
@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: xionglinlin

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
Copy link

sourcery-ai bot commented Feb 10, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjusts tray icon registration so new plugin surfaces are inserted at the beginning of their section rather than appended, restoring the original plugin display sequence from left to right (or from start to end) and removing the right-to-left ordering logic.

Sequence diagram for tray icon registration ordering change

sequenceDiagram
    actor User
    participant Plugin as PluginInstance
    participant Manager as PluginManager
    participant Model as TraySortOrderModel
    participant Section as TraySection

    User ->> Plugin: Trigger load
    Plugin ->> Manager: registerTraySurface(surfaceId, sectionId)
    Manager ->> Model: registerToSection(surfaceId, sectionId)
    Model ->> Section: contains(surfaceId)?
    alt surfaceId not in Section
        Model ->> Section: prepend(surfaceId)
    else surfaceId already registered
        Model -->> Section: no change
    end
    Section -->> Model: updated ordering
    Model -->> Manager: registration complete
    Manager -->> Plugin: tray surface registered
Loading

Updated class diagram for TraySortOrderModel tray section ordering

classDiagram
    class TraySortOrderModel {
        +registerToSection(surfaceId: QString, sectionId: QString) void
    }

    class TraySection {
        +id: QString
        +surfaceIds: QList~QString~
        +contains(surfaceId: QString) bool
        +prepend(surfaceId: QString) void
        +append(surfaceId: QString) void
    }

    class PluginManager {
        +registerTraySurface(surfaceId: QString, sectionId: QString) void
    }

    class PluginInstance {
        +surfaceId: QString
        +sectionId: QString
        +initialize() void
    }

    PluginInstance --> PluginManager : uses
    PluginManager --> TraySortOrderModel : manages
    TraySortOrderModel --> TraySection : organizes
Loading

File-Level Changes

Change Details Files
Change tray section registration to prepend new surface IDs instead of appending, restoring original plugin display order.
  • Replace section->append(surfaceId) with section->prepend(surfaceId) when registering a surface that is not yet in the section
  • Remove the outdated inline comment that described right-to-left icon display behavior
panels/dock/tray/traysortordermodel.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

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:

  • Given this reverts the previous right-to-left behavior, consider adding a brief code comment explaining why prepend is now the correct semantics for plugin insertion order to avoid future flip-flops on this logic.
  • Double-check any consumers of section that may assume newly registered surfaces appear at the end, as switching from append to prepend inverts that assumption and might require corresponding adjustments elsewhere.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Given this reverts the previous right-to-left behavior, consider adding a brief code comment explaining why `prepend` is now the correct semantics for plugin insertion order to avoid future flip-flops on this logic.
- Double-check any consumers of `section` that may assume newly registered surfaces appear at the end, as switching from `append` to `prepend` inverts that assumption and might require corresponding adjustments elsewhere.

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

deepin pr auto review

这段代码修改涉及系统托盘图标的排序逻辑,将 append(追加到末尾)改为 prepend(插入到开头)。以下是对该修改的详细审查意见:

1. 语法逻辑

  • 审查结果:通过。
  • 分析:从语法角度看,QList::prepend() 是 Qt 框架提供的标准 API,调用方式正确。逻辑上,代码意图是将新注册的图标 ID (surfaceId) 插入到列表的最前面,这与修改前追加到列表末尾的行为相反。

2. 代码质量

  • 审查结果:良好,但建议更新注释。
  • 分析
    • 代码简洁,直接利用了 Qt 容器的方法。
    • 改进建议:原注释 // the icon should be show from right to left 提到图标应该从右到左显示。在修改代码逻辑的同时,建议删除或更新此注释,以免产生歧义。如果改为 prepend 是为了实现“新图标显示在最右侧(或最左侧,取决于布局方向)”,注释应准确描述当前行为,例如:// 新图标插入到列表头部,使其显示在最左侧(具体取决于视图的渲染顺序)。

3. 代码性能

  • 审查结果:需注意潜在的性能影响。
  • 分析
    • QList::prepend() 的时间复杂度通常是 O(n),因为它需要将列表中现有的所有元素向后移动一位以腾出空间。
    • QList::append() 的时间复杂度通常是 均摊 O(1)(除非发生内存重分配)。
    • 影响:如果 section 列表中包含大量图标(例如几十个),频繁调用 prepend 可能会导致微小的性能开销。但在系统托盘场景下,图标数量通常较少(通常 < 20),因此这种性能差异在实际运行中几乎可以忽略不计。

4. 代码安全

  • 审查结果:安全。
  • 分析
    • 代码执行前已经通过 if (!section->contains(surfaceId)) 检查了元素是否存在,避免了重复插入导致的数据冗余。
    • prepend 操作本身不会导致内存越界或空指针问题。

总结与建议

这段修改改变了托盘图标的插入顺序,从“追加到末尾”变为“插入到头部”。这通常是为了改变 UI 上图标的排列顺序(例如让新出现的图标显示在最前面)。

建议修改后的代码片段(包含注释更新):

    if (!section->contains(surfaceId)) {
        // 将新图标插入到列表头部,使其在UI中显示在最前面
        section->prepend(surfaceId);
    }

如果 UI 布局是从右向左排列的,且列表头部对应右侧,那么原注释“从右到左”可能依然适用,但为了代码清晰度,建议明确指出是“插入头部”这一行为。

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