Skip to content

fix: reset grid view index when hiding launcher#664

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
wjyrich:fix-bug-337493
Oct 24, 2025
Merged

fix: reset grid view index when hiding launcher#664
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
wjyrich:fix-bug-337493

Conversation

@wjyrich

@wjyrich wjyrich commented Oct 24, 2025

Copy link
Copy Markdown
Contributor
  1. Add property alias to expose grid view current index from list view page item
  2. Reset grid view index to 0 when hiding launcher to ensure consistent state
  3. This prevents the grid view from retaining previous selection when launcher is reopened
  4. Improves user experience by always starting from first item after hide/show cycle

fix: 隐藏启动器时重置网格视图索引

  1. 添加属性别名以暴露列表视图页面项的网格视图当前索引
  2. 隐藏启动器时将网格视图索引重置为0以确保状态一致
  3. 防止启动器重新打开时网格视图保留之前的选中状态
  4. 通过始终在隐藏/显示循环后从第一项开始来改善用户体验

PMS: BUG-337493

Summary by Sourcery

Expose grid view current index via a property alias and reset it to zero when hiding the launcher to prevent stale selection and improve user experience

New Features:

  • Expose grid view current index via a property alias

Bug Fixes:

  • Reset grid view index to 0 when hiding the launcher to ensure consistent state

Enhancements:

  • Always start the grid view from the first item after hiding and showing the launcher

1. Add property alias to expose grid view current index from list view
page item
2. Reset grid view index to 0 when hiding launcher to ensure consistent
state
3. This prevents the grid view from retaining previous selection when
launcher is reopened
4. Improves user experience by always starting from first item after
hide/show cycle

fix: 隐藏启动器时重置网格视图索引

1. 添加属性别名以暴露列表视图页面项的网格视图当前索引
2. 隐藏启动器时将网格视图索引重置为0以确保状态一致
3. 防止启动器重新打开时网格视图保留之前的选中状态
4. 通过始终在隐藏/显示循环后从第一项开始来改善用户体验

PMS: BUG-337493
@wjyrich wjyrich requested review from 18202781743 and BLumia and removed request for 18202781743 October 24, 2025 03:27
@sourcery-ai

sourcery-ai Bot commented Oct 24, 2025

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

Reviewer's Guide

Expose the grid view’s current index via a QML property alias and reset it to 0 when hiding the launcher to prevent stale selections and ensure a consistent user experience on reopen

Class diagram for ListViewPageItem and gridViewIndex property alias

classDiagram
    class ListViewPageItem {
        +int viewIndex
        +int gridViewIndex
    }
    ListViewPageItem : gridViewIndex = gridViewContainer.currentIndex
Loading

File-Level Changes

Change Details Files
Expose grid view current index via property alias
  • Define property alias gridViewIndex pointing to gridViewContainer.currentIndex
  • Expose alias on the list view page item for external access
qml/FullscreenFrame.qml
Reset gridViewIndex when hiding launcher
  • Guard against null listviewPage.currentItem before modifying
  • Set gridViewIndex to 0 during the hide event to clear previous selection
qml/FullscreenFrame.qml

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. 语法逻辑分析:
  • 新增的 property alias gridViewIndex: gridViewContainer.currentIndex 语法正确,使用 alias 属性将内部属性暴露出来
  • 新增的重置逻辑 listviewPage.currentItem.gridViewIndex = 0 语法正确,并且有适当的空值检查
  1. 代码质量:
  • 优点:
    • 添加了空值检查 if (listviewPage.currentItem),避免了潜在的空指针异常
    • 代码缩进和格式符合规范
  • 可改进之处:
    • 缺少注释说明新增属性和重置逻辑的用途
    • gridViewIndex 的命名可以更具描述性,比如 currentGridIndex 可能更清晰
  1. 代码性能:
  • 使用 property alias 是性能较好的选择,不会产生额外的内存开销
  • 重置逻辑只在需要时执行,不会影响性能
  1. 代码安全:
  • 添加了空值检查,提高了代码的健壮性
  • 没有发现明显的安全隐患

改进建议:

  1. 添加注释说明:
// 暴露当前网格视图的索引,用于外部重置
property alias gridViewIndex: gridViewContainer.currentIndex
  1. 在重置逻辑处添加注释:
// 重置网格视图的选中项到第一项
if (listviewPage.currentItem) {
    listviewPage.currentItem.gridViewIndex = 0
}
  1. 考虑将魔法数字 0 定义为常量:
readonly property int defaultGridIndex: 0
...
listviewPage.currentItem.gridViewIndex = defaultGridIndex
  1. 可以考虑将重置逻辑封装成一个函数,提高代码复用性:
function resetGridViewIndex() {
    if (listviewPage.currentItem) {
        listviewPage.currentItem.gridViewIndex = defaultGridIndex
    }
}

总体来说,这个变更实现了功能需求,代码质量良好,但可以通过添加注释和适当的重构来提高可维护性。

@wjyrich wjyrich requested a review from 18202781743 October 24, 2025 03:30

@BLumia BLumia left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

需求文档:

● 关闭启动器后再次进入时,停留在前一次退出的页面;启动器由窗口模式切换到全屏时,停留在首页;

@BLumia BLumia left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我理解错了...

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: BLumia, wjyrich

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

@wjyrich

wjyrich commented Oct 24, 2025

Copy link
Copy Markdown
Contributor Author

/forcemerge

@deepin-bot

deepin-bot Bot commented Oct 24, 2025

Copy link
Copy Markdown

This pr force merged! (status: blocked)

@deepin-bot deepin-bot Bot merged commit 45c7990 into linuxdeepin:master Oct 24, 2025
8 of 10 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