Merge pull request #638 from manongjohn/export_scene_enhancements
Export Scene enhancements
This commit is contained in:
commit
84b31319ef
7 changed files with 84 additions and 7 deletions
|
@ -29,9 +29,16 @@
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
|
#include <QStandardPaths>
|
||||||
|
|
||||||
using namespace DVGui;
|
using namespace DVGui;
|
||||||
|
|
||||||
|
TFilePath getStdDocumentsPath() {
|
||||||
|
QString documentsPath =
|
||||||
|
QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation)[0];
|
||||||
|
return TFilePath(documentsPath);
|
||||||
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
namespace {
|
namespace {
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
|
@ -520,7 +527,7 @@ ExportScenePopup::ExportScenePopup(std::vector<TFilePath> scenes)
|
||||||
chooseProjectLayout->addWidget(m_chooseProjectButton);
|
chooseProjectLayout->addWidget(m_chooseProjectButton);
|
||||||
|
|
||||||
m_projectTreeView = new ExportSceneTreeView(chooseProjectWidget);
|
m_projectTreeView = new ExportSceneTreeView(chooseProjectWidget);
|
||||||
m_projectTreeView->setMinimumWidth(200);
|
m_projectTreeView->setMinimumWidth(400);
|
||||||
ret = ret && connect(m_projectTreeView, SIGNAL(focusIn()), this,
|
ret = ret && connect(m_projectTreeView, SIGNAL(focusIn()), this,
|
||||||
SLOT(onProjectTreeViweFocusIn()));
|
SLOT(onProjectTreeViweFocusIn()));
|
||||||
chooseProjectLayout->addWidget(m_projectTreeView);
|
chooseProjectLayout->addWidget(m_projectTreeView);
|
||||||
|
@ -532,10 +539,7 @@ ExportScenePopup::ExportScenePopup(std::vector<TFilePath> scenes)
|
||||||
QWidget *newProjectWidget = new QWidget(this);
|
QWidget *newProjectWidget = new QWidget(this);
|
||||||
QGridLayout *newProjectLayout = new QGridLayout(newProjectWidget);
|
QGridLayout *newProjectLayout = new QGridLayout(newProjectWidget);
|
||||||
|
|
||||||
m_newProjectButton = new QRadioButton(tr("New Project"), newProjectWidget);
|
m_newProjectButton = new QRadioButton(tr("New Project"), newProjectWidget);
|
||||||
QString newProjectTip = tr("Create a new project in ") +
|
|
||||||
Preferences::instance()->getDefaultProjectPath();
|
|
||||||
m_newProjectButton->setToolTip(newProjectTip);
|
|
||||||
group->addButton(m_newProjectButton, 1);
|
group->addButton(m_newProjectButton, 1);
|
||||||
newProjectLayout->addWidget(m_newProjectButton, 0, 0, 1, 2, Qt::AlignLeft);
|
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->setColumnStretch(1, 5);
|
||||||
newProjectLayout->addWidget(m_newProjectName, 1, 1, 1, 1, Qt::AlignLeft);
|
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);
|
newProjectWidget->setLayout(chooseProjectLayout);
|
||||||
layout->addWidget(newProjectWidget);
|
layout->addWidget(newProjectWidget);
|
||||||
|
|
||||||
|
@ -673,8 +692,16 @@ TFilePath ExportScenePopup::createNewProject() {
|
||||||
return TFilePath();
|
return TFilePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
TFilePath projectPath = pm->projectNameToProjectPath(projectName);
|
TFilePath newLocation = TFilePath(m_projectLocationFld->getPath());
|
||||||
TProject *project = new TProject();
|
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();
|
TProjectP currentProject = pm->getCurrentProject();
|
||||||
assert(currentProject);
|
assert(currentProject);
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
#include "toonzqt/dvdialog.h"
|
#include "toonzqt/dvdialog.h"
|
||||||
#include "toonzqt/lineedit.h"
|
#include "toonzqt/lineedit.h"
|
||||||
|
#include "toonzqt/filefield.h"
|
||||||
#include "tfilepath.h"
|
#include "tfilepath.h"
|
||||||
#include "filebrowsermodel.h"
|
#include "filebrowsermodel.h"
|
||||||
#include "dvdirtreeview.h"
|
#include "dvdirtreeview.h"
|
||||||
|
@ -163,6 +164,9 @@ class ExportScenePopup final : public DVGui::Dialog {
|
||||||
QRadioButton *m_newProjectButton;
|
QRadioButton *m_newProjectButton;
|
||||||
QRadioButton *m_chooseProjectButton;
|
QRadioButton *m_chooseProjectButton;
|
||||||
|
|
||||||
|
QLabel *m_pathFieldLabel;
|
||||||
|
DVGui::FileField *m_projectLocationFld;
|
||||||
|
|
||||||
bool m_createNewProject;
|
bool m_createNewProject;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "toonz/toonzscene.h"
|
#include "toonz/toonzscene.h"
|
||||||
#include "toonz/sceneresources.h"
|
#include "toonz/sceneresources.h"
|
||||||
#include "toonz/preferences.h"
|
#include "toonz/preferences.h"
|
||||||
|
#include "toonz/tscenehandle.h"
|
||||||
|
|
||||||
// TnzCore includes
|
// TnzCore includes
|
||||||
#include "tfiletype.h"
|
#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() {
|
void FileSelection::selectAll() {
|
||||||
DvItemSelection::selectAll();
|
DvItemSelection::selectAll();
|
||||||
const std::set<int> &indices = getSelectedIndices();
|
const std::set<int> &indices = getSelectedIndices();
|
||||||
|
@ -601,3 +616,27 @@ void FileSelection::selectAll() {
|
||||||
FileBrowser::updateItemViewerPanel();
|
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;
|
||||||
|
|
|
@ -43,6 +43,7 @@ public:
|
||||||
void collectAssets();
|
void collectAssets();
|
||||||
void importScenes();
|
void importScenes();
|
||||||
void exportScenes();
|
void exportScenes();
|
||||||
|
void exportScene(TFilePath scenePath);
|
||||||
void selectAll();
|
void selectAll();
|
||||||
void separateFilesByColors();
|
void separateFilesByColors();
|
||||||
};
|
};
|
||||||
|
|
|
@ -1910,6 +1910,10 @@ void MainWindow::defineActions() {
|
||||||
QT_TR_NOOP("&Clear Recent Flipbook Image List"), "");
|
QT_TR_NOOP("&Clear Recent Flipbook Image List"), "");
|
||||||
createMenuFileAction(MI_ClearCacheFolder, QT_TR_NOOP("&Clear Cache Folder"),
|
createMenuFileAction(MI_ClearCacheFolder, QT_TR_NOOP("&Clear Cache Folder"),
|
||||||
"", "clear_cache");
|
"", "clear_cache");
|
||||||
|
createMenuFileAction(MI_ExportCurrentScene,
|
||||||
|
QT_TR_NOOP("&Export Current Scene"), "", "",
|
||||||
|
tr("Export the current scene to another project."));
|
||||||
|
|
||||||
// Menu - Edit
|
// Menu - Edit
|
||||||
|
|
||||||
createMenuEditAction(MI_SelectAll, QT_TR_NOOP("&Select All"), "Ctrl+A",
|
createMenuEditAction(MI_SelectAll, QT_TR_NOOP("&Select All"), "Ctrl+A",
|
||||||
|
|
|
@ -339,6 +339,7 @@ void TopBar::loadMenubar() {
|
||||||
{ addMenuItem(importMenu, MI_ImportMagpieFile); }
|
{ addMenuItem(importMenu, MI_ImportMagpieFile); }
|
||||||
QMenu *exportMenu = fileMenu->addMenu(tr("Export"));
|
QMenu *exportMenu = fileMenu->addMenu(tr("Export"));
|
||||||
{
|
{
|
||||||
|
addMenuItem(exportMenu, MI_ExportCurrentScene);
|
||||||
addMenuItem(exportMenu, MI_SoundTrack);
|
addMenuItem(exportMenu, MI_SoundTrack);
|
||||||
addMenuItem(exportMenu, MI_ExportXDTS);
|
addMenuItem(exportMenu, MI_ExportXDTS);
|
||||||
addMenuItem(exportMenu, MI_StopMotionExportImageSequence);
|
addMenuItem(exportMenu, MI_StopMotionExportImageSequence);
|
||||||
|
|
|
@ -265,6 +265,7 @@
|
||||||
#define MI_CollectAssets "MI_CollectAssets"
|
#define MI_CollectAssets "MI_CollectAssets"
|
||||||
#define MI_ImportScenes "MI_ImportScenes"
|
#define MI_ImportScenes "MI_ImportScenes"
|
||||||
#define MI_ExportScenes "MI_ExportScenes"
|
#define MI_ExportScenes "MI_ExportScenes"
|
||||||
|
#define MI_ExportCurrentScene "MI_ExportCurrentScene"
|
||||||
|
|
||||||
#define MI_SelectRowKeyframes "MI_SelectRowKeyframes"
|
#define MI_SelectRowKeyframes "MI_SelectRowKeyframes"
|
||||||
#define MI_SelectColumnKeyframes "MI_SelectColumnKeyframes"
|
#define MI_SelectColumnKeyframes "MI_SelectColumnKeyframes"
|
||||||
|
|
Loading…
Reference in a new issue