Use bindBidirectional for background type
This commit is contained in:
@@ -188,20 +188,30 @@ public final class SettingsPage extends StackPane implements DecoratorPage {
|
|||||||
backgroundItem.loadChildren(Collections.singletonList(
|
backgroundItem.loadChildren(Collections.singletonList(
|
||||||
backgroundItem.createChildren(i18n("launcher.background.default"), EnumBackgroundImage.DEFAULT)
|
backgroundItem.createChildren(i18n("launcher.background.default"), EnumBackgroundImage.DEFAULT)
|
||||||
));
|
));
|
||||||
|
|
||||||
FXUtils.bindString(backgroundItem.getTxtCustom(), CONFIG.backgroundImageProperty());
|
|
||||||
|
|
||||||
backgroundItem.setCustomUserData(EnumBackgroundImage.CUSTOM);
|
backgroundItem.setCustomUserData(EnumBackgroundImage.CUSTOM);
|
||||||
backgroundItem.getGroup().getToggles().stream().filter(it -> it.getUserData() == CONFIG.getBackgroundImageType()).findFirst().ifPresent(it -> it.setSelected(true));
|
backgroundItem.getTxtCustom().textProperty().bindBidirectional(CONFIG.backgroundImageProperty());
|
||||||
|
|
||||||
|
ObjectProperty<EnumBackgroundImage> backgroundType = new SimpleObjectProperty<EnumBackgroundImage>(EnumBackgroundImage.DEFAULT) {
|
||||||
|
{
|
||||||
|
invalidated();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void invalidated() {
|
||||||
|
backgroundItem.getGroup().getToggles().stream()
|
||||||
|
.filter(it -> it.getUserData() == get())
|
||||||
|
.findFirst()
|
||||||
|
.ifPresent(it -> it.setSelected(true));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
backgroundItem.getGroup().selectedToggleProperty().addListener((observable, oldValue, newValue) -> backgroundType.set((EnumBackgroundImage) newValue.getUserData()));
|
||||||
|
backgroundType.bindBidirectional(CONFIG.backgroundImageTypeProperty());
|
||||||
|
|
||||||
backgroundItem.subtitleProperty().bind(
|
backgroundItem.subtitleProperty().bind(
|
||||||
new When(CONFIG.backgroundImageTypeProperty().isEqualTo(EnumBackgroundImage.DEFAULT))
|
new When(backgroundType.isEqualTo(EnumBackgroundImage.DEFAULT))
|
||||||
.then(i18n("launcher.background.default"))
|
.then(i18n("launcher.background.default"))
|
||||||
.otherwise(CONFIG.backgroundImageProperty()));
|
.otherwise(CONFIG.backgroundImageProperty()));
|
||||||
|
|
||||||
backgroundItem.setToggleSelectedListener(newValue ->
|
|
||||||
CONFIG.setBackgroundImageType((EnumBackgroundImage) newValue.getUserData()));
|
|
||||||
|
|
||||||
// theme
|
// theme
|
||||||
JFXColorPicker picker = new JFXColorPicker(Color.web(CONFIG.getTheme().getColor()), null);
|
JFXColorPicker picker = new JFXColorPicker(Color.web(CONFIG.getTheme().getColor()), null);
|
||||||
picker.setCustomColorText(i18n("color.custom"));
|
picker.setCustomColorText(i18n("color.custom"));
|
||||||
|
|||||||
Reference in New Issue
Block a user