diff --git a/client/src/main/java/ctbrec/ui/settings/SettingsTab.java b/client/src/main/java/ctbrec/ui/settings/SettingsTab.java index d0794572..4916974f 100644 --- a/client/src/main/java/ctbrec/ui/settings/SettingsTab.java +++ b/client/src/main/java/ctbrec/ui/settings/SettingsTab.java @@ -70,7 +70,7 @@ public class SettingsTab extends Tab implements TabSelectionListener { private RadioButton recordRemote; private ToggleGroup recordLocation; private ProxySettingsPane proxySettingsPane; - private ComboBox maxResolution; + private TextField maxResolution; private ComboBox splitAfter; private ComboBox directoryStructure; private ComboBox startTab; @@ -264,26 +264,7 @@ public class SettingsTab extends Tab implements TabSelectionListener { layout.add(directoryStructure, 1, row++); recordingsDirectory.prefWidthProperty().bind(directoryStructure.widthProperty()); - Label l = new Label("Maximum resolution (0 = unlimited)"); - layout.add(l, 0, row); - List resolutionOptions = new ArrayList<>(); - resolutionOptions.add(1080); - resolutionOptions.add(720); - resolutionOptions.add(600); - resolutionOptions.add(480); - resolutionOptions.add(0); - maxResolution = new ComboBox<>(FXCollections.observableList(resolutionOptions)); - setMaxResolutionValue(); - maxResolution.setOnAction((e) -> { - Config.getInstance().getSettings().maximumResolution = maxResolution.getSelectionModel().getSelectedItem(); - saveConfig(); - }); - maxResolution.prefWidthProperty().bind(directoryStructure.widthProperty()); - layout.add(maxResolution, 1, row++); - GridPane.setMargin(l, new Insets(0, 0, 0, 0)); - GridPane.setMargin(maxResolution, new Insets(0, 0, 0, CHECKBOX_MARGIN)); - - l = new Label("Split recordings after (minutes)"); + Label l = new Label("Split recordings after (minutes)"); layout.add(l, 0, row); List splitOptions = new ArrayList<>(); splitOptions.add(new SplitAfterOption("disabled", 0)); @@ -308,6 +289,26 @@ public class SettingsTab extends Tab implements TabSelectionListener { GridPane.setMargin(l, new Insets(0, 0, 0, 0)); GridPane.setMargin(splitAfter, new Insets(0, 0, 0, CHECKBOX_MARGIN)); + l = new Label("Maximum resolution (0 = unlimited)"); + layout.add(l, 0, row); + maxResolution = new TextField(Integer.toString(Config.getInstance().getSettings().maximumResolution)); + maxResolution.textProperty().addListener((observable, oldValue, newValue) -> { + if (!newValue.matches("\\d*")) { + maxResolution.setText(newValue.replaceAll("[^\\d]", "")); + } + if (!maxResolution.getText().isEmpty()) { + int newRes = Integer.parseInt(maxResolution.getText()); + if (newRes != Config.getInstance().getSettings().maximumResolution) { + Config.getInstance().getSettings().maximumResolution = newRes; + saveConfig(); + } + } + }); + maxResolution.prefWidthProperty().bind(directoryStructure.widthProperty()); + layout.add(maxResolution, 1, row++); + GridPane.setMargin(l, new Insets(0, 0, 0, 0)); + GridPane.setMargin(maxResolution, new Insets(0, 0, 0, CHECKBOX_MARGIN)); + layout.add(new Label("Post-Processing"), 0, row); // TODO allow empty strings to remove post-processing scripts postProcessing = new ProgramSelectionBox(Config.getInstance().getSettings().postProcessing); @@ -504,15 +505,6 @@ public class SettingsTab extends Tab implements TabSelectionListener { } } - private void setMaxResolutionValue() { - int value = Config.getInstance().getSettings().maximumResolution; - for (Integer option : maxResolution.getItems()) { - if(option == value) { - maxResolution.getSelectionModel().select(option); - } - } - } - void showRestartRequired() { restartLabel.setVisible(true); }