OpenToonz - An open-source full-featured 2D animation creation software
C
Add Open Folder and Exported Levels Count support to Export Level
Abel Youd0631f6110d8
diff --git a/toonz/sources/toonz/exportalllevelspopup.cpp b/toonz/sources/toonz/exportalllevelspopup.cppindex 691c15e32..b505d92d2 100644--- a/toonz/sources/toonz/exportalllevelspopup.cpp+++ b/toonz/sources/toonz/exportalllevelspopup.cpp@@ -166,7 +166,17 @@ ExportAllLevelsPopup::~ExportAllLevelsPopup() {//------------------------------------void ExportAllLevelsPopup::showEvent(QShowEvent *se) {-++ collectSelectedSimpleLevels(); // also init level_to_foldername,and sort+ // them++ if (outputLevels.empty()) {+ DVGui::error(+ tr("No level found in the camera view or levels are null!!"));+ QTimer::singleShot(0, this, &ExportAllLevelsPopup::hide);+ return;+ }+if (Preferences::instance()->getPixelsOnly()) {m_exportOptions->m_widthFld->hide();m_exportOptions->m_heightFld->hide();@@ -184,15 +194,6 @@ void ExportAllLevelsPopup::showEvent(QShowEvent *se) {// reset maplevel_to_foldername.clear();- collectSelectedSimpleLevels(); // also init level_to_foldername,and sort- // them-- if (outputLevels.empty()) {- QTimer::singleShot(1000, this, &ExportAllLevelsPopup::hide);- DVGui::error(tr("No levels found in the camera view or levels are null!!"));- return;- }-onExportAll(m_isExportAll);updateOnSelection();diff --git a/toonz/sources/toonz/exportalllevelspopup.h b/toonz/sources/toonz/exportalllevelspopup.hindex 543619d9c..7a7467cc7 100644--- a/toonz/sources/toonz/exportalllevelspopup.h+++ b/toonz/sources/toonz/exportalllevelspopup.h@@ -15,7 +15,6 @@ public:private:bool m_isExportAll; // set to false when "Export All" is unchecked- int m_levelExportedCount = 0;std::map<std::wstring ,std::wstring> level_to_foldername;std::wstring backFolderName(std::string colname, std::wstring levelname);bool isAllLevelsExported();diff --git a/toonz/sources/toonz/exportlevelpopup.cpp b/toonz/sources/toonz/exportlevelpopup.cppindex 255e47a8f..217ef50f6 100644--- a/toonz/sources/toonz/exportlevelpopup.cpp+++ b/toonz/sources/toonz/exportlevelpopup.cpp@@ -55,6 +55,7 @@#include <QSplitter>#include <QToolBar>#include <QMessageBox>+#include <QDesktopServices>//********************************************************************************// Export callbacks definition@@ -443,6 +444,7 @@ void ExportLevelPopup::hideEvent(QHideEvent *he) {TApp *app = TApp::instance();+ m_levelExportedCount=0;app->getCurrentSelection()->disconnect(this);app->getCurrentLevel()->disconnect(this);@@ -631,10 +633,10 @@ bool ExportLevelPopup::execute() {// Whether need to create folderbool createFolder = m_exportOptions->m_createlevelfolder->isChecked();+ bool ret = true;if (outputLevels.size() > 1) {// MORE THAN ONE LEVEL- bool ret = true;MultiExportOverwriteCB overwriteCB;MultiExportProgressCB progressCB;@@ -649,17 +651,12 @@ bool ExportLevelPopup::execute() {.arg(toQString(FilePath)));return false;}- FilePath = TFilePath(FilePath.getWideString() + L"\\" + sl->getName())- .withType(ext)- .withFrame(tmplFId);- ret = ret &&- IoCmd::exportLevel(FilePath, sl, opts, &overwriteCB, &progressCB);- } else {- ret = ret && IoCmd::exportLevel(FilePath.withName(sl->getName())- .withType(ext)- .withFrame(tmplFId),- sl, opts, &overwriteCB, &progressCB);+ FilePath = TFilePath(FilePath.getWideString() + L"\\" + sl->getName());}+ ret = ret && IoCmd::exportLevel(FilePath.withType(ext).withFrame(tmplFId),+ sl, opts, &overwriteCB, &progressCB);+ if (ret) ++m_levelExportedCount;+ else return false;}} else {// ONE LEVEL@@ -686,9 +683,29 @@ bool ExportLevelPopup::execute() {TFilePath(FilePath.getWideString() + L"\\" + FileName.toStdWString());}- return IoCmd::exportLevel(FilePath.withType(ext).withFrame(tmplFId),- *outputLevels.begin(), opts, 0, 0);+ ret = IoCmd::exportLevel(FilePath.withType(ext).withFrame(tmplFId),+ *outputLevels.begin(), opts, 0, 0);+ m_levelExportedCount = 1;}++ // Reused code from xdtsio.cpp.+ // Encountered a modal bug when using QMessage:+ // the dialog doesn't appear correctly with DVGui::info.+ std::vector<QString> buttons = {QObject::tr("OK"),+ QObject::tr("Open containing folder")};+ int tmp = DVGui::MsgBox(+ DVGui::INFORMATION,+ QString("%1 Levels Exported").arg(m_levelExportedCount), buttons);+ if (tmp == 2) {+ TFilePath folderPath = TFilePath(m_browser->getFolder());+ if (TSystem::isUNC(folderPath))+ QDesktopServices::openUrl(QUrl(folderPath.getQString()));+ else+ QDesktopServices::openUrl(QUrl::fromLocalFile(folderPath.getQString()));+ }+ // Reuse END++ return ret;}//--------------------------------------------------------------diff --git a/toonz/sources/toonz/exportlevelpopup.h b/toonz/sources/toonz/exportlevelpopup.hindex 9ae4c2594..4795fba97 100644--- a/toonz/sources/toonz/exportlevelpopup.h+++ b/toonz/sources/toonz/exportlevelpopup.h@@ -95,6 +95,7 @@ private:// Othersstd::vector<TXshSimpleLevel *> outputLevels;+ int m_levelExportedCount =0 ;bool allPlis;std::map<std::string, TPropertyGroup *> m_formatProperties;