Add record later as subsequent action for time limmited recordings
This commit is contained in:
parent
f05353c3e5
commit
ab209ca2c1
|
@ -14,13 +14,14 @@ import ctbrec.SubsequentAction;
|
|||
import ctbrec.ui.controls.DateTimePicker;
|
||||
import ctbrec.ui.controls.Dialogs;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.VPos;
|
||||
import javafx.scene.Cursor;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.RadioButton;
|
||||
import javafx.scene.control.ToggleGroup;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.VBox;
|
||||
|
||||
public class RecordUntilDialog {
|
||||
|
||||
|
@ -30,6 +31,8 @@ public class RecordUntilDialog {
|
|||
private Model model;
|
||||
|
||||
private RadioButton pauseButton;
|
||||
private RadioButton removeButton;
|
||||
private RadioButton recordLaterButton;
|
||||
private DateTimePicker datePicker;
|
||||
private GridPane gridPane = new GridPane();
|
||||
|
||||
|
@ -47,18 +50,25 @@ public class RecordUntilDialog {
|
|||
gridPane.setPadding(new Insets(20, 150, 10, 10));
|
||||
gridPane.add(new Label("Stop at"), 0, 0);
|
||||
gridPane.add(datePicker, 1, 0);
|
||||
gridPane.add(new Label("And then"), 0, 1);
|
||||
Label l = new Label("And then");
|
||||
l.setPadding(new Insets(5, 0, 0, 0));
|
||||
gridPane.add(l, 0, 1);
|
||||
GridPane.setValignment(l, VPos.TOP);
|
||||
var toggleGroup = new ToggleGroup();
|
||||
pauseButton = new RadioButton("pause recording");
|
||||
pauseButton.setSelected(model.getRecordUntilSubsequentAction() == PAUSE);
|
||||
pauseButton.setToggleGroup(toggleGroup);
|
||||
var removeButton = new RadioButton("remove model");
|
||||
removeButton = new RadioButton("remove model");
|
||||
removeButton.setSelected(model.getRecordUntilSubsequentAction() == REMOVE);
|
||||
removeButton.setToggleGroup(toggleGroup);
|
||||
var row = new HBox();
|
||||
row.getChildren().addAll(pauseButton, removeButton);
|
||||
HBox.setMargin(pauseButton, new Insets(5));
|
||||
HBox.setMargin(removeButton, new Insets(5));
|
||||
recordLaterButton = new RadioButton("mark for later");
|
||||
recordLaterButton.setSelected(model.getRecordUntilSubsequentAction() == RECORD_LATER);
|
||||
recordLaterButton.setToggleGroup(toggleGroup);
|
||||
var row = new VBox();
|
||||
row.getChildren().addAll(pauseButton, removeButton, recordLaterButton);
|
||||
VBox.setMargin(pauseButton, new Insets(5));
|
||||
VBox.setMargin(removeButton, new Insets(5));
|
||||
VBox.setMargin(recordLaterButton, new Insets(5));
|
||||
gridPane.add(row, 1, 1);
|
||||
if (model.isRecordingTimeLimited()) {
|
||||
var localDate = LocalDateTime.ofInstant(model.getRecordUntil(), ZoneId.systemDefault());
|
||||
|
@ -69,7 +79,7 @@ public class RecordUntilDialog {
|
|||
public boolean showAndWait() {
|
||||
boolean confirmed = Dialogs.showCustomInput(source.getScene(), "Stop Recording of " + model.getDisplayName() + " at", gridPane);
|
||||
if (confirmed) {
|
||||
SubsequentAction action = pauseButton.isSelected() ? PAUSE : REMOVE;
|
||||
SubsequentAction action = getSubsequentAction();
|
||||
LOG.info("Stop at {} and {}", datePicker.getDateTimeValue(), action);
|
||||
var stopAt = Instant.from(datePicker.getDateTimeValue().atZone(ZoneId.systemDefault()));
|
||||
model.setRecordUntil(stopAt);
|
||||
|
@ -77,4 +87,14 @@ public class RecordUntilDialog {
|
|||
}
|
||||
return confirmed;
|
||||
}
|
||||
|
||||
private SubsequentAction getSubsequentAction() {
|
||||
if (pauseButton.isSelected()) {
|
||||
return PAUSE;
|
||||
} else if (removeButton.isSelected()) {
|
||||
return REMOVE;
|
||||
} else {
|
||||
return RECORD_LATER;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,5 +2,6 @@ package ctbrec;
|
|||
|
||||
public enum SubsequentAction {
|
||||
PAUSE,
|
||||
REMOVE
|
||||
REMOVE,
|
||||
RECORD_LATER
|
||||
}
|
||||
|
|
|
@ -319,15 +319,22 @@ public class NextGenLocalRecorder implements Recorder {
|
|||
}
|
||||
|
||||
private void executeRecordUntilSubsequentAction(Model model) {
|
||||
LOG.debug("Stopping recording {} because the recording timeframe ended at {}. Subsequent action is {}", model,
|
||||
model.getRecordUntil().atZone(ZoneId.systemDefault()), model.getRecordUntilSubsequentAction());
|
||||
if (model.getRecordUntilSubsequentAction() == PAUSE) {
|
||||
model.setSuspended(true);
|
||||
} else if (model.getRecordUntilSubsequentAction() == REMOVE) {
|
||||
try {
|
||||
LOG.info("Removing {} because the recording timeframe ended at {}", model, model.getRecordUntil().atZone(ZoneId.systemDefault()));
|
||||
stopRecording(model);
|
||||
} catch (Exception e1) {
|
||||
LOG.error("Error while stopping recording", e1);
|
||||
}
|
||||
} else if (model.getRecordUntilSubsequentAction() == RECORD_LATER) {
|
||||
try {
|
||||
markForLaterRecording(model, true);
|
||||
} catch (Exception e1) {
|
||||
LOG.error("Error while stopping recording", e1);
|
||||
}
|
||||
}
|
||||
// reset values, so that model can be recorded again
|
||||
model.setRecordUntil(null);
|
||||
|
|
Loading…
Reference in New Issue