Skip to content

Comments

fix: correct icon display order from right to left#1413

Merged
BLumia merged 1 commit intolinuxdeepin:masterfrom
re2zero:bugfix
Jan 29, 2026
Merged

fix: correct icon display order from right to left#1413
BLumia merged 1 commit intolinuxdeepin:masterfrom
re2zero:bugfix

Conversation

@re2zero
Copy link
Contributor

@re2zero re2zero commented Jan 28, 2026

change prepend to append operation to ensure icons are displayed in the correct order from right to left as intended

插件图标顺序从右到左(左:系统监视器;右:屏幕键盘)。

PMS: BUG-342419
Log: correct icon display order from right to left

Summary by Sourcery

Bug Fixes:

  • Fix tray section insertion so new icons are appended instead of prepended, preserving the desired right-to-left visual order.

change prepend to append operation to ensure icons are displayed
in the correct order from right to left as intended

插件图标顺序从右到左(左:系统监视器;右:屏幕键盘)。

PMS: BUG-342419
Log: correct icon display order from right to left
@sourcery-ai
Copy link

sourcery-ai bot commented Jan 28, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjusts how tray icons are inserted into sections so that new icons appear in right-to-left visual order by switching from prepending to appending IDs in the tray sort order model.

Sequence diagram for registering tray icons with right-to-left ordering

sequenceDiagram
    actor User
    participant App
    participant TraySortOrderModel
    participant Section

    User->>App: Enable tray plugin icon
    App->>TraySortOrderModel: registerToSection(surfaceId, sectionId)
    TraySortOrderModel->>Section: contains(surfaceId)?
    alt surfaceId not present
        TraySortOrderModel->>Section: append(surfaceId)
        Section-->>TraySortOrderModel: surfaceId added at end
    else surfaceId already present
        Section-->>TraySortOrderModel: no change
    end
    Section-->>App: updated ordered list of surfaceIds
    App-->>User: Icons rendered from right to left using list order
Loading

Class diagram for TraySortOrderModel tray section insertion change

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

    class Section {
        +QStringList surfaceIds
        +bool contains(QString surfaceId)
        +void append(QString surfaceId)
    }

    TraySortOrderModel --> Section : updates_ordered_surfaceIds
Loading

File-Level Changes

Change Details Files
Fix tray icon insertion order to match intended right-to-left visual layout.
  • Change section insertion from prepend to append when registering a new surface ID if it is not already present in the section.
  • Add a clarifying comment documenting that icons should be displayed from right to left.
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 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

deepin pr auto review

这段代码修改主要涉及到了托盘区域图标排序逻辑的变更。以下是对该 diff 的详细审查意见,包括语法逻辑、代码质量、性能和安全方面的分析:

1. 语法逻辑审查

  • 修改内容:将 section->prepend(surfaceId) 修改为 section->append(surfaceId)
  • 逻辑分析
    • 原逻辑prepend 意味着将新图标插入到列表的头部(左侧/开始位置)。当新图标出现时,它会排在最前面。
    • 新逻辑append 意味着将新图标插入到列表的尾部(右侧/结束位置)。
    • 结论:根据注释 // the icon should be show from right to left(图标应该从右向左显示),如果该 UI 组件的布局方向是从右向左排列的(即列表索引 0 在最右侧,或者渲染时反向遍历列表),那么使用 append 将新图标放在数据结构的末尾,确实可能对应视觉上的最右侧。反之,如果布局是从左到右,且希望新图标出现在最右边,通常也需要使用 append
    • 建议:逻辑修改符合注释描述的 UI 需求。只要 UI 渲染层与此数据模型配合正确,逻辑上是成立的。

2. 代码质量审查

  • 注释:添加了注释 // the icon should be show from right to left
    • 优点:这是一个很好的实践。对于这种改变数据排列顺序的关键逻辑,必须添加注释说明原因,否则未来的维护者可能会误以为这是一个 Bug 并将其改回 prepend
    • 建议:注释可以稍微更严谨一些,例如:// New icons should appear at the rightmost side of the tray (visual order: right to left),明确指出是视觉顺序。

3. 代码性能审查

  • 复杂度分析
    • prependappendQListQStringList(Qt 常用容器)中的时间复杂度取决于容器类型:
      • 如果是 QList(Qt 5 及之前)或 QVector(Qt 6 的 QList 实现):prepend 通常需要移动所有现有元素(O(N)),而 append 通常是均摊 O(1) 的(除非发生扩容)。
      • 如果是 QLinkedList:两者都是 O(1)。
    • 结论:将 prepend 改为 append 在性能上是一个正向优化。它避免了每次新图标注册时移动内存中所有现有元素的开销,尤其是在托盘图标较多的情况下,能减少 CPU 周期和内存抖动。

4. 代码安全审查

  • 指针安全:代码中使用了 section->,说明 section 是一个指针。虽然 diff 中未显示上下文,但根据上一行 if (!section->contains(surfaceId)) 可以推断,section 在此处必然已经过有效性检查(非空指针)。
  • 数据一致性:修改仅仅改变了插入位置,不涉及内存越界、空指针解引用或数据损坏的风险。
  • 结论:该修改是安全的。

总结与改进建议

该代码修改是一个低风险、高质量的改动。它不仅修复了 UI 显示顺序的问题(符合产品需求),还顺便提升了数据插入的性能。

最终建议:

  1. 保持该修改:逻辑和性能上都是正确的。
  2. 完善注释(可选):为了让代码意图更清晰,建议稍微扩充注释,例如:
    // Append to ensure new icons appear on the rightmost side.
    // Visual layout order is from right to left.
    section->append(surfaceId);
  3. 测试建议:在合并代码前,重点测试以下场景:
    • 启动系统时,托盘图标的初始排列顺序。
    • 运行过程中,新启动的应用图标在托盘中的出现位置(应出现在最右侧)。
    • 移除图标后,剩余图标的排列是否依然稳定。

@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 eacd145 into linuxdeepin:master Jan 29, 2026
10 of 11 checks passed
@re2zero re2zero deleted the bugfix branch January 29, 2026 01:51
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