void ExportScenePopup::onExport() { QApplication::setOverrideCursor(Qt::WaitCursor); TProjectManager *pm = TProjectManager::instance(); TFilePath oldProjectPath = pm->getCurrentProjectPath(); TFilePath projectPath; if (!m_createNewProject) { DvDirModelFileFolderNode *node = (DvDirModelFileFolderNode *)m_projectTreeView->getCurrentNode(); if (!node || !pm->isProject(node->getPath())) { QApplication::restoreOverrideCursor(); MsgBox(WARNING, tr("The folder you selected is not a project.")); return; } projectPath = pm->projectFolderToProjectPath(node->getPath()); assert(projectPath != TFilePath()); } else //Create project { projectPath = createNewProject(); if (projectPath == TFilePath()) { QApplication::restoreOverrideCursor(); return; } } pm->setCurrentProjectPath(projectPath); std::vector<TFilePath> newScenes; int i; for (i = 0; i < m_scenes.size(); i++) { TFilePath newScenePath = importScene(m_scenes[i]); if (newScenePath == TFilePath()) continue; newScenes.push_back(newScenePath); } pm->setCurrentProjectPath(oldProjectPath); if (newScenes.empty()) { QApplication::restoreOverrideCursor(); MsgBox(WARNING, tr("There was an error exporting the scene.")); return; } for (i = 0; i < newScenes.size(); i++) collectAssets(newScenes[i]); QApplication::restoreOverrideCursor(); accept(); }
void ProjectCreatePopup::createProject() { if (!IoCmd::saveSceneIfNeeded(QObject::tr("Create project"))) return; #ifdef LINETEST TnzCamera *camera = TnzCamera::instance(); if (camera->isCameraConnected()) camera->cameraDisconnect(); #endif QFileInfo fi(m_nameFld->text()); if (!isValidFileName(fi.baseName())) { error( tr("Project Name cannot be empty or contain any of the following " "characters:\n \\ / : * ? \" < > |")); return; } TProjectManager *pm = TProjectManager::instance(); TFilePath projectName = TFilePath(m_nameFld->text().toStdWString()); if (projectName == TFilePath()) { return; } if (projectName.isAbsolute()) { error(tr("Bad project name: '%1' looks like an absolute file path") .arg(m_nameFld->text())); return; } if (pm->getProjectPathByName(projectName) != TFilePath()) { error(tr("Project '%1' already exists").arg(m_nameFld->text())); // project already exists return; } TFilePath currentProjectRoot; DvDirModelFileFolderNode *node = dynamic_cast<DvDirModelFileFolderNode *>(m_treeView->getCurrentNode()); if (node) currentProjectRoot = node->getPath(); else currentProjectRoot = pm->getCurrentProjectRoot(); TFilePath projectFolder = currentProjectRoot + projectName; TFilePath projectPath = pm->projectFolderToProjectPath(projectFolder); TProject *project = new TProject(); updateProjectFromFields(project); TProjectP currentProject = pm->getCurrentProject(); project->setSceneProperties(currentProject->getSceneProperties()); try { bool isSaved = project->save(projectPath); if (!isSaved) DVGui::error(tr("It is not possible to create the %1 project.") .arg(toQString(projectPath))); } catch (TSystemException se) { DVGui::warning(QString::fromStdWString(se.getMessage())); return; } pm->setCurrentProjectPath(projectPath); IoCmd::newScene(); DvDirModel::instance()->refreshFolder(projectFolder.getParentDir()); accept(); }