diff --git a/app/core.cpp b/app/core.cpp index 1d0e42696..c4aad1c36 100644 --- a/app/core.cpp +++ b/app/core.cpp @@ -53,11 +53,11 @@ #include "render/diskmanager.h" #include "render/pixelformat.h" #include "render/shaderinfo.h" +#include "task/project/exportotio/exportotiotask.h" #include "task/project/import/import.h" #include "task/project/import/importerrordialog.h" #include "task/project/load/load.h" #include "task/project/save/save.h" -#include "task/project/saveotio/projectsaveasotiotask.h" #include "task/taskmanager.h" #include "ui/style/style.h" #include "undo/undostack.h" @@ -272,17 +272,21 @@ void Core::CreateNewProject() #ifdef USE_OTIO void Core::ExportActiveSequenceAsOTIO() { - QString fn = QFileDialog::getSaveFileName(main_window_, - tr("Export as OpenTimelineIO"), - QString(), - tr("OpenTimelineIO (*.otio)")); + ViewerOutput* sequence = GetSequenceToExport(); - if (!fn.isEmpty()) { - fn = FileFunctions::EnsureFilenameExtension(fn, QStringLiteral("otio")); + if (sequence) { + QString fn = QFileDialog::getSaveFileName(main_window_, + tr("Export as OpenTimelineIO"), + QString(), + tr("OpenTimelineIO (*.otio)")); - ProjectSaveAsOTIOTask* task = new ProjectSaveAsOTIOTask(); - TaskDialog* dialog = new TaskDialog(task, tr("Export Sequence"), main_window_); - dialog->open(); + if (!fn.isEmpty()) { + fn = FileFunctions::EnsureFilenameExtension(fn, QStringLiteral("otio")); + + ExportOTIOTask* task = new ExportOTIOTask(sequence, fn); + TaskDialog* dialog = new TaskDialog(task, tr("Export Sequence"), main_window_); + dialog->open(); + } } } #endif @@ -377,30 +381,11 @@ void Core::DialogProjectPropertiesShow() void Core::DialogExportShow() { - // First try the most recently focused time based window - TimeBasedPanel* time_panel = PanelManager::instance()->MostRecentlyFocused(); + ViewerOutput* sequence = GetSequenceToExport(); - // If that fails try defaulting to the first timeline (i.e. if a project has just been loaded). - if (!time_panel->GetConnectedViewer()) { - // Safe to assume there will always be one timeline. - time_panel = PanelManager::instance()->GetPanelsOfType().first(); - } - - if (time_panel && time_panel->GetConnectedViewer()) { - if (time_panel->GetConnectedViewer()->GetLength() == 0) { - QMessageBox::critical(main_window_, - tr("Error"), - tr("This Sequence is empty. There is nothing to export."), - QMessageBox::Ok); - } else { - ExportDialog ed(time_panel->GetConnectedViewer(), main_window_); - ed.exec(); - } - } else { - QMessageBox::critical(main_window_, - tr("Error"), - tr("No valid sequence detected.\n\nMake sure a sequence is loaded and it has a connected Viewer node."), - QMessageBox::Ok); + if (sequence) { + ExportDialog ed(sequence, main_window_); + ed.exec(); } } @@ -736,6 +721,36 @@ void Core::SaveProjectInternal(ProjectPtr project) task_dialog->open(); } +ViewerOutput *Core::GetSequenceToExport() +{ + // First try the most recently focused time based window + TimeBasedPanel* time_panel = PanelManager::instance()->MostRecentlyFocused(); + + // If that fails try defaulting to the first timeline (i.e. if a project has just been loaded). + if (!time_panel->GetConnectedViewer()) { + // Safe to assume there will always be one timeline. + time_panel = PanelManager::instance()->GetPanelsOfType().first(); + } + + if (time_panel && time_panel->GetConnectedViewer()) { + if (time_panel->GetConnectedViewer()->GetLength() == 0) { + QMessageBox::critical(main_window_, + tr("Error"), + tr("This Sequence is empty. There is nothing to export."), + QMessageBox::Ok); + } else { + return time_panel->GetConnectedViewer(); + } + } else { + QMessageBox::critical(main_window_, + tr("Error"), + tr("No valid sequence detected.\n\nMake sure a sequence is loaded and it has a connected Viewer node."), + QMessageBox::Ok); + } + + return nullptr; +} + void Core::SaveAutorecovery() { foreach (ProjectPtr p, open_projects_) { diff --git a/app/core.h b/app/core.h index bccc1c81d..773dd54e1 100644 --- a/app/core.h +++ b/app/core.h @@ -462,6 +462,11 @@ private: */ void SaveProjectInternal(ProjectPtr project); + /** + * @brief Retrieves the currently most active sequence for exporting + */ + ViewerOutput* GetSequenceToExport(); + /** * @brief Internal main window object */