OpenToonz - An open-source full-featured 2D animation creation software
C
change default to scenefolder (#1959)
shun-iwasawacf6df16d8ab7
diff --git a/toonz/sources/toonz/filebrowserpopup.cpp b/toonz/sources/toonz/filebrowserpopup.cppindex 4c276c333..57180bee3 100644--- a/toonz/sources/toonz/filebrowserpopup.cpp+++ b/toonz/sources/toonz/filebrowserpopup.cpp@@ -369,6 +369,16 @@ void FileBrowserPopup::showEvent(QShowEvent *) {if (m_currentProjectPath != projectPath) {m_currentProjectPath = projectPath;initFolder();++ // set initial folder of all browsers to $scenefolder when the scene folder+ // mode is set in user preferences+ if (Preferences::instance()->getPathAliasPriority() ==+ Preferences::SceneFolderAlias) {+ ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene();+ if (scene && !scene->isUntitled())+ setFolder(scene->getScenePath().getParentDir());+ }+m_nameField->update();m_nameField->setFocus();}diff --git a/toonz/sources/toonz/penciltestpopup.cpp b/toonz/sources/toonz/penciltestpopup.cppindex 8bc3f0430..72498a39a 100644--- a/toonz/sources/toonz/penciltestpopup.cpp+++ b/toonz/sources/toonz/penciltestpopup.cpp@@ -1040,10 +1040,14 @@ void PencilTestSaveInFolderPopup::createSceneInFolder() {if (!scene) return;TFilePath fp(getPath().toStdWString());- TOutputProperties* prop = scene->getProperties()->getOutputProperties();- TFilePath outFp = prop->getPath().withParentDir(fp);- prop->setPath(outFp);+ // for the scene folder mode, output destination must be already set to+ // $scenefolder or its subfolder. See TSceneProperties::onInitialize()+ if (Preferences::instance()->getPathAliasPriority() !=+ Preferences::SceneFolderAlias) {+ TOutputProperties* prop = scene->getProperties()->getOutputProperties();+ prop->setPath(prop->getPath().withParentDir(fp));+ }// save the sceneTFilePath sceneFp =diff --git a/toonz/sources/toonz/preferencespopup.cpp b/toonz/sources/toonz/preferencespopup.cppindex 8193bb65e..77f9a5cee 100644--- a/toonz/sources/toonz/preferencespopup.cpp+++ b/toonz/sources/toonz/preferencespopup.cpp@@ -1564,6 +1564,14 @@ PreferencesPopup::PreferencesPopup()pathAliasPriority->setToolTip(tr("This option defines which alias to be used\nif both are possible on ""coding file path."));+ pathAliasPriority->setItemData(0, QString(" "), Qt::ToolTipRole);+ QString scenefolderTooltip =+ tr("Choosing this option will set initial location of all file browsers "+ "to $scenefolder.\n"+ "Also the initial output destination for new scenes will be set to "+ "$scenefolder as well.");+ pathAliasPriority->setItemData(1, scenefolderTooltip, Qt::ToolTipRole);+ pathAliasPriority->setItemData(2, QString(" "), Qt::ToolTipRole);//--- Interface ------------------------------QStringList styleSheetList;diff --git a/toonz/sources/toonz/rendercommand.cpp b/toonz/sources/toonz/rendercommand.cppindex 5cbd96c74..85e792533 100644--- a/toonz/sources/toonz/rendercommand.cpp+++ b/toonz/sources/toonz/rendercommand.cpp@@ -282,6 +282,15 @@ sprop->getOutputProperties()->setRenderSettings(rso);*/// Read the output filepathTFilePath fp = outputSettings.getPath();++ // you cannot render an untitled scene to scene folder+ if (scene->isUntitled() && TFilePath("$scenefolder").isAncestorOf(fp)) {+ DVGui::warning(+ QObject::tr("The scene is not yet saved and the output destination is "+ "set to $scenefolder.\nSave the scene first."));+ return false;+ }+/*-- ファイル名が指定されていない場合は、シーン名を出力ファイル名にする --*/if (fp.getWideName() == L"")fp = fp.withName(scene->getScenePath().getName());diff --git a/toonz/sources/toonzlib/sceneproperties.cpp b/toonz/sources/toonzlib/sceneproperties.cppindex 4dde79d3e..d97e31ac7 100644--- a/toonz/sources/toonzlib/sceneproperties.cpp+++ b/toonz/sources/toonzlib/sceneproperties.cpp@@ -9,6 +9,7 @@#include "toonz/tcamera.h"#include "toonz/tstageobjecttree.h"#include "toonz/txshleveltypes.h"+#include "toonz/preferences.h"#include "cleanuppalette.h"// TnzBase includes@@ -98,6 +99,15 @@ void TSceneProperties::assign(const TSceneProperties *sprop) {//-----------------------------------------------------------------------------void TSceneProperties::onInitialize() {+ // set initial output folder to $scenefolder when the scene folder mode is set+ // in user preferences+ if (Preferences::instance()->getPathAliasPriority() ==+ Preferences::SceneFolderAlias &&+ !TFilePath("$scenefolder").isAncestorOf(m_outputProp->getPath())) {+ std::string ext = m_outputProp->getPath().getDottedType();+ m_outputProp->setPath(TFilePath("$scenefolder/") + ext);+ }+// m_scanParameters->adaptToCurrentScanner();}diff --git a/toonz/sources/toonzlib/toonzscene.cpp b/toonz/sources/toonzlib/toonzscene.cppindex e36d56c03..3a16fd5a6 100644--- a/toonz/sources/toonzlib/toonzscene.cpp+++ b/toonz/sources/toonzlib/toonzscene.cpp@@ -1451,6 +1451,12 @@ TFilePath ToonzScene::getDefaultLevelPath(int levelType,default:levelPath = TFilePath(levelName + L"..png");}++ if (!isUntitled() &&+ Preferences::instance()->getPathAliasPriority() ==+ Preferences::SceneFolderAlias)+ return TFilePath("$scenefolder") + levelPath;+std::string folderName = getFolderName(levelType);if (project->getUseScenePath(folderName))return TFilePath("+" + folderName) + getSavePath() + levelPath;