OpenToonz - An open-source full-featured 2D animation creation software
C
Export Scene enhancements
manongjohn7746e5a03df9
diff --git a/stuff/profiles/layouts/rooms/Default/menubar_template.xml b/stuff/profiles/layouts/rooms/Default/menubar_template.xmlindex 1bec09e0e..730a3e1e3 100644--- a/stuff/profiles/layouts/rooms/Default/menubar_template.xml+++ b/stuff/profiles/layouts/rooms/Default/menubar_template.xml@@ -26,6 +26,7 @@<command>MI_ImportMagpieFile</command></menu><menu title="Export">+ <command>MI_ExportCurrentScene</command><command>MI_SoundTrack</command><command>MI_ExportXDTS</command><command>MI_ExportOCA</command>diff --git a/toonz/sources/include/toonzqt/filefield.h b/toonz/sources/include/toonzqt/filefield.hindex 5f28d1a4c..cffa7ceb0 100644--- a/toonz/sources/include/toonzqt/filefield.h+++ b/toonz/sources/include/toonzqt/filefield.h@@ -92,6 +92,7 @@ public:void setValidator(const QValidator *v) { m_field->setValidator(v); }QString getPath();void setPath(const QString &path);+ LineEdit *getField() { return m_field; }static void setBrowserPopupController(BrowserPopupController *controller);static BrowserPopupController *getBrowserPopupController();diff --git a/toonz/sources/toonz/exportscenepopup.cpp b/toonz/sources/toonz/exportscenepopup.cppindex 2a542d790..464cce740 100644--- a/toonz/sources/toonz/exportscenepopup.cpp+++ b/toonz/sources/toonz/exportscenepopup.cpp@@ -28,9 +28,16 @@#include <QPainter>#include <QApplication>#include <QMainWindow>+#include <QStandardPaths>using namespace DVGui;+TFilePath getStdDocumentsPath() {+ QString documentsPath =+ QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation)[0];+ return TFilePath(documentsPath);+}+//------------------------------------------------------------------------namespace {//------------------------------------------------------------------------@@ -526,6 +533,7 @@ ExportScenePopup::ExportScenePopup(std::vector<TFilePath> scenes)m_projectTreeView = new ExportSceneTreeView(chooseProjectWidget);m_projectTreeView->setMinimumWidth(200);+ m_projectTreeView->setMinimumWidth(400);ret = ret && connect(m_projectTreeView, SIGNAL(focusIn()), this,SLOT(onProjectTreeViweFocusIn()));chooseProjectLayout->addWidget(m_projectTreeView);@@ -552,6 +560,16 @@ ExportScenePopup::ExportScenePopup(std::vector<TFilePath> scenes)newProjectLayout->setColumnStretch(1, 5);newProjectLayout->addWidget(m_newProjectName, 1, 1, 1, 1, Qt::AlignLeft);+ m_pathFieldLabel = new QLabel(tr("Create In:"), this);+ m_projectLocationFld =+ new DVGui::FileField(this, getStdDocumentsPath().getQString());+ ret = ret && connect(m_projectLocationFld->getField(), SIGNAL(focusIn()),+ this, SLOT(onProjectNameFocusIn()));++ newProjectLayout->addWidget(m_pathFieldLabel, 2, 0,+ Qt::AlignRight | Qt::AlignVCenter);+ newProjectLayout->addWidget(m_projectLocationFld, 2, 1);+newProjectWidget->setLayout(chooseProjectLayout);layout->addWidget(newProjectWidget);@@ -673,16 +691,16 @@ TFilePath ExportScenePopup::createNewProject() {return TFilePath();}- TFilePath currentProjectRoot;- DvDirModelFileFolderNode *node = dynamic_cast<DvDirModelFileFolderNode *>(- m_projectTreeView->getCurrentNode());- if (node)- currentProjectRoot = node->getPath();- else- currentProjectRoot = pm->getCurrentProjectRoot();- TFilePath projectFolder = currentProjectRoot + projectName;+ TFilePath newLocation = TFilePath(m_projectLocationFld->getPath());+ TFilePath projectFolder = newLocation + projectName;TFilePath projectPath = pm->projectFolderToProjectPath(projectFolder);- TProject *project = new TProject();++ if (TSystem::doesExistFileOrLevel(projectPath)) {+ error(tr("Project '%1' already exists").arg(m_newProjectName->text()));+ return TFilePath();+ }++ TProject *project = new TProject();TProjectP currentProject = pm->getCurrentProject();assert(currentProject);@@ -691,7 +709,7 @@ TFilePath ExportScenePopup::createNewProject() {project->setFolder(currentProject->getFolderName(i),currentProject->getFolder(i));project->save(projectPath);- DvDirModel::instance()->refreshFolder(currentProjectRoot);+ DvDirModel::instance()->refreshFolder(newLocation);return projectPath;}diff --git a/toonz/sources/toonz/exportscenepopup.h b/toonz/sources/toonz/exportscenepopup.hindex f9846be26..580efd2d5 100644--- a/toonz/sources/toonz/exportscenepopup.h+++ b/toonz/sources/toonz/exportscenepopup.h@@ -5,6 +5,7 @@#include "toonzqt/dvdialog.h"#include "toonzqt/lineedit.h"+#include "toonzqt/filefield.h"#include "tfilepath.h"#include "filebrowsermodel.h"#include "dvdirtreeview.h"@@ -163,6 +164,9 @@ class ExportScenePopup final : public DVGui::Dialog {QRadioButton *m_newProjectButton;QRadioButton *m_chooseProjectButton;+ QLabel *m_pathFieldLabel;+ DVGui::FileField *m_projectLocationFld;+bool m_createNewProject;public:diff --git a/toonz/sources/toonz/fileselection.cpp b/toonz/sources/toonz/fileselection.cppindex 69958f370..5475b4809 100644--- a/toonz/sources/toonz/fileselection.cpp+++ b/toonz/sources/toonz/fileselection.cpp@@ -33,6 +33,7 @@#include "toonz/studiopalette.h"#include "toonz/palettecontroller.h"#include "toonz/tpalettehandle.h"+#include "toonz/tscenehandle.h"// TnzCore includes#include "tfiletype.h"@@ -609,6 +610,20 @@ void FileSelection::exportScenes() {//------------------------------------------------------------------------+void FileSelection::exportScene(TFilePath scenePath) {+ if (scenePath.isEmpty()) return;++ std::vector<TFilePath> files;+ files.push_back(scenePath);+ if (!m_exportScenePopup)+ m_exportScenePopup = new ExportScenePopup(files);+ else+ m_exportScenePopup->setScenes(files);+ m_exportScenePopup->show();+}++//------------------------------------------------------------------------+void FileSelection::selectAll() {DvItemSelection::selectAll();const std::set<int> &indices = getSelectedIndices();@@ -621,3 +636,27 @@ void FileSelection::selectAll() {FileBrowser::updateItemViewerPanel();}}++//-----------------------------------------------------------------------------++class ExportCurrentSceneCommandHandler final : public MenuItemHandler {+public:+ ExportCurrentSceneCommandHandler() : MenuItemHandler(MI_ExportCurrentScene) {}+ void execute() override {+ TApp *app = TApp::instance();+ TSceneHandle *sceneHandle = app->getCurrentScene();+ if (!sceneHandle) return;+ ToonzScene *scene = sceneHandle->getScene();+ if (!scene) return;+ TFilePath fp = scene->getScenePath();++ if (sceneHandle->getDirtyFlag() || scene->isUntitled() ||+ !TSystem::doesExistFileOrLevel(fp)) {+ DVGui::warning(tr("You must save the current scene first."));+ return;+ }++ FileSelection *fs = new FileSelection();+ fs->exportScene(fp);+ }+} ExportCurrentSceneCommandHandler;diff --git a/toonz/sources/toonz/fileselection.h b/toonz/sources/toonz/fileselection.hindex f3c76f811..29fd8d567 100644--- a/toonz/sources/toonz/fileselection.h+++ b/toonz/sources/toonz/fileselection.h@@ -43,6 +43,7 @@ public:void collectAssets();void importScenes();void exportScenes();+ void exportScene(TFilePath scenePath);void selectAll();void separateFilesByColors();};diff --git a/toonz/sources/toonz/mainwindow.cpp b/toonz/sources/toonz/mainwindow.cppindex e9d4e53dc..a1fed4b96 100644--- a/toonz/sources/toonz/mainwindow.cpp+++ b/toonz/sources/toonz/mainwindow.cpp@@ -1731,6 +1731,8 @@ void MainWindow::defineActions() {QT_TR_NOOP("&Clear Recent Flipbook Image List"), "");createMenuFileAction(MI_ClearCacheFolder, QT_TR_NOOP("&Clear Cache Folder"),"", "clear_cache");+ createMenuFileAction(MI_ExportCurrentScene,+ QT_TR_NOOP("&Export Current Scene"), "");// Menu - Editdiff --git a/toonz/sources/toonz/menubar.cpp b/toonz/sources/toonz/menubar.cppindex e39e89858..885355eee 100644--- a/toonz/sources/toonz/menubar.cpp+++ b/toonz/sources/toonz/menubar.cpp@@ -1108,6 +1108,7 @@ QMenuBar *StackedMenuBar::createFullMenuBar() {{ addMenuItem(importMenu, MI_ImportMagpieFile); }QMenu *exportMenu = fileMenu->addMenu(tr("Export"));{+ addMenuItem(exportMenu, MI_ExportCurrentScene);addMenuItem(exportMenu, MI_SoundTrack);addMenuItem(exportMenu, MI_ExportXDTS);addMenuItem(exportMenu, MI_ExportOCA);diff --git a/toonz/sources/toonz/menubarcommandids.h b/toonz/sources/toonz/menubarcommandids.hindex 41cd6d810..b749deebc 100644--- a/toonz/sources/toonz/menubarcommandids.h+++ b/toonz/sources/toonz/menubarcommandids.h@@ -261,6 +261,7 @@#define MI_CollectAssets "MI_CollectAssets"#define MI_ImportScenes "MI_ImportScenes"#define MI_ExportScenes "MI_ExportScenes"+#define MI_ExportCurrentScene "MI_ExportCurrentScene"#define MI_SelectRowKeyframes "MI_SelectRowKeyframes"#define MI_SelectColumnKeyframes "MI_SelectColumnKeyframes"