From 3f818e3fc68f8c425c44737e17e797bf5f58f1ec Mon Sep 17 00:00:00 2001 From: shun-iwasawa Date: Oct 03 2017 08:17:58 +0000 Subject: Camera Capture feature : Save scene in the subfolder checkbox (#1496) * save scene in subfolder checkbox * save "save in" folder in the scene --- diff --git a/stuff/config/loc/日本語/toonz.qm b/stuff/config/loc/日本語/toonz.qm index 9fd4950..72d1da6 100644 Binary files a/stuff/config/loc/日本語/toonz.qm and b/stuff/config/loc/日本語/toonz.qm differ diff --git a/toonz/sources/include/toonz/sceneproperties.h b/toonz/sources/include/toonz/sceneproperties.h index 2c2c6b6..88c5d42 100644 --- a/toonz/sources/include/toonz/sceneproperties.h +++ b/toonz/sources/include/toonz/sceneproperties.h @@ -76,6 +76,7 @@ private: QList m_notesColor; bool m_columnColorFilterOnRender; + TFilePath m_camCapSaveInPath; public: /*! @@ -260,6 +261,14 @@ and height. m_columnColorFilterOnRender = on; } + /* Returns initial save in path for the camera capture feature */ + TFilePath cameraCaptureSaveInPath() const { return m_camCapSaveInPath; } + + /* Set the initial save in path for the camera capture feature */ + void setCameraCaptureSaveInPath(const TFilePath &fp) { + m_camCapSaveInPath = fp; + } + //! Substitutes current cameras with those stored in the specified stage tree. void cloneCamerasFrom(TStageObjectTree *stageObjects); diff --git a/toonz/sources/toonz/penciltestpopup.cpp b/toonz/sources/toonz/penciltestpopup.cpp index 90645c5..ceb0c9e 100644 --- a/toonz/sources/toonz/penciltestpopup.cpp +++ b/toonz/sources/toonz/penciltestpopup.cpp @@ -8,6 +8,8 @@ #include "cellselection.h" #include "toonzqt/tselectionhandle.h" #include "cameracapturelevelcontrol.h" +#include "iocommand.h" + // TnzQt includes #include "toonzqt/menubarcommand.h" #include "toonzqt/filefield.h" @@ -92,6 +94,8 @@ TEnv::StringVar CamCapSaveInPopupEpisode("CamCapSaveInPopupEpisode", "1"); TEnv::StringVar CamCapSaveInPopupSequence("CamCapSaveInPopupSequence", "1"); TEnv::StringVar CamCapSaveInPopupScene("CamCapSaveInPopupScene", "1"); TEnv::IntVar CamCapSaveInPopupAutoSubName("CamCapSaveInPopupAutoSubName", 1); +TEnv::IntVar CamCapSaveInPopupCreateSceneInFolder( + "CamCapSaveInPopupCreateSceneInFolder", 0); namespace { @@ -680,10 +684,7 @@ PencilTestSaveInFolderPopup::PencilTestSaveInFolderPopup(QWidget* parent) : Dialog(parent, true, false, "PencilTestSaveInFolder") { setWindowTitle("Create the Destination Subfolder to Save"); - QString parentFolder = QString::fromStdString(CamCapSaveInParentFolder); - if (parentFolder.isEmpty()) - parentFolder = QString("+%1").arg(QString::fromStdString(TProject::Extras)); - m_parentFolderField = new FileField(this, parentFolder); + m_parentFolderField = new FileField(this); QPushButton* setAsDefaultBtn = new QPushButton(tr("Set As Default"), this); setAsDefaultBtn->setToolTip( @@ -707,6 +708,7 @@ PencilTestSaveInFolderPopup::PencilTestSaveInFolderPopup(QWidget* parent) QCheckBox* showPopupOnLaunchCB = new QCheckBox(tr("Show This on Launch of the Camera Capture"), this); + m_createSceneInFolderCB = new QCheckBox(tr("Save Scene in Subfolder"), this); QPushButton* okBtn = new QPushButton(tr("OK"), this); QPushButton* cancelBtn = new QPushButton(tr("Cancel"), this); @@ -743,6 +745,11 @@ PencilTestSaveInFolderPopup::PencilTestSaveInFolderPopup(QWidget* parent) m_subNameFormatCombo->setCurrentIndex(CamCapSaveInPopupAutoSubName - 1); showPopupOnLaunchCB->setChecked(CamCapOpenSaveInPopupOnLaunch != 0); + m_createSceneInFolderCB->setChecked(CamCapSaveInPopupCreateSceneInFolder != + 0); + m_createSceneInFolderCB->setToolTip( + tr("Save the current scene in the subfolder.\nSet the output folder path " + "to the subfolder as well.")); addButtonBarWidget(okBtn, cancelBtn); @@ -807,6 +814,8 @@ PencilTestSaveInFolderPopup::PencilTestSaveInFolderPopup(QWidget* parent) subNameLay->setColumnStretch(1, 1); subNameGroupBox->setLayout(subNameLay); subFolderLay->addWidget(subNameGroupBox, 0); + + subFolderLay->addWidget(m_createSceneInFolderCB, 0, Qt::AlignLeft); } subFolderFrame->setLayout(subFolderLay); m_topLayout->addWidget(subFolderFrame); @@ -816,7 +825,7 @@ PencilTestSaveInFolderPopup::PencilTestSaveInFolderPopup(QWidget* parent) m_topLayout->addStretch(1); } - resize(300, 400); + resize(300, 440); //---- signal-slot connection bool ret = true; @@ -838,12 +847,13 @@ PencilTestSaveInFolderPopup::PencilTestSaveInFolderPopup(QWidget* parent) ret = ret && connect(showPopupOnLaunchCB, SIGNAL(clicked(bool)), this, SLOT(onShowPopupOnLaunchCBClicked(bool))); + ret = ret && connect(m_createSceneInFolderCB, SIGNAL(clicked(bool)), this, + SLOT(onCreateSceneInFolderCBClicked(bool))); ret = ret && connect(setAsDefaultBtn, SIGNAL(pressed()), this, SLOT(onSetAsDefaultBtnPressed())); ret = ret && connect(okBtn, SIGNAL(clicked(bool)), this, SLOT(onOkPressed())); ret = ret && connect(cancelBtn, SIGNAL(clicked(bool)), this, SLOT(reject())); - assert(ret); updateSubFolderName(); @@ -864,6 +874,15 @@ QString PencilTestSaveInFolderPopup::getParentPath() { } //----------------------------------------------------------------------------- + +void PencilTestSaveInFolderPopup::showEvent(QShowEvent* event) { + // Show "Save the scene" check box only when the scene is untitled + bool isUntitled = + TApp::instance()->getCurrentScene()->getScene()->isUntitled(); + m_createSceneInFolderCB->setVisible(isUntitled); +} + +//----------------------------------------------------------------------------- namespace { QString formatString(QString inStr, int charNum) { if (inStr.isEmpty()) return QString("0").rightJustified(charNum, '0'); @@ -931,6 +950,12 @@ void PencilTestSaveInFolderPopup::onShowPopupOnLaunchCBClicked(bool on) { //----------------------------------------------------------------------------- +void PencilTestSaveInFolderPopup::onCreateSceneInFolderCBClicked(bool on) { + CamCapSaveInPopupCreateSceneInFolder = (on) ? 1 : 0; +} + +//----------------------------------------------------------------------------- + void PencilTestSaveInFolderPopup::onSetAsDefaultBtnPressed() { CamCapSaveInParentFolder = m_parentFolderField->getPath().toStdString(); } @@ -987,9 +1012,57 @@ void PencilTestSaveInFolderPopup::onOkPressed() { return; } + createSceneInFolder(); accept(); } +//----------------------------------------------------------------------------- + +void PencilTestSaveInFolderPopup::createSceneInFolder() { + // make sure that the check box is displayed (= the scene is untitled) and is + // checked. + if (m_createSceneInFolderCB->isHidden() || + !m_createSceneInFolderCB->isChecked()) + return; + // just in case + if (!m_subFolderCB->isChecked()) return; + + // set the output folder + ToonzScene* scene = TApp::instance()->getCurrentScene()->getScene(); + if (!scene) return; + + TFilePath fp(getPath().toStdWString()); + TOutputProperties* prop = scene->getProperties()->getOutputProperties(); + TFilePath outFp = prop->getPath().withParentDir(fp); + + prop->setPath(outFp); + + // save the scene + TFilePath sceneFp = + scene->decodeFilePath(fp) + + TFilePath(m_subFolderNameField->text().toStdWString()).withType("tnz"); + IoCmd::saveScene(sceneFp, 0); +} + +//----------------------------------------------------------------------------- + +void PencilTestSaveInFolderPopup::updateParentFolder() { + // If the parent folder is saved in the scene, use it + ToonzScene* scene = TApp::instance()->getCurrentScene()->getScene(); + QString parentFolder = + scene->getProperties()->cameraCaptureSaveInPath().getQString(); + if (parentFolder.isEmpty()) { + // else then, if the user-env stores the parent folder value, use it + parentFolder = QString::fromStdString(CamCapSaveInParentFolder); + // else, use "+extras" project folder + if (parentFolder.isEmpty()) + parentFolder = + QString("+%1").arg(QString::fromStdString(TProject::Extras)); + } + + m_parentFolderField->setPath(parentFolder); +} + //============================================================================= PencilTestPopup::PencilTestPopup() @@ -1095,7 +1168,8 @@ PencilTestPopup::PencilTestPopup() m_saveOnCaptureCB->setChecked(true); imageFrame->setObjectName("CleanupSettingsFrame"); - m_colorTypeCombo->addItems({tr("Color"), tr("Grayscale"), tr("Black & White")}); + m_colorTypeCombo->addItems( + {tr("Color"), tr("Grayscale"), tr("Black & White")}); m_colorTypeCombo->setCurrentIndex(0); m_upsideDownCB->setChecked(false); @@ -1347,7 +1421,7 @@ PencilTestPopup::PencilTestPopup() ret = ret && connect(subfolderButton, SIGNAL(clicked(bool)), this, SLOT(openSaveInFolderPopup())); ret = ret && connect(m_saveInFileFld, SIGNAL(pathChanged()), this, - SLOT(refreshFrameInfo())); + SLOT(onSaveInPathEdited())); ret = ret && connect(m_fileTypeCombo, SIGNAL(activated(int)), this, SLOT(refreshFrameInfo())); ret = ret && connect(m_frameNumberEdit, SIGNAL(editingFinished()), this, @@ -1763,9 +1837,9 @@ void PencilTestPopup::showEvent(QShowEvent* event) { } TSceneHandle* sceneHandle = TApp::instance()->getCurrentScene(); - connect(sceneHandle, SIGNAL(sceneSwitched()), this, SLOT(refreshFrameInfo())); + connect(sceneHandle, SIGNAL(sceneSwitched()), this, SLOT(onSceneSwitched())); connect(sceneHandle, SIGNAL(castChanged()), this, SLOT(refreshFrameInfo())); - refreshFrameInfo(); + onSceneSwitched(); } //----------------------------------------------------------------------------- @@ -2207,8 +2281,9 @@ void PencilTestPopup::openSaveInFolderPopup() { m_saveInFileFld->setPath(m_saveInFolderPopup->getPath()); if (oldPath == m_saveInFileFld->getPath()) setToNextNewLevel(); - else - refreshFrameInfo(); + else { + onSaveInPathEdited(); + } } } @@ -2463,6 +2538,23 @@ void PencilTestPopup::refreshFrameInfo() { //----------------------------------------------------------------------------- +void PencilTestPopup::onSaveInPathEdited() { + ToonzScene* scene = TApp::instance()->getCurrentScene()->getScene(); + TFilePath saveInPath(m_saveInFileFld->getPath().toStdWString()); + scene->getProperties()->setCameraCaptureSaveInPath(saveInPath); + refreshFrameInfo(); +} + +//----------------------------------------------------------------------------- + +void PencilTestPopup::onSceneSwitched() { + m_saveInFolderPopup->updateParentFolder(); + m_saveInFileFld->setPath(m_saveInFolderPopup->getParentPath()); + refreshFrameInfo(); +} + +//----------------------------------------------------------------------------- + OpenPopupCommandHandler openPencilTestPopup(MI_PencilTest); // specialized in order to call openSaveInFolderPopup() diff --git a/toonz/sources/toonz/penciltestpopup.h b/toonz/sources/toonz/penciltestpopup.h index 8cfa88f..0ebee84 100644 --- a/toonz/sources/toonz/penciltestpopup.h +++ b/toonz/sources/toonz/penciltestpopup.h @@ -150,18 +150,25 @@ class PencilTestSaveInFolderPopup : public DVGui::Dialog { QLineEdit *m_projectField, *m_episodeField, *m_sequenceField, *m_sceneField, *m_subFolderNameField; - QCheckBox *m_subFolderCB, *m_autoSubNameCB; + QCheckBox *m_subFolderCB, *m_autoSubNameCB, *m_createSceneInFolderCB; QComboBox* m_subNameFormatCombo; + void createSceneInFolder(); + public: PencilTestSaveInFolderPopup(QWidget* parent = 0); QString getPath(); QString getParentPath(); + void updateParentFolder(); + +protected: + void showEvent(QShowEvent* event); protected slots: void updateSubFolderName(); void onAutoSubNameCBClicked(bool); void onShowPopupOnLaunchCBClicked(bool); + void onCreateSceneInFolderCBClicked(bool); void onSetAsDefaultBtnPressed(); void onOkPressed(); }; @@ -252,6 +259,9 @@ protected slots: void refreshFrameInfo(); + void onSaveInPathEdited(); + void onSceneSwitched(); + public slots: void openSaveInFolderPopup(); }; diff --git a/toonz/sources/toonzlib/sceneproperties.cpp b/toonz/sources/toonzlib/sceneproperties.cpp index 1c3a2e9..4dde79d 100644 --- a/toonz/sources/toonzlib/sceneproperties.cpp +++ b/toonz/sources/toonzlib/sceneproperties.cpp @@ -37,7 +37,8 @@ TSceneProperties::TSceneProperties() , m_tlvSubsampling(1) , m_fieldGuideSize(16) , m_fieldGuideAspectRatio(1.77778) - , m_columnColorFilterOnRender(false) { + , m_columnColorFilterOnRender(false) + , m_camCapSaveInPath() { // Default color m_notesColor.push_back(TPixel32(255, 235, 140)); m_notesColor.push_back(TPixel32(255, 160, 120)); @@ -298,6 +299,8 @@ void TSceneProperties::saveData(TOStream &os) const { os.child("subsampling") << m_fullcolorSubsampling << m_tlvSubsampling; os.child("fieldguide") << m_fieldGuideSize << m_fieldGuideAspectRatio; if (m_columnColorFilterOnRender) os.child("columnColorFilterOnRender") << 1; + if (!m_camCapSaveInPath.isEmpty()) + os.child("cameraCaputureSaveInPath") << m_camCapSaveInPath; os.openChild("noteColors"); for (i = 0; i < m_notesColor.size(); i++) os << m_notesColor.at(i); @@ -673,6 +676,8 @@ void TSceneProperties::loadData(TIStream &is, bool isLoadingProject) { i++; } assert(i == 7); + } else if (tagName == "cameraCaputureSaveInPath") { + is >> m_camCapSaveInPath; } else { throw TException("unexpected property tag: " + tagName); } diff --git a/toonz/sources/toonzlib/tproject.cpp b/toonz/sources/toonzlib/tproject.cpp index 0a6b82e..4c270d4 100644 --- a/toonz/sources/toonzlib/tproject.cpp +++ b/toonz/sources/toonzlib/tproject.cpp @@ -1068,6 +1068,9 @@ void TProjectManager::saveTemplate(ToonzScene *scene) { props.assign(scene->getProperties()); props.cloneCamerasFrom(scene->getXsheet()->getStageObjectTree()); + // camera capture's "save in" path is saved in env, not in the project + props.setCameraCaptureSaveInPath(TFilePath()); + TProjectP currentProject = getCurrentProject(); currentProject->setSceneProperties(props); currentProject->save(); diff --git a/toonz/sources/translations/japanese/toonz.ts b/toonz/sources/translations/japanese/toonz.ts index 2110cd1..bcf6f15 100644 --- a/toonz/sources/translations/japanese/toonz.ts +++ b/toonz/sources/translations/japanese/toonz.ts @@ -884,6 +884,22 @@ What do you want to do? Field Guide フィールドガイド + + Bottom + + + + Top + + + + Left + + + + Right + + CleanupTab @@ -5685,6 +5701,18 @@ WARNING : Image size mismatch. The saved image size is %1 x %2. 警告: 画像サイズの不一致。保存されている画像のサイズは %1 x %2 ピクセルです。 + + Color + カラー + + + Grayscale + グレースケール + + + Black & White + 白黒二値 + PencilTestSaveInFolderPopup @@ -5780,6 +5808,16 @@ WARNING : Image size mismatch. The saved image size is %1 x %2. Set the current "Save In" path as the default. 現在の「作成場所」のパスを既定にします。 + + Save Scene in Subfolder + カットフォルダ内にシーンを保存する + + + Save the current scene in the subfolder. + Set the output folder path to the subfolder as well. + シーンをカットフォルダ内に保存します。 +出力設定の保存先のパスもカットフォルダ内に変更します。 + PltGizmoPopup @@ -6621,6 +6659,18 @@ Is it OK to release these shortcuts? Font Weight *: 文字の太さ *: + + Arrow Markers + 矢印マーカー + + + Animated Guide + アニメーションガイド + + + Vector Guided Style: + ベクターレベルの描き順のガイド: + PreferencesPopup::FormatProperties @@ -8350,6 +8400,14 @@ Are you sure? Reframe to %1's with %2 blanks リフレーム: %1 コマ 中 %2 + + Stage Schematic + ステージスキマティック + + + Fx Schematic + エフェクトスキマティック + ReframePopup @@ -9647,6 +9705,26 @@ Please commit or revert changes first. Select Column 列を選択 + + Vector Guided Drawing + ベクターレベルの描き順のガイド + + + Off + オフ + + + Closest Drawing + 直近の作画 + + + Farthest Drawing + 最も遠い作画 + + + All Drawings + 全ての作画 + SceneViewerPanel