forked from j62/ctbrec
Add menu entry to open the recording dir of a model
This commit is contained in:
parent
84428f8aac
commit
8ae41142d1
|
@ -27,6 +27,7 @@ import ctbrec.recorder.Recorder;
|
|||
import ctbrec.sites.Site;
|
||||
import ctbrec.ui.action.EditNotesAction;
|
||||
import ctbrec.ui.action.FollowAction;
|
||||
import ctbrec.ui.action.OpenRecordingsDir;
|
||||
import ctbrec.ui.action.PauseAction;
|
||||
import ctbrec.ui.action.PlayAction;
|
||||
import ctbrec.ui.action.ResumeAction;
|
||||
|
@ -513,6 +514,8 @@ public class RecordedModelsTab extends Tab implements TabSelectionListener {
|
|||
follow.setOnAction(e -> follow(selectedModels));
|
||||
MenuItem notes = new MenuItem("Notes");
|
||||
notes.setOnAction(e -> notes(selectedModels));
|
||||
MenuItem openRecDir = new MenuItem("Open recording directory");
|
||||
openRecDir.setOnAction(e -> new OpenRecordingsDir(table, selectedModels.get(0)).execute());
|
||||
|
||||
ContextMenu menu = new ContextMenu(stop);
|
||||
if (selectedModels.size() == 1) {
|
||||
|
@ -520,7 +523,7 @@ public class RecordedModelsTab extends Tab implements TabSelectionListener {
|
|||
} else {
|
||||
menu.getItems().addAll(resumeRecording, pauseRecording);
|
||||
}
|
||||
menu.getItems().addAll(copyUrl, openInPlayer, openInBrowser, switchStreamSource, follow, notes);
|
||||
menu.getItems().addAll(copyUrl, openInPlayer, openInBrowser, openRecDir, switchStreamSource, follow, notes);
|
||||
|
||||
if (selectedModels.size() > 1) {
|
||||
copyUrl.setDisable(true);
|
||||
|
|
|
@ -35,6 +35,7 @@ import ctbrec.recorder.Recorder;
|
|||
import ctbrec.sites.Site;
|
||||
import ctbrec.sites.mfc.MyFreeCamsClient;
|
||||
import ctbrec.sites.mfc.MyFreeCamsModel;
|
||||
import ctbrec.ui.action.OpenRecordingsDir;
|
||||
import ctbrec.ui.controls.SearchBox;
|
||||
import ctbrec.ui.controls.SearchPopover;
|
||||
import ctbrec.ui.controls.SearchPopoverTreeList;
|
||||
|
@ -448,6 +449,9 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener {
|
|||
MenuItem refresh = new MenuItem("Refresh");
|
||||
refresh.setOnAction(e -> refresh());
|
||||
|
||||
MenuItem openRecDir = new MenuItem("Open recording directory");
|
||||
openRecDir.setOnAction(e -> new OpenRecordingsDir(cell, cell.getModel()).execute());
|
||||
|
||||
MenuItem copyUrl = createCopyUrlMenuItem(cell);
|
||||
MenuItem sendTip = createTipMenuItem(cell);
|
||||
|
||||
|
@ -469,12 +473,13 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener {
|
|||
if(site.supportsTips()) {
|
||||
contextMenu.getItems().add(sendTip);
|
||||
}
|
||||
contextMenu.getItems().addAll(copyUrl, ignore, refresh);
|
||||
contextMenu.getItems().addAll(copyUrl, ignore, refresh, openRecDir);
|
||||
if(cell.getModel() instanceof MyFreeCamsModel && Objects.equals(System.getenv("CTBREC_DEV"), "1")) {
|
||||
MenuItem debug = new MenuItem("debug");
|
||||
debug.setOnAction(e -> MyFreeCamsClient.getInstance().getSessionState(cell.getModel()));
|
||||
contextMenu.getItems().add(debug);
|
||||
}
|
||||
|
||||
return contextMenu;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
package ctbrec.ui.action;
|
||||
|
||||
import java.io.File;
|
||||
import java.time.Instant;
|
||||
|
||||
import ctbrec.Config;
|
||||
import ctbrec.Model;
|
||||
import ctbrec.ui.DesktopIntegration;
|
||||
import ctbrec.ui.controls.Dialogs;
|
||||
import javafx.scene.Cursor;
|
||||
import javafx.scene.Node;
|
||||
|
||||
public class OpenRecordingsDir {
|
||||
|
||||
private Model selectedModel;
|
||||
private Node source;
|
||||
|
||||
public OpenRecordingsDir(Node source, Model selectedModel) {
|
||||
this.source = source;
|
||||
this.selectedModel = selectedModel;
|
||||
}
|
||||
|
||||
public void execute() {
|
||||
source.setCursor(Cursor.WAIT);
|
||||
File fileForRecording = Config.getInstance().getFileForRecording(selectedModel, ".mp4", Instant.now());
|
||||
File dir = fileForRecording.getParentFile();
|
||||
if (dir.exists()) {
|
||||
new Thread(() -> DesktopIntegration.open(dir)).start();
|
||||
} else {
|
||||
Dialogs.showError(source.getScene(), "Directory does not exist", "There are no recordings for this model", null);
|
||||
}
|
||||
source.setCursor(Cursor.DEFAULT);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue