Merge pull request #638 from manongjohn/export_scene_enhancements

Export Scene enhancements
This commit is contained in:
manongjohn 2021-04-03 14:07:10 -04:00 committed by GitHub
commit 84b31319ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 84 additions and 7 deletions

View file

@ -29,9 +29,16 @@
#include <QPainter>
#include <QApplication>
#include <QMainWindow>
#include <QStandardPaths>
using namespace DVGui;
TFilePath getStdDocumentsPath() {
QString documentsPath =
QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation)[0];
return TFilePath(documentsPath);
}
//------------------------------------------------------------------------
namespace {
//------------------------------------------------------------------------
@ -520,7 +527,7 @@ ExportScenePopup::ExportScenePopup(std::vector<TFilePath> scenes)
chooseProjectLayout->addWidget(m_chooseProjectButton);
m_projectTreeView = new ExportSceneTreeView(chooseProjectWidget);
m_projectTreeView->setMinimumWidth(200);
m_projectTreeView->setMinimumWidth(400);
ret = ret && connect(m_projectTreeView, SIGNAL(focusIn()), this,
SLOT(onProjectTreeViweFocusIn()));
chooseProjectLayout->addWidget(m_projectTreeView);
@ -532,10 +539,7 @@ ExportScenePopup::ExportScenePopup(std::vector<TFilePath> scenes)
QWidget *newProjectWidget = new QWidget(this);
QGridLayout *newProjectLayout = new QGridLayout(newProjectWidget);
m_newProjectButton = new QRadioButton(tr("New Project"), newProjectWidget);
QString newProjectTip = tr("Create a new project in ") +
Preferences::instance()->getDefaultProjectPath();
m_newProjectButton->setToolTip(newProjectTip);
m_newProjectButton = new QRadioButton(tr("New Project"), newProjectWidget);
group->addButton(m_newProjectButton, 1);
newProjectLayout->addWidget(m_newProjectButton, 0, 0, 1, 2, Qt::AlignLeft);
@ -549,6 +553,21 @@ ExportScenePopup::ExportScenePopup(std::vector<TFilePath> scenes)
newProjectLayout->setColumnStretch(1, 5);
newProjectLayout->addWidget(m_newProjectName, 1, 1, 1, 1, Qt::AlignLeft);
m_pathFieldLabel = new QLabel(tr("Create In:"), this);
QString defaultProjectLocation =
Preferences::instance()->getDefaultProjectPath();
m_projectLocationFld =
new DVGui::FileField(this, getStdDocumentsPath().getQString());
ret = ret && connect(m_projectLocationFld->getField(), SIGNAL(focusIn()),
this, SLOT(onProjectNameFocusIn()));
if (TSystem::doesExistFileOrLevel(TFilePath(defaultProjectLocation))) {
m_projectLocationFld->setPath(defaultProjectLocation);
}
newProjectLayout->addWidget(m_pathFieldLabel, 2, 0,
Qt::AlignRight | Qt::AlignVCenter);
newProjectLayout->addWidget(m_projectLocationFld, 2, 1);
newProjectWidget->setLayout(chooseProjectLayout);
layout->addWidget(newProjectWidget);
@ -673,8 +692,16 @@ TFilePath ExportScenePopup::createNewProject() {
return TFilePath();
}
TFilePath projectPath = pm->projectNameToProjectPath(projectName);
TProject *project = new TProject();
TFilePath newLocation = TFilePath(m_projectLocationFld->getPath());
TFilePath projectFolder = newLocation + projectName;
TFilePath projectPath = pm->projectFolderToProjectPath(projectFolder);
if (TSystem::doesExistFileOrLevel(projectPath)) {
error(tr("Project '%1' already exists").arg(m_newProjectName->text()));
return TFilePath();
}
TProject *project = new TProject();
TProjectP currentProject = pm->getCurrentProject();
assert(currentProject);

View file

@ -5,6 +5,7 @@
#include "toonzqt/dvdialog.h"
#include "toonzqt/lineedit.h"
#include "toonzqt/filefield.h"
#include "tfilepath.h"
#include "filebrowsermodel.h"
#include "dvdirtreeview.h"
@ -163,6 +164,9 @@ class ExportScenePopup final : public DVGui::Dialog {
QRadioButton *m_newProjectButton;
QRadioButton *m_chooseProjectButton;
QLabel *m_pathFieldLabel;
DVGui::FileField *m_projectLocationFld;
bool m_createNewProject;
public:

View file

@ -29,6 +29,7 @@
#include "toonz/toonzscene.h"
#include "toonz/sceneresources.h"
#include "toonz/preferences.h"
#include "toonz/tscenehandle.h"
// TnzCore includes
#include "tfiletype.h"
@ -589,6 +590,20 @@ void FileSelection::exportScenes() {
//------------------------------------------------------------------------
void FileSelection::exportScene(TFilePath scenePath) {
if (scenePath.isEmpty()) return;
std::vector<TFilePath> files;
files.push_back(scenePath);
if (!m_exportScenePopup)
m_exportScenePopup = new ExportScenePopup(files);
else
m_exportScenePopup->setScenes(files);
m_exportScenePopup->show();
}
//------------------------------------------------------------------------
void FileSelection::selectAll() {
DvItemSelection::selectAll();
const std::set<int> &indices = getSelectedIndices();
@ -601,3 +616,27 @@ void FileSelection::selectAll() {
FileBrowser::updateItemViewerPanel();
}
}
//-----------------------------------------------------------------------------
class ExportCurrentSceneCommandHandler final : public MenuItemHandler {
public:
ExportCurrentSceneCommandHandler() : MenuItemHandler(MI_ExportCurrentScene) {}
void execute() override {
TApp *app = TApp::instance();
TSceneHandle *sceneHandle = app->getCurrentScene();
if (!sceneHandle) return;
ToonzScene *scene = sceneHandle->getScene();
if (!scene) return;
TFilePath fp = scene->getScenePath();
if (sceneHandle->getDirtyFlag() || scene->isUntitled() ||
!TSystem::doesExistFileOrLevel(fp)) {
DVGui::warning(tr("You must save the current scene first."));
return;
}
FileSelection *fs = new FileSelection();
fs->exportScene(fp);
}
} ExportCurrentSceneCommandHandler;

View file

@ -43,6 +43,7 @@ public:
void collectAssets();
void importScenes();
void exportScenes();
void exportScene(TFilePath scenePath);
void selectAll();
void separateFilesByColors();
};

View file

@ -1910,6 +1910,10 @@ void MainWindow::defineActions() {
QT_TR_NOOP("&Clear Recent Flipbook Image List"), "");
createMenuFileAction(MI_ClearCacheFolder, QT_TR_NOOP("&Clear Cache Folder"),
"", "clear_cache");
createMenuFileAction(MI_ExportCurrentScene,
QT_TR_NOOP("&Export Current Scene"), "", "",
tr("Export the current scene to another project."));
// Menu - Edit
createMenuEditAction(MI_SelectAll, QT_TR_NOOP("&Select All"), "Ctrl+A",

View file

@ -339,6 +339,7 @@ void TopBar::loadMenubar() {
{ addMenuItem(importMenu, MI_ImportMagpieFile); }
QMenu *exportMenu = fileMenu->addMenu(tr("Export"));
{
addMenuItem(exportMenu, MI_ExportCurrentScene);
addMenuItem(exportMenu, MI_SoundTrack);
addMenuItem(exportMenu, MI_ExportXDTS);
addMenuItem(exportMenu, MI_StopMotionExportImageSequence);

View file

@ -265,6 +265,7 @@
#define MI_CollectAssets "MI_CollectAssets"
#define MI_ImportScenes "MI_ImportScenes"
#define MI_ExportScenes "MI_ExportScenes"
#define MI_ExportCurrentScene "MI_ExportCurrentScene"
#define MI_SelectRowKeyframes "MI_SelectRowKeyframes"
#define MI_SelectColumnKeyframes "MI_SelectColumnKeyframes"