Turn properties in SettingsPage from local variables into fields

This commit is contained in:
yushijinhun 2018-07-20 16:04:38 +08:00
parent 357fef8672
commit 088af981df
No known key found for this signature in database
GPG Key ID: 5BC167F73EA558E4

View File

@ -101,7 +101,10 @@ public final class SettingsPage extends StackPane implements DecoratorPage {
@FXML
private Pane proxyPane;
{
private ObjectProperty<Proxy.Type> selectedProxyType;
private ObjectProperty<EnumBackgroundImage> backgroundType;
public SettingsPage() {
FXUtils.loadFXML(this, "/assets/fxml/setting.fxml");
FXUtils.smoothScrolling(scroll);
@ -148,7 +151,7 @@ public final class SettingsPage extends StackPane implements DecoratorPage {
chkEnableProxy.selectedProperty().bindBidirectional(CONFIG.hasProxyProperty());
chkProxyAuthentication.selectedProperty().bindBidirectional(CONFIG.hasProxyAuthProperty());
ObjectProperty<Proxy.Type> selectedProxyType = new SimpleObjectProperty<Proxy.Type>(Proxy.Type.HTTP) {
selectedProxyType = new SimpleObjectProperty<Proxy.Type>(Proxy.Type.HTTP) {
{
invalidated();
}
@ -184,14 +187,14 @@ public final class SettingsPage extends StackPane implements DecoratorPage {
FXUtils.installTooltip(btnUpdate, i18n("update.tooltip"));
checkUpdate();
// background
// ==== Background ====
backgroundItem.loadChildren(Collections.singletonList(
backgroundItem.createChildren(i18n("launcher.background.default"), EnumBackgroundImage.DEFAULT)
));
backgroundItem.setCustomUserData(EnumBackgroundImage.CUSTOM);
backgroundItem.getTxtCustom().textProperty().bindBidirectional(CONFIG.backgroundImageProperty());
ObjectProperty<EnumBackgroundImage> backgroundType = new SimpleObjectProperty<EnumBackgroundImage>(EnumBackgroundImage.DEFAULT) {
backgroundType = new SimpleObjectProperty<EnumBackgroundImage>(EnumBackgroundImage.DEFAULT) {
{
invalidated();
}
@ -211,8 +214,9 @@ public final class SettingsPage extends StackPane implements DecoratorPage {
new When(backgroundType.isEqualTo(EnumBackgroundImage.DEFAULT))
.then(i18n("launcher.background.default"))
.otherwise(CONFIG.backgroundImageProperty()));
// ====
// theme
// ==== Theme ====
JFXColorPicker picker = new JFXColorPicker(Color.web(CONFIG.getTheme().getColor()), null);
picker.setCustomColorText(i18n("color.custom"));
picker.setRecentColorsText(i18n("color.recent"));
@ -224,6 +228,7 @@ public final class SettingsPage extends StackPane implements DecoratorPage {
});
themeColorPickerContainer.getChildren().setAll(picker);
Platform.runLater(() -> JFXDepthManager.setDepth(picker, 0));
// ====
}
public String getTitle() {