Skip to content

feat: 为自定义颜色选择对话框添加显式的确认和取消按钮#5775

Open
Mine-diamond wants to merge 8 commits intoHMCL-dev:mainfrom
Mine-diamond:color-picker-comfirm
Open

feat: 为自定义颜色选择对话框添加显式的确认和取消按钮#5775
Mine-diamond wants to merge 8 commits intoHMCL-dev:mainfrom
Mine-diamond:color-picker-comfirm

Conversation

@Mine-diamond
Copy link
Contributor

@Mine-diamond Mine-diamond commented Mar 13, 2026

close #5767

目前的自定义颜色选择对话框的逻辑是点击关闭按钮是触发更新,而Esc是直接关闭,但是我认为这种逻辑比较隐晦,如果用户想要放弃其更改,可能不知道Esc可能直接关闭而不更新
在这个PR中引入显式的操作按钮,并将关闭按钮的逻辑改为直接关闭。

image

@Mine-diamond Mine-diamond changed the title feat: 为自定义颜色选择对话框添加明确的确认和取消按钮 feat: 为自定义颜色选择对话框添加显式的确认和取消按钮 Mar 13, 2026
Copy link
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 通过为自定义颜色选择对话框增加显式的“确定 / 取消”操作,修复“点击关闭按钮也会应用颜色”的隐性行为,使“关闭/取消=放弃更改、确定/回车=应用更改”的交互更直观,关闭 #5767

Changes:

  • 将对话框右上角关闭按钮行为从“应用颜色”改为“直接关闭不应用”。
  • 在自定义颜色对话框底部新增“确定 / 取消”按钮区,并接入现有 i18n 文案键。
  • 为新增按钮区增加 CSS 样式(背景、内边距、右对齐)。

Reviewed changes

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

File Description
HMCL/src/main/resources/assets/css/root.css 新增自定义颜色对话框底部 actions 区域样式类
HMCL/src/main/java/com/jfoenix/skins/JFXCustomColorPickerDialog.java 调整关闭按钮行为,并新增 OK/Cancel 显式操作按钮

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

});

container.getChildren().add(tabs);

Copy link
Member

Choose a reason for hiding this comment

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

为什么这么多空行?

Copy link
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 通过在自定义颜色选择对话框中引入显式的“确定/取消”按钮,并将窗口关闭按钮改为直接关闭(不再隐式应用颜色),来修复/规避用户在未确认情况下颜色被意外应用的问题(close #5767),使交互更直观可控。

Changes:

  • 将自定义颜色对话框标题栏关闭按钮行为从“应用颜色”改为“直接关闭”
  • 在对话框底部新增“确定/取消”操作区:确定应用颜色并触发保存逻辑,取消/关闭则不应用
  • 为新增操作区与按钮新增 CSS 样式

Reviewed changes

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

File Description
HMCL/src/main/resources/assets/css/root.css 增加自定义颜色对话框底部 actions 区与按钮的样式规则
HMCL/src/main/java/com/jfoenix/skins/JFXCustomColorPickerDialog.java 调整关闭行为并新增 OK/Cancel 按钮区;OK 触发 updateColor,Cancel/关闭仅 close

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

Comment on lines +161 to +173
actionsHBox.getStyleClass().add("jfx-color-dialog-actions");

JFXButton acceptButton = new JFXButton(i18n("button.ok"));
acceptButton.setOnAction(event -> updateColor());
acceptButton.getStyleClass().add("jfx-color-dialog-accept");

JFXButton cancelButton = new JFXButton(i18n("button.cancel"));
cancelButton.setOnAction(event -> close());
cancelButton.getStyleClass().add("jfx-color-dialog-cancel");

actionsHBox.getChildren().addAll(acceptButton, cancelButton);
container.getChildren().add(actionsHBox);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

不需要,其他的也没有单独这么做过

}, pane.backgroundProperty()));

acceptButton.textFillProperty().bind(Bindings.createObjectBinding(() -> {
return (Color) pane.getBackground().getFills().get(0).getFill();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

不存在这种问题

.custom-color-dialog .jfx-color-dialog-actions {
-fx-background-color: -monet-surface;
-fx-padding: 0.0 10.0 5.0 0.0;
-fx-alignment: center-right;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

本来按钮就有默认的距离的

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