From 93f4764414cdca37571a087ffba3428836cc308e Mon Sep 17 00:00:00 2001 From: shun_iwasawa Date: Apr 25 2016 03:15:05 +0000 Subject: Merge branch 'master' of https://github.com/walkerka/opentoonz into add_save_all_command --- diff --git a/toonz/sources/toonz/iocommand.cpp b/toonz/sources/toonz/iocommand.cpp index 9bb224b..7bddb5a 100644 --- a/toonz/sources/toonz/iocommand.cpp +++ b/toonz/sources/toonz/iocommand.cpp @@ -1662,6 +1662,74 @@ bool IoCmd::saveLevel(TXshSimpleLevel *sl) } //=========================================================================== +// IoCmd::saveAll() save current scene and all of its levels +//--------------------------------------------------------------------------- + +bool IoCmd::saveAll() +{ +#ifdef BRAVODEMO + return false; +#else + // try to save as much as possible + // if anything is wrong, return false + bool result = true; + // save scene + if (!saveScene()) + { + result = false; + } + + TApp *app = TApp::instance(); + ToonzScene* scene = app->getCurrentScene()->getScene(); + TLevelSet* levelSet = scene->getLevelSet(); + int numLevels = levelSet->getLevelCount(); + // save levels of scene + for (int i = 0; i < numLevels; ++i) + { + TXshLevel* level = levelSet->getLevel(i); + TXshSimpleLevel *sl = level->getSimpleLevel(); + if (sl) + { + if (sl->getPath() == TFilePath()) + { + result = false; + continue; + } + + TFilePath path = scene->decodeFilePath(sl->getPath()); + if (path == TFilePath()) + { + result = false; + continue; + } + if (path.getWideString()[0] == L'+') + { + result = false; + continue; + } + if (!path.isAbsolute()) + { + result = false; + continue; + } + if (!saveLevel(path, sl, true)) + { + result = false; + continue; + } + sl->setDirtyFlag(false); + } + } + + // for update title bar + // should we call this for all the levels? + app->getCurrentLevel()->notifyLevelChange(); + + return result; +#endif +} + +//=========================================================================== // IoCmd::saveSound(soundPath, soundColumn, overwrite) //--------------------------------------------------------------------------- @@ -2829,3 +2897,21 @@ public: TApp::instance()->getPaletteController()->getCurrentLevelPalette()->notifyPaletteDirtyFlagChanged(); } } overwritePaletteCommandHandler; + + +//============================================================================= +// Save scene and levels +//----------------------------------------------------------------------------- +class SaveAllCommandHandler : public MenuItemHandler +{ +public: + SaveAllCommandHandler() : MenuItemHandler(MI_SaveAll) {} + void execute() + { +#ifdef BRAVODEMO + DVGui::featureNotAvelaible(); +#else + IoCmd::saveAll(); +#endif + } +} saveAllCommandHandler; diff --git a/toonz/sources/toonz/iocommand.h b/toonz/sources/toonz/iocommand.h index 825b8ad..00dac2a 100644 --- a/toonz/sources/toonz/iocommand.h +++ b/toonz/sources/toonz/iocommand.h @@ -173,6 +173,8 @@ bool saveLevel(); bool saveLevel(const TFilePath &fp, TXshSimpleLevel *sl, bool overwrite); bool saveLevel(TXshSimpleLevel *sl); +bool saveAll(); + bool saveSound(const TFilePath &fp, TXshSoundLevel *sc, bool overwrite); bool saveSound(TXshSoundLevel *sc); diff --git a/toonz/sources/toonz/mainwindow.cpp b/toonz/sources/toonz/mainwindow.cpp index e076360..c766ecd 100644 --- a/toonz/sources/toonz/mainwindow.cpp +++ b/toonz/sources/toonz/mainwindow.cpp @@ -1579,6 +1579,7 @@ void MainWindow::defineActions() createMenuFileAction(MI_LoadScene, tr("&Load Scene..."), "Ctrl+L"); createMenuFileAction(MI_SaveScene, tr("&Save Scene"), "Ctrl+S"); createMenuFileAction(MI_SaveSceneAs, tr("&Save Scene As..."), "Ctrl+Shift+S"); + createMenuFileAction(MI_SaveAll, tr("&Save All"), ""); createMenuFileAction(MI_RevertScene, tr("&Revert Scene"), ""); QAction *act = CommandManager::instance()->getAction(MI_RevertScene); diff --git a/toonz/sources/toonz/menubar.cpp b/toonz/sources/toonz/menubar.cpp index 02de277..f21a7a3 100644 --- a/toonz/sources/toonz/menubar.cpp +++ b/toonz/sources/toonz/menubar.cpp @@ -403,6 +403,7 @@ QMenuBar* StackedMenuBar::createCleanupMenuBar() addMenuItem(filesMenu, MI_LoadScene); addMenuItem(filesMenu, MI_SaveScene); addMenuItem(filesMenu, MI_SaveSceneAs); + addMenuItem(filesMenu, MI_SaveAll); addMenuItem(filesMenu, MI_OpenRecentScene); addMenuItem(filesMenu, MI_RevertScene); filesMenu->addSeparator(); @@ -535,6 +536,7 @@ QMenuBar* StackedMenuBar::createPltEditMenuBar() addMenuItem(filesMenu, MI_LoadScene); addMenuItem(filesMenu, MI_SaveScene); addMenuItem(filesMenu, MI_SaveSceneAs); + addMenuItem(filesMenu, MI_SaveAll); addMenuItem(filesMenu, MI_OpenRecentScene); addMenuItem(filesMenu, MI_RevertScene); filesMenu->addSeparator(); @@ -707,6 +709,7 @@ QMenuBar* StackedMenuBar::createInknPaintMenuBar() addMenuItem(filesMenu, MI_LoadScene); addMenuItem(filesMenu, MI_SaveScene); addMenuItem(filesMenu, MI_SaveSceneAs); + addMenuItem(filesMenu, MI_SaveAll); addMenuItem(filesMenu, MI_OpenRecentScene); filesMenu->addSeparator(); addMenuItem(filesMenu, MI_NewScene); @@ -857,6 +860,7 @@ QMenuBar* StackedMenuBar::createXsheetMenuBar() addMenuItem(xsheetMenu, MI_LoadScene); addMenuItem(xsheetMenu, MI_SaveScene); addMenuItem(xsheetMenu, MI_SaveSceneAs); + addMenuItem(xsheetMenu, MI_SaveAll); addMenuItem(xsheetMenu, MI_OpenRecentScene); addMenuItem(xsheetMenu, MI_RevertScene); xsheetMenu->addSeparator(); @@ -1109,6 +1113,7 @@ QMenuBar* StackedMenuBar::createFullMenuBar() addMenuItem(fileMenu, MI_NewScene); addMenuItem(fileMenu, MI_LoadScene); addMenuItem(fileMenu, MI_SaveScene); + addMenuItem(fileMenu, MI_SaveAll); addMenuItem(fileMenu, MI_SaveSceneAs); addMenuItem(fileMenu, MI_OpenRecentScene); addMenuItem(fileMenu, MI_RevertScene); diff --git a/toonz/sources/toonz/menubarcommandids.h b/toonz/sources/toonz/menubarcommandids.h index ec9f0c8..9c1a0e3 100644 --- a/toonz/sources/toonz/menubarcommandids.h +++ b/toonz/sources/toonz/menubarcommandids.h @@ -15,6 +15,7 @@ #define MI_LoadScene "MI_LoadScene" #define MI_SaveScene "MI_SaveScene" #define MI_SaveSceneAs "MI_SaveSceneAs" +#define MI_SaveAll "MI_SaveAll" #define MI_RevertScene "MI_RevertScene" #define MI_LoadSubSceneFile "MI_LoadSubSceneFile"