Skip to content

优化工具栏“全选”功能#5867

Open
CiiLu wants to merge 2 commits intoHMCL-dev:mainfrom
CiiLu:selecterererer
Open

优化工具栏“全选”功能#5867
CiiLu wants to merge 2 commits intoHMCL-dev:mainfrom
CiiLu:selecterererer

Conversation

@CiiLu
Copy link
Copy Markdown
Contributor

@CiiLu CiiLu commented Mar 28, 2026

  • 修复模组管理点击全选会工具栏会闪烁的问题
  • 在全选时禁用全选按钮

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

该 PR 针对版本管理页(模组/数据包列表)工具栏的“全选”交互进行优化:避免“全选”触发选择状态短暂清空导致的工具栏闪烁,并在已全选状态下禁用“全选”按钮以减少无效操作。

Changes:

  • 将“全选”从 selectAll() 改为 selectRange(0, items.size()),减少选择状态抖动引起的工具栏闪烁
  • 监听选中项变化,在已全选时禁用“全选”按钮
    -(ModListPageSkin)将 org.jackhuang.hmcl.util.* 通配导入改为显式导入

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/ModListPageSkin.java 调整模组列表“全选”实现并新增“全选按钮在全选时禁用”的逻辑
HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/DataPackListPageSkin.java 调整数据包列表“全选”实现并新增“全选按钮在全选时禁用”的逻辑

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +127 to +135
// reason for not using selectAll() is that selectAll() first clears all selected then selects all, causing the toolbar to flicker
var selectAllButton = createToolbarButton2(i18n("button.select_all"), SVG.SELECT_ALL, () -> listView.getSelectionModel().selectRange(0, listView.getItems().size()));

listView.getSelectionModel().getSelectedItems().addListener(
(ListChangeListener<Object>) change -> {
selectAllButton.setDisable(!listView.getItems().isEmpty()
&& listView.getSelectionModel().getSelectedItems().size() == listView.getItems().size());
}
);
Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

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

The select-all button disable state is updated only when selectedItems changes and isn’t initialized. If listView.getItems() size changes (e.g., filtering/search updates) without a selection change, the button can remain disabled/enabled incorrectly. Consider binding disableProperty to a condition that observes both items size and selectedItems size, and ensure it’s evaluated once initially.

Copilot uses AI. Check for mistakes.
@Glavo
Copy link
Copy Markdown
Member

Glavo commented Apr 5, 2026

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d570b7a231

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

};

listView.getSelectionModel().getSelectedItems().addListener(listener);
listView.getItems().addListener(listener);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Attach select-all listener to current ListView items

listView.getItems().addListener(listener) is registered before setItems(filteredList) is called, so this listener stays attached to the initial default list instead of the actual filteredList backing the view. As a result, the new select-all disable state is not recomputed when the displayed datapack list changes without a selection change (for example when items are refreshed/updated), and the button can remain incorrectly disabled after the list size changes. Register the items listener after setItems(...) (or observe itemsProperty) so it tracks the active list.

Useful? React with 👍 / 👎.

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