forked from j62/ctbrec
1
0
Fork 0

Add concurrent recordings setting to settings tab

This commit is contained in:
0xboobface 2019-02-05 15:25:56 +01:00
parent 097fb251cb
commit 351560079b
2 changed files with 22 additions and 1 deletions

View File

@ -72,6 +72,7 @@ public class SettingsTab extends Tab implements TabSelectionListener {
private ToggleGroup recordLocation;
private ProxySettingsPane proxySettingsPane;
private TextField maxResolution;
private TextField concurrentRecordings;
private ComboBox<SplitAfterOption> splitAfter;
private ComboBox<DirectoryStructure> directoryStructure;
private ComboBox<String> startTab;
@ -310,6 +311,26 @@ public class SettingsTab extends Tab implements TabSelectionListener {
GridPane.setMargin(l, new Insets(0, 0, 0, 0));
GridPane.setMargin(maxResolution, new Insets(0, 0, 0, CHECKBOX_MARGIN));
l = new Label("Concurrent Recordings (0 = unlimited)");
layout.add(l, 0, row);
concurrentRecordings = new TextField(Integer.toString(Config.getInstance().getSettings().concurrentRecordings));
concurrentRecordings.textProperty().addListener((observable, oldValue, newValue) -> {
if (!newValue.matches("\\d*")) {
concurrentRecordings.setText(newValue.replaceAll("[^\\d]", ""));
}
if (!concurrentRecordings.getText().isEmpty()) {
int newConcurrentRecordings = Integer.parseInt(concurrentRecordings.getText());
if (newConcurrentRecordings != Config.getInstance().getSettings().concurrentRecordings) {
Config.getInstance().getSettings().concurrentRecordings = newConcurrentRecordings;
saveConfig();
}
}
});
concurrentRecordings.prefWidthProperty().bind(directoryStructure.widthProperty());
layout.add(concurrentRecordings, 1, row++);
GridPane.setMargin(l, new Insets(0, 0, 0, 0));
GridPane.setMargin(concurrentRecordings, new Insets(0, 0, 0, CHECKBOX_MARGIN));
layout.add(new Label("Post-Processing"), 0, row);
postProcessing = new ProgramSelectionBox(Config.getInstance().getSettings().postProcessing);
postProcessing.allowEmptyValue();

View File

@ -214,7 +214,7 @@ public class LocalRecorder implements Recorder {
private boolean downloadSlotAvailable() {
int concurrentRecordings = Config.getInstance().getSettings().concurrentRecordings;
return concurrentRecordings > 0 && recordingProcesses.size() < concurrentRecordings;
return concurrentRecordings == 0 || concurrentRecordings > 0 && recordingProcesses.size() < concurrentRecordings;
}
private void stopRecordingProcess(Model model) {