diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/AbstractInstallersPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/AbstractInstallersPage.java
index b1c2a97d59..96fec6ccfc 100644
--- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/AbstractInstallersPage.java
+++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/AbstractInstallersPage.java
@@ -27,11 +27,14 @@
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.HBox;
+import javafx.scene.layout.Priority;
+
import org.jackhuang.hmcl.download.DownloadProvider;
import org.jackhuang.hmcl.download.LibraryAnalyzer;
import org.jackhuang.hmcl.ui.Controllers;
import org.jackhuang.hmcl.ui.FXUtils;
import org.jackhuang.hmcl.ui.InstallerItem;
+import org.jackhuang.hmcl.ui.SVG;
import org.jackhuang.hmcl.ui.construct.MessageDialogPane;
import org.jackhuang.hmcl.ui.wizard.Navigation;
import org.jackhuang.hmcl.ui.wizard.WizardController;
@@ -112,6 +115,30 @@ protected Skin> createDefaultSkin() {
return new InstallersPageSkin(this);
}
+ /**
+ * Determines whether to display the extension pane.
+ *
+ * This method controls the visibility of the extension pane in the UI.
+ * When this method returns {@code true} and the pane is visible, users can
+ * interact with the features inside it, which includes triggering the
+ * "Reset to Default Name" button handled by {@link #resetDefaultName()}.
+ *
+ *
+ * @return {@code true} if the extension pane should be displayed; {@code false} otherwise.
+ */
+ protected abstract boolean showExtendPane();
+
+ /**
+ * Resets the name to its default value.
+ *
+ * This method contains the business logic for the "Reset to Default Name" button
+ * located within the extension pane. This logic can only be triggered by the user
+ * clicking the corresponding button after {@link #showExtendPane()} returns
+ * {@code true} and the extension pane is successfully displayed.
+ *
+ */
+ protected abstract void resetDefaultName();
+
protected static class InstallersPageSkin extends SkinBase {
/**
* Constructor for all SkinBase instances.
@@ -127,11 +154,27 @@ protected InstallersPageSkin(AbstractInstallersPage control) {
{
HBox versionNamePane = new HBox(8);
versionNamePane.getStyleClass().add("card-non-transparent");
- versionNamePane.setStyle("-fx-padding: 20 8 20 16");
+ versionNamePane.setStyle("-fx-padding: 20 16 20 16");
versionNamePane.setAlignment(Pos.CENTER_LEFT);
- control.txtName.setMaxWidth(300);
- versionNamePane.getChildren().setAll(new Label(i18n("version.name")), control.txtName);
+ HBox.setHgrow(control.txtName, Priority.ALWAYS);
+
+ versionNamePane.getChildren().addAll(new Label(i18n("version.name")), control.txtName);
+
+ if (control.showExtendPane()) {
+ JFXButton clearButton = FXUtils.newToggleButton4(SVG.CLOSE);
+ FXUtils.installFastTooltip(clearButton, i18n("button.clear"));
+ clearButton.disableProperty().bind(control.txtName.textProperty().isEmpty().or(control.txtName.disableProperty()));
+ clearButton.setOnAction(e -> control.txtName.clear());
+
+ JFXButton resetButton = FXUtils.newToggleButton4(SVG.RESTORE);
+ FXUtils.installFastTooltip(resetButton, i18n("button.reset"));
+ resetButton.disableProperty().bind(control.txtName.disableProperty());
+ resetButton.setOnAction(e -> control.resetDefaultName());
+
+ versionNamePane.getChildren().addAll(clearButton, resetButton);
+ }
+
root.setTop(versionNamePane);
}
diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/AdditionalInstallersPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/AdditionalInstallersPage.java
index 7464556d7d..49701af04e 100644
--- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/AdditionalInstallersPage.java
+++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/AdditionalInstallersPage.java
@@ -111,4 +111,13 @@ protected void reload() {
@Override
public void cleanup(SettingsMap settings) {
}
+
+ @Override
+ protected boolean showExtendPane() {
+ return false;
+ }
+
+ @Override
+ protected void resetDefaultName() {
+ }
}
diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/InstallersPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/InstallersPage.java
index 3d07ed74b6..ff8beb5b95 100644
--- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/InstallersPage.java
+++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/InstallersPage.java
@@ -143,4 +143,15 @@ private void setTxtNameWithLoaders() {
txtName.setText(nameBuilder.toString());
isNameModifiedByUser = false;
}
+
+ @Override
+ protected boolean showExtendPane() {
+ return true;
+ }
+
+ @Override
+ protected void resetDefaultName() {
+ isNameModifiedByUser = false;
+ setTxtNameWithLoaders();
+ }
}