diff --git a/CHANGELOG.md b/CHANGELOG.md index 80cdff2b..8e9492b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +4.6.2 +======================== +* Add setting to define a default period for "record until" + 4.6.1 ======================== * Fixed adding of Streamate models diff --git a/client/src/main/java/ctbrec/ui/RecordUntilDialog.java b/client/src/main/java/ctbrec/ui/RecordUntilDialog.java index 0698a4a1..05e85fae 100644 --- a/client/src/main/java/ctbrec/ui/RecordUntilDialog.java +++ b/client/src/main/java/ctbrec/ui/RecordUntilDialog.java @@ -6,6 +6,7 @@ import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; +import ctbrec.Config; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -27,14 +28,15 @@ public class RecordUntilDialog { private static final Logger LOG = LoggerFactory.getLogger(RecordUntilDialog.class); - private Node source; - private Model model; + private final Node source; + private final Model model; + private final GridPane gridPane = new GridPane(); private RadioButton pauseButton; private RadioButton removeButton; - private RadioButton recordLaterButton; private DateTimePicker datePicker; - private GridPane gridPane = new GridPane(); + + private Config config = Config.getInstance(); public RecordUntilDialog(Node source, Model model) { this.source = source; @@ -61,7 +63,7 @@ public class RecordUntilDialog { removeButton = new RadioButton("remove model"); removeButton.setSelected(model.getRecordUntilSubsequentAction() == REMOVE); removeButton.setToggleGroup(toggleGroup); - recordLaterButton = new RadioButton("mark for later"); + RadioButton recordLaterButton = new RadioButton("mark for later"); recordLaterButton.setSelected(model.getRecordUntilSubsequentAction() == RECORD_LATER); recordLaterButton.setToggleGroup(toggleGroup); var row = new VBox(); @@ -73,6 +75,9 @@ public class RecordUntilDialog { if (model.isRecordingTimeLimited()) { var localDate = LocalDateTime.ofInstant(model.getRecordUntil(), ZoneId.systemDefault()); datePicker.setDateTimeValue(localDate); + } else { + var localDate = LocalDateTime.now().plusHours(config.getSettings().recordUntilDefaultPeriodInHours); + datePicker.setDateTimeValue(localDate); } } diff --git a/client/src/main/java/ctbrec/ui/settings/SettingsTab.java b/client/src/main/java/ctbrec/ui/settings/SettingsTab.java index fea75547..8f57c957 100644 --- a/client/src/main/java/ctbrec/ui/settings/SettingsTab.java +++ b/client/src/main/java/ctbrec/ui/settings/SettingsTab.java @@ -143,6 +143,7 @@ public class SettingsTab extends Tab implements TabSelectionListener { private SimpleIntegerProperty defaultPriority; private LocalTimeProperty timeoutRecordingStartingAt; private LocalTimeProperty timeoutRecordingEndingAt; + private SimpleLongProperty recordUntilDefaultPeriodInHours; public SettingsTab(List sites, Recorder recorder) { this.sites = sites; @@ -212,6 +213,7 @@ public class SettingsTab extends Tab implements TabSelectionListener { defaultPriority = new SimpleIntegerProperty(null, "defaultPriority", settings.defaultPriority); timeoutRecordingStartingAt = new LocalTimeProperty(null, "timeoutRecordingStartingAt", settings.timeoutRecordingStartingAt); timeoutRecordingEndingAt = new LocalTimeProperty(null, "timeoutRecordingEndingAt", settings.timeoutRecordingEndingAt); + recordUntilDefaultPeriodInHours = new SimpleLongProperty(null, "recordUntilDefaultPeriodInHours", settings.recordUntilDefaultPeriodInHours); } private void createGui() { @@ -265,6 +267,7 @@ public class SettingsTab extends Tab implements TabSelectionListener { Setting.of("Restrict Resolution", resolutionRange, "Only record streams with resolution within the given range"), Setting.of("Concurrent Recordings (0 = unlimited)", concurrentRecordings), Setting.of("Default Priority", defaultPriority), + Setting.of("Default period for \"Record until\" (hours)", recordUntilDefaultPeriodInHours), Setting.of("Leave space on device (GiB)", leaveSpaceOnDevice, "Stop recording, if the free space on the device gets below this threshold").converter(new GigabytesConverter()), Setting.of("FFmpeg parameters", ffmpegParameters, "FFmpeg parameters to use when merging stream segments"), diff --git a/common/src/main/java/ctbrec/Settings.java b/common/src/main/java/ctbrec/Settings.java index 48158097..da0dd777 100644 --- a/common/src/main/java/ctbrec/Settings.java +++ b/common/src/main/java/ctbrec/Settings.java @@ -161,6 +161,7 @@ public class Settings { public DirectoryStructure recordingsDirStructure = DirectoryStructure.FLAT; public List recordLater = new ArrayList<>(); public boolean recordSingleFile = false; + public long recordUntilDefaultPeriodInHours = 24L; public boolean removeRecordingAfterPostProcessing = false; public boolean requireAuthentication = false; public String servletContext = "";