Skip to content

feat: 文件选择器支持选择文件和文件夹#5806

Open
Mine-diamond wants to merge 4 commits intoHMCL-dev:mainfrom
Mine-diamond:file-selector
Open

feat: 文件选择器支持选择文件和文件夹#5806
Mine-diamond wants to merge 4 commits intoHMCL-dev:mainfrom
Mine-diamond:file-selector

Conversation

@Mine-diamond
Copy link
Copy Markdown
Contributor

fix #5794

在仅支持选择文件和文件夹的地方的表现不变,而同时支持选择文件或文件夹的情况下弹出选项

image

Comment thread HMCL/src/main/resources/assets/lang/I18N_zh.properties Outdated
Co-authored-by: 3gf8jv4dv <3gf8jv4dv@gmail.com>
@Glavo
Copy link
Copy Markdown
Member

Glavo commented Apr 20, 2026

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the FileSelector component to support a new SelectionMode enum, allowing for file, directory, or dual selection via a popup menu. It also adds a new SVG icon and corresponding localization strings. A review comment suggests adjusting the popup's horizontal alignment and vertical offset to prevent UI clipping and improve the user interface consistency.

new IconedMenuItem(SVG.FOLDER_OPEN, i18n("selector.choose_directory"), () -> openDirectoryChooser(customField), selectModePopup)
);

selectModePopup.show(selectButton, JFXPopup.PopupVPosition.TOP, JFXPopup.PopupHPosition.LEFT, selectButton.getWidth(), 0);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

弹出菜单的显示位置可能存在问题。在 HMCL 的设置界面中,文件选择按钮通常位于界面的最右侧。使用 PopupHPosition.LEFT 配合 selectButton.getWidth() 的偏移量,会使弹出菜单从按钮的右边缘开始向右展开,这极有可能导致菜单超出窗口边界而被裁剪。

建议将水平对齐方式改为 PopupHPosition.RIGHT,并将 Y 轴偏移量设置为按钮的高度,以便菜单能够对齐按钮右侧并向下展开,这更符合下拉菜单的交互习惯。

Suggested change
selectModePopup.show(selectButton, JFXPopup.PopupVPosition.TOP, JFXPopup.PopupHPosition.LEFT, selectButton.getWidth(), 0);
selectModePopup.show(selectButton, JFXPopup.PopupVPosition.TOP, JFXPopup.PopupHPosition.RIGHT, selectButton.getWidth(), selectButton.getHeight());

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.

[Bug] 壁纸设置中没有提供文件夹选择模式

3 participants