diff --git a/toonz/sources/toonz/filebrowserpopup.cpp b/toonz/sources/toonz/filebrowserpopup.cpp index 4c276c3..57180be 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.cpp index 8bc3f04..72498a3 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 scene TFilePath sceneFp = diff --git a/toonz/sources/toonz/preferencespopup.cpp b/toonz/sources/toonz/preferencespopup.cpp index 8193bb6..77f9a5c 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.cpp index 5cbd96c..85e7925 100644 --- a/toonz/sources/toonz/rendercommand.cpp +++ b/toonz/sources/toonz/rendercommand.cpp @@ -282,6 +282,15 @@ sprop->getOutputProperties()->setRenderSettings(rso);*/ // Read the output filepath TFilePath 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.cpp index 4dde79d..d97e31a 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.cpp index e36d56c..3a16fd5 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;