mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-10 20:37:30 -04:00
Remember the last used login type
This commit is contained in:
parent
a1d9b52b9d
commit
594a2741d7
@ -157,6 +157,12 @@ public final class Config implements Cloneable, Observable {
|
|||||||
@SerializedName("uiVersion")
|
@SerializedName("uiVersion")
|
||||||
private IntegerProperty uiVersion = new SimpleIntegerProperty(0);
|
private IntegerProperty uiVersion = new SimpleIntegerProperty(0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The preferred login type to use when the user wants to add an account.
|
||||||
|
*/
|
||||||
|
@SerializedName("preferredLoginType")
|
||||||
|
private StringProperty preferredLoginType = new SimpleStringProperty();
|
||||||
|
|
||||||
private transient ObservableHelper helper = new ObservableHelper(this);
|
private transient ObservableHelper helper = new ObservableHelper(this);
|
||||||
|
|
||||||
public Config() {
|
public Config() {
|
||||||
@ -475,4 +481,16 @@ public final class Config implements Cloneable, Observable {
|
|||||||
public void setUiVersion(int uiVersion) {
|
public void setUiVersion(int uiVersion) {
|
||||||
this.uiVersion.set(uiVersion);
|
this.uiVersion.set(uiVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getPreferredLoginType() {
|
||||||
|
return preferredLoginType.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPreferredLoginType(String preferredLoginType) {
|
||||||
|
this.preferredLoginType.set(preferredLoginType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StringProperty preferredLoginTypeProperty() {
|
||||||
|
return preferredLoginType;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,12 @@ public class AddAccountPane extends StackPane {
|
|||||||
|
|
||||||
cboType.getItems().setAll(Accounts.FACTORY_OFFLINE, Accounts.FACTORY_YGGDRASIL, Accounts.FACTORY_AUTHLIB_INJECTOR);
|
cboType.getItems().setAll(Accounts.FACTORY_OFFLINE, Accounts.FACTORY_YGGDRASIL, Accounts.FACTORY_AUTHLIB_INJECTOR);
|
||||||
cboType.setConverter(stringConverter(Accounts::getAccountTypeName));
|
cboType.setConverter(stringConverter(Accounts::getAccountTypeName));
|
||||||
cboType.getSelectionModel().select(0);
|
// try selecting the preferred login type
|
||||||
|
cboType.getSelectionModel().select(
|
||||||
|
cboType.getItems().stream()
|
||||||
|
.filter(type -> Accounts.getAccountTypeName(type).equals(config().getPreferredLoginType()))
|
||||||
|
.findFirst()
|
||||||
|
.orElse(Accounts.FACTORY_OFFLINE));
|
||||||
|
|
||||||
btnAddServer.visibleProperty().bind(cboServers.visibleProperty());
|
btnAddServer.visibleProperty().bind(cboServers.visibleProperty());
|
||||||
btnManageServer.visibleProperty().bind(cboServers.visibleProperty());
|
btnManageServer.visibleProperty().bind(cboServers.visibleProperty());
|
||||||
@ -91,6 +96,9 @@ public class AddAccountPane extends StackPane {
|
|||||||
|
|
||||||
ReadOnlyObjectProperty<AccountFactory<?>> loginType = cboType.getSelectionModel().selectedItemProperty();
|
ReadOnlyObjectProperty<AccountFactory<?>> loginType = cboType.getSelectionModel().selectedItemProperty();
|
||||||
|
|
||||||
|
// remember the last used login type
|
||||||
|
loginType.addListener((observable, oldValue, newValue) -> config().setPreferredLoginType(Accounts.getAccountTypeName(newValue)));
|
||||||
|
|
||||||
txtPassword.visibleProperty().bind(loginType.isNotEqualTo(Accounts.FACTORY_OFFLINE));
|
txtPassword.visibleProperty().bind(loginType.isNotEqualTo(Accounts.FACTORY_OFFLINE));
|
||||||
lblPassword.visibleProperty().bind(txtPassword.visibleProperty());
|
lblPassword.visibleProperty().bind(txtPassword.visibleProperty());
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user