mirror of
https://github.com/octopusYan/alist-gui.git
synced 2024-11-21 19:56:41 +08:00
fix: 修复代理类型下拉框无法跟随语言切换的问题
This commit is contained in:
parent
4702396bbc
commit
828a2fdb62
@ -6,6 +6,7 @@ import cn.octopusyan.alistgui.config.Context;
|
||||
import cn.octopusyan.alistgui.config.I18n;
|
||||
import cn.octopusyan.alistgui.enums.ProxySetup;
|
||||
import cn.octopusyan.alistgui.manager.ConfigManager;
|
||||
import cn.octopusyan.alistgui.view.ProxySetupCell;
|
||||
import cn.octopusyan.alistgui.viewModel.SetupViewModel;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.fxml.FXML;
|
||||
@ -60,6 +61,9 @@ public class SetupController extends BaseController<SetupViewModel> implements I
|
||||
themeComboBox.setItems(FXCollections.observableList(ConfigManager.THEME_LIST));
|
||||
proxySetupComboBox.setItems(FXCollections.observableList(List.of(ProxySetup.values())));
|
||||
|
||||
proxySetupComboBox.setCellFactory(_ -> new ProxySetupCell());
|
||||
proxySetupComboBox.setButtonCell(new ProxySetupCell());
|
||||
|
||||
themeComboBox.setConverter(new StringConverter<>() {
|
||||
@Override
|
||||
public String toString(Theme object) {
|
||||
@ -78,6 +82,14 @@ public class SetupController extends BaseController<SetupViewModel> implements I
|
||||
proxySetupComboBox.getSelectionModel().selectedItemProperty().addListener((_, _, newValue) -> {
|
||||
proxySetupPane.setVisible(ProxySetup.MANUAL.equals(newValue));
|
||||
proxyCheck.setVisible(!ProxySetup.NO_PROXY.equals(newValue));
|
||||
|
||||
// proxySetupComboBox.promptTextProperty().bind(
|
||||
//// Bindings.createStringBinding(
|
||||
//// () -> Context.getLanguageBinding(STR."proxy.setup.label.\{newValue.getName()}").get(),
|
||||
//// Context.currentLocaleProperty()
|
||||
//// )
|
||||
// Context.getLanguageBinding(STR."proxy.setup.label.\{newValue.getName()}")
|
||||
// );
|
||||
});
|
||||
|
||||
languageComboBox.getSelectionModel().select(ConfigManager.language());
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cn.octopusyan.alistgui.enums;
|
||||
|
||||
import cn.octopusyan.alistgui.config.Context;
|
||||
import javafx.beans.binding.StringBinding;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@ -20,6 +21,10 @@ public enum ProxySetup {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Context.getLanguageBinding("proxy.setup.label." + getName()).getValue();
|
||||
return getBinding().get();
|
||||
}
|
||||
|
||||
public StringBinding getBinding() {
|
||||
return Context.getLanguageBinding(STR."proxy.setup.label.\{getName()}");
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,23 @@
|
||||
package cn.octopusyan.alistgui.view;
|
||||
|
||||
import cn.octopusyan.alistgui.enums.ProxySetup;
|
||||
import javafx.scene.control.ListCell;
|
||||
|
||||
/**
|
||||
* ProxySetup I18n Cell
|
||||
*
|
||||
* @author octopus_yan
|
||||
*/
|
||||
public class ProxySetupCell extends ListCell<ProxySetup> {
|
||||
|
||||
@Override
|
||||
protected void updateItem(ProxySetup item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
textProperty().unbind();
|
||||
if (empty || item == null) {
|
||||
setText("");
|
||||
} else {
|
||||
textProperty().bind(item.getBinding());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user