Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -112,6 +115,30 @@ protected Skin<?> createDefaultSkin() {
return new InstallersPageSkin(this);
}

/**
* Determines whether to display the extension pane.
* <p>
* 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()}.
* </p>
*
* @return {@code true} if the extension pane should be displayed; {@code false} otherwise.
*/
protected abstract boolean showExtendPane();

/**
* Resets the name to its default value.
* <p>
* 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.
* </p>
*/
protected abstract void resetDefaultName();
Comment thread
KSSJW marked this conversation as resolved.

protected static class InstallersPageSkin extends SkinBase<AbstractInstallersPage> {
/**
* Constructor for all SkinBase instances.
Expand All @@ -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);
}
Comment thread
KSSJW marked this conversation as resolved.

root.setTop(versionNamePane);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,13 @@ protected void reload() {
@Override
public void cleanup(SettingsMap settings) {
}

@Override
protected boolean showExtendPane() {
return false;
}
Comment thread
KSSJW marked this conversation as resolved.

@Override
protected void resetDefaultName() {
}
Comment thread
KSSJW marked this conversation as resolved.
}
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,15 @@ private void setTxtNameWithLoaders() {
txtName.setText(nameBuilder.toString());
isNameModifiedByUser = false;
}

@Override
protected boolean showExtendPane() {
return true;
}
Comment thread
KSSJW marked this conversation as resolved.

@Override
protected void resetDefaultName() {
isNameModifiedByUser = false;
setTxtNameWithLoaders();
}
Comment thread
KSSJW marked this conversation as resolved.
}