Project Management Overhaul (#47)
* Redo Project Management - Part 1 * Part 2 * Fix build * Cleanup
This commit is contained in:
parent
8d19877058
commit
c04aa72cd3
25 changed files with 427 additions and 759 deletions
|
@ -57,9 +57,9 @@ after_build:
|
|||
|
||||
copy /Y "C:\Tools\opencv\build\x64\vc14\bin\opencv_world412.dll" %CONFIGURATION%\Tahoma
|
||||
|
||||
mkdir "%CONFIGURATION%\Tahoma\portablestuff"
|
||||
mkdir "%CONFIGURATION%\Tahoma\tahomastuff"
|
||||
|
||||
xcopy /Y /E ..\..\stuff "%CONFIGURATION%\Tahoma\portablestuff"
|
||||
xcopy /Y /E ..\..\stuff "%CONFIGURATION%\Tahoma\tahomastuff"
|
||||
|
||||
artifacts:
|
||||
- path: toonz\$(PLATFORM)\$(CONFIGURATION)
|
||||
|
|
|
@ -4,94 +4,12 @@ HD 1080, 1920x1080, 16/9
|
|||
|
||||
HD 720, 1280x720, 16/9
|
||||
|
||||
HD 480, 853x480, 16/9
|
||||
Square, 1000x1000, 1
|
||||
|
||||
AJA Fr01,1920x1080, 10x5.625, 16/9
|
||||
Cinema 1080, 1920x803, 2.39
|
||||
|
||||
PAL analog, 768x576, 4/3
|
||||
Cinema 2K, 2048x858, 2.39
|
||||
|
||||
PAL digital, 720x576, 4/3
|
||||
Cinema 4K, 3840x1607, 2.39
|
||||
|
||||
PAL 16/9, 1024x576, 16/9
|
||||
|
||||
NTSC digital, 720x486, 4/3
|
||||
|
||||
NTSC analog, 648x486, 4/3
|
||||
|
||||
NTSC 16/9, 864x486, 16/9
|
||||
|
||||
Academy Full Frame1 1K, 914x666, 1.37
|
||||
|
||||
Academy Full Frame2 1K, 1024x746, 1.37
|
||||
|
||||
Academy Full Frame1 2K, 1828x1332, 1.37
|
||||
|
||||
Academy Full Frame2 2K, 2048x1494, 1.37
|
||||
|
||||
Academy Full Frame1 4K, 3656x2664, 1.37
|
||||
|
||||
Academy Full Frame2 4K, 4096x2988, 1.37
|
||||
|
||||
Full Camera Aperture 1K, 1024x768, 4/3
|
||||
|
||||
1K, 1024x768, 4/3
|
||||
|
||||
Full Camera Aperture 2K, 2048x1536, 4/3
|
||||
|
||||
2K, 2048x1536, 4/3
|
||||
|
||||
3K, 3072x2304, 4/3
|
||||
|
||||
Full Camera Aperture 4k, 4096x3072, 4/3
|
||||
|
||||
4K, 4096x3072, 4/3
|
||||
|
||||
Cineon Half Unsqueezed, 3675x1556, 2.36183
|
||||
|
||||
Cineon Half, 1828x1556, 2.35
|
||||
|
||||
Cineon Half Squeezed, 1828x1556, 2.36183
|
||||
|
||||
Cineon Full, 3656x3112, 2.35
|
||||
|
||||
Cineon Full, 4704x3112, 2.36183
|
||||
|
||||
Academy Projection1 1K, 914x550, 1.66
|
||||
|
||||
Academy Projection2 1K, 1024x617, 1.66
|
||||
|
||||
Academy Projection1 2K, 1828x1102, 1.66
|
||||
|
||||
Academy Projection2 2K, 2048x1229, 1.66
|
||||
|
||||
Academy Projection1 4K, 3656x2202, 1.66
|
||||
|
||||
Academy Projection2 4K, 4096x2468, 1.66
|
||||
|
||||
Academy Projection1 1K, 914x494, 1.85
|
||||
|
||||
Academy Projection2 1K, 1024x554, 1.85
|
||||
|
||||
Academy Projection1 2K, 1828x988, 1.85
|
||||
|
||||
Academy Projection2 2K, 2048x1107, 1.85
|
||||
|
||||
Academy Projection1 4K, 3656x1976, 1.85
|
||||
|
||||
Academy Projection2 4K, 4096x2214, 1.85
|
||||
|
||||
Anamorphic Pre-squeezed 1K, 914x774, 1.18
|
||||
|
||||
Anamorphic Pre-squeezed 2K, 1828x1550, 1.18
|
||||
|
||||
Anamorphic Pre-squeezed 4K, 3656x3098, 1.18
|
||||
|
||||
Anamorphic Un-squeezed 1K, 914x388, 2.35
|
||||
|
||||
Anamorphic Un-squeezed 2K, 1828x778, 2.35
|
||||
|
||||
Anamorphic Un-squeezed 4K, 3656x1556, 2.35
|
||||
|
||||
DCI 2K, 2048x1080, 256/135
|
||||
|
||||
DCI 4K, 4096x2160, 256/135
|
||||
1K, 1024x768, 4/3
|
|
@ -15,12 +15,9 @@
|
|||
<separator/>
|
||||
<command>MI_LoadColorModel</command>
|
||||
<separator/>
|
||||
<menu title="Project Management">
|
||||
<command>MI_NewProject</command>
|
||||
<command>MI_ProjectSettings</command>
|
||||
<separator/>
|
||||
<command>MI_SaveDefaultSettings</command>
|
||||
</menu>
|
||||
<command>MI_NewProject</command>
|
||||
<separator/>
|
||||
<command>MI_SaveDefaultSettings</command>
|
||||
<separator/>
|
||||
<menu title="Import">
|
||||
<command>MI_ImportMagpieFile</command>
|
||||
|
@ -313,6 +310,8 @@
|
|||
<command>MI_StartupPopup</command>
|
||||
<command>MI_OpenGuidedDrawingControls</command>
|
||||
<separator/>
|
||||
<command>MI_OpenExport</command>
|
||||
<separator/>
|
||||
<command>MI_MaximizePanel</command>
|
||||
<command>MI_FullScreenWindow</command>
|
||||
<separator/>
|
||||
|
|
|
@ -143,7 +143,7 @@ public:
|
|||
TFilePath getStuffDir() {
|
||||
if (m_stuffDir) return *m_stuffDir;
|
||||
if (m_isPortable)
|
||||
return TFilePath((getWorkingDirectory() + "\\portablestuff\\"));
|
||||
return TFilePath((getWorkingDirectory() + "\\tahomastuff\\"));
|
||||
|
||||
return TFilePath(getSystemVarValue(m_rootVarName));
|
||||
}
|
||||
|
@ -226,21 +226,20 @@ public:
|
|||
m_workingDirectory = workingDirectory;
|
||||
|
||||
// check if portable
|
||||
TFilePath portableCheck =
|
||||
TFilePath(m_workingDirectory + "\\portablestuff\\");
|
||||
TFilePath portableCheck = TFilePath(m_workingDirectory + "\\tahomastuff\\");
|
||||
TFileStatus portableStatus(portableCheck);
|
||||
m_isPortable = portableStatus.doesExist();
|
||||
|
||||
#ifdef MACOSX
|
||||
// macOS 10.12 (Sierra) translocates applications before running them
|
||||
// depending on how it was installed. This separates the app from the
|
||||
// portablestuff folder and we don't know where it is so we stop treating it
|
||||
// as a portable. Placing portablestuff inside Tahoma.app will keep
|
||||
// tahomastuff folder and we don't know where it is so we stop treating it
|
||||
// as a portable. Placing stuff inside Tahoma.app will keep
|
||||
// everything together when it translocates.
|
||||
if (!m_isPortable) {
|
||||
portableCheck =
|
||||
TFilePath(m_workingDirectory + "\\" + getApplicationFileName() +
|
||||
".app\\portablestuff\\");
|
||||
".app\\tahomastuff\\");
|
||||
portableStatus = TFileStatus(portableCheck);
|
||||
m_isPortable = portableStatus.doesExist();
|
||||
if (m_isPortable)
|
||||
|
|
|
@ -108,11 +108,11 @@ public:
|
|||
};
|
||||
|
||||
private:
|
||||
std::vector<TFilePath> m_projectsRoots;
|
||||
// std::vector<TFilePath> m_projectsRoots;
|
||||
std::vector<TFilePath> m_svnProjectsRoots;
|
||||
std::set<Listener *> m_listeners;
|
||||
|
||||
void addDefaultProjectsRoot();
|
||||
// void addDefaultProjectsRoot();
|
||||
|
||||
TProjectManager();
|
||||
void notifyListeners();
|
||||
|
@ -135,12 +135,12 @@ public:
|
|||
|
||||
void saveTemplate(ToonzScene *scene);
|
||||
|
||||
void addProjectsRoot(const TFilePath &fp);
|
||||
// void addProjectsRoot(const TFilePath &fp);
|
||||
void addSVNProjectsRoot(const TFilePath &fp);
|
||||
|
||||
//! returns the project root of the current project (if this fails, then
|
||||
//! returns the first project root)
|
||||
TFilePath getCurrentProjectRoot();
|
||||
// TFilePath getCurrentProjectRoot();
|
||||
|
||||
TFilePath projectPathToProjectName(const TFilePath &projectPath);
|
||||
TFilePath projectNameToProjectPath(const TFilePath &projectName);
|
||||
|
@ -166,9 +166,9 @@ public:
|
|||
TFilePath getSandboxProjectFolder();
|
||||
TFilePath getSandboxProjectPath();
|
||||
|
||||
void getProjectRoots(std::vector<TFilePath> &projectRoots) const {
|
||||
projectRoots = m_projectsRoots;
|
||||
}
|
||||
// void getProjectRoots(std::vector<TFilePath> &projectRoots) const {
|
||||
// projectRoots = m_projectsRoots;
|
||||
//}
|
||||
|
||||
bool isProject(const TFilePath &projectFolder);
|
||||
};
|
||||
|
|
|
@ -92,6 +92,7 @@ public:
|
|||
void setValidator(const QValidator *v) { m_field->setValidator(v); }
|
||||
QString getPath();
|
||||
void setPath(const QString &path);
|
||||
LineEdit *getField() { return m_field; }
|
||||
|
||||
static void setBrowserPopupController(BrowserPopupController *controller);
|
||||
static BrowserPopupController *getBrowserPopupController();
|
||||
|
|
|
@ -523,17 +523,17 @@ int main(int argc, char *argv[]) {
|
|||
TFilePath logFilePath = lRootDir + "tcleanup.log";
|
||||
TUserLogAppend m_userLog(logFilePath);
|
||||
|
||||
TFilePathSet fps = ToonzFolder::getProjectsFolders();
|
||||
TFilePathSet::iterator fpIt;
|
||||
for (fpIt = fps.begin(); fpIt != fps.end(); ++fpIt)
|
||||
TProjectManager::instance()->addProjectsRoot(*fpIt);
|
||||
// TFilePathSet fps = ToonzFolder::getProjectsFolders();
|
||||
// TFilePathSet::iterator fpIt;
|
||||
// for (fpIt = fps.begin(); fpIt != fps.end(); ++fpIt)
|
||||
// TProjectManager::instance()->addProjectsRoot(*fpIt);
|
||||
|
||||
TFilePath libraryFolder = ToonzFolder::getLibraryFolder();
|
||||
TRasterImagePatternStrokeStyle::setRootDir(libraryFolder);
|
||||
TVectorImagePatternStrokeStyle::setRootDir(libraryFolder);
|
||||
TPalette::setRootDir(libraryFolder);
|
||||
TImageStyle::setLibraryDir(libraryFolder);
|
||||
TFilePath cacheRoot = ToonzFolder::getCacheRootFolder();
|
||||
TFilePath cacheRoot = ToonzFolder::getCacheRootFolder();
|
||||
if (cacheRoot.isEmpty()) cacheRoot = TEnv::getStuffDir() + "cache";
|
||||
TImageCache::instance()->setRootDir(cacheRoot);
|
||||
|
||||
|
@ -843,4 +843,3 @@ int main(int argc, char *argv[]) {
|
|||
return 0;
|
||||
}
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -713,10 +713,10 @@ int main(int argc, char *argv[]) {
|
|||
TMeasureManager::instance()-> // Loads camera-related units
|
||||
addCameraMeasures(getCurrentCameraSize); //
|
||||
|
||||
TFilePathSet fps = ToonzFolder::getProjectsFolders();
|
||||
TFilePathSet::iterator fpIt;
|
||||
for (fpIt = fps.begin(); fpIt != fps.end(); ++fpIt)
|
||||
TProjectManager::instance()->addProjectsRoot(*fpIt);
|
||||
// TFilePathSet fps = ToonzFolder::getProjectsFolders();
|
||||
// TFilePathSet::iterator fpIt;
|
||||
// for (fpIt = fps.begin(); fpIt != fps.end(); ++fpIt)
|
||||
// TProjectManager::instance()->addProjectsRoot(*fpIt);
|
||||
|
||||
TFilePath libraryFolder = ToonzFolder::getLibraryFolder();
|
||||
TRasterImagePatternStrokeStyle::setRootDir(libraryFolder);
|
||||
|
|
|
@ -154,7 +154,7 @@ bool DvDirTreeViewDelegate::editorEvent(QEvent *ev, QAbstractItemModel *model,
|
|||
m_treeView->expand(index);
|
||||
}
|
||||
|
||||
if ((pnode && pnode->isCurrent() == false && 14 < x && x < 26) ||
|
||||
if ( //(pnode && pnode->isCurrent() == false && 14 < x && x < 26) ||
|
||||
(vcpNode && vcpNode->isCurrent() == false && 14 < x && x < 26)) {
|
||||
if (pnode)
|
||||
pnode->makeCurrent();
|
||||
|
@ -212,7 +212,8 @@ void DvDirTreeViewDelegate::paint(QPainter *painter,
|
|||
DvDirVersionControlNode *vcNode =
|
||||
dynamic_cast<DvDirVersionControlNode *>(node);
|
||||
|
||||
rect.adjust((pnode || vcpNode) ? 31 : 22, 0, 0, 0);
|
||||
// rect.adjust((pnode || vcpNode) ? 31 : 22, 0, 0, 0);
|
||||
rect.adjust((vcpNode) ? 31 : 22, 0, 0, 0);
|
||||
|
||||
// draw text
|
||||
QVariant d = index.data();
|
||||
|
@ -231,7 +232,8 @@ void DvDirTreeViewDelegate::paint(QPainter *painter,
|
|||
painter->drawText(rect, Qt::AlignVCenter | Qt::AlignLeft, name);
|
||||
|
||||
// project folder node, version control node
|
||||
if (pnode || vcpNode) {
|
||||
// if (pnode || vcpNode) {
|
||||
if (vcpNode) {
|
||||
painter->setPen(m_treeView->getTextColor());
|
||||
if ((pnode && pnode->isCurrent()) || (vcpNode && vcpNode->isCurrent()))
|
||||
painter->setBrush(Qt::red);
|
||||
|
@ -302,6 +304,7 @@ void DvDirTreeViewDelegate::commitAndCloseEditor() {
|
|||
FileBrowser *fileBrowser =
|
||||
dynamic_cast<FileBrowser *>(m_treeView->parentWidget());
|
||||
if (fileBrowser) fileBrowser->onTreeFolderChanged();
|
||||
emit(m_treeView->currentNodeChanged());
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -177,7 +177,7 @@ void ExportSceneDvDirModelRootNode::refreshChildren() {
|
|||
//{
|
||||
TProjectManager *pm = TProjectManager::instance();
|
||||
std::vector<TFilePath> projectRoots;
|
||||
pm->getProjectRoots(projectRoots);
|
||||
// pm->getProjectRoots(projectRoots);
|
||||
|
||||
int i;
|
||||
for (i = 0; i < (int)projectRoots.size(); i++) {
|
||||
|
@ -264,7 +264,7 @@ DvDirModelNode *ExportSceneDvDirModel::getNode(const QModelIndex &index) const {
|
|||
QModelIndex ExportSceneDvDirModel::index(int row, int column,
|
||||
const QModelIndex &parent) const {
|
||||
if (column != 0) return QModelIndex();
|
||||
DvDirModelNode *parentNode = m_root;
|
||||
DvDirModelNode *parentNode = m_root;
|
||||
if (parent.isValid()) parentNode = getNode(parent);
|
||||
if (row < 0 || row >= parentNode->getChildCount()) return QModelIndex();
|
||||
DvDirModelNode *node = parentNode->getChild(row);
|
||||
|
@ -454,9 +454,9 @@ ExportSceneTreeView::ExportSceneTreeView(QWidget *parent)
|
|||
// bottom horizontal scrollbar to resize contents...
|
||||
bool ret = connect(this, SIGNAL(expanded(const QModelIndex &)), this,
|
||||
SLOT(resizeToConts()));
|
||||
ret = ret && connect(this, SIGNAL(collapsed(const QModelIndex &)), this,
|
||||
ret = ret && connect(this, SIGNAL(collapsed(const QModelIndex &)), this,
|
||||
SLOT(resizeToConts()));
|
||||
ret = ret && connect(this->model(), SIGNAL(layoutChanged()), this,
|
||||
ret = ret && connect(this->model(), SIGNAL(layoutChanged()), this,
|
||||
SLOT(resizeToConts()));
|
||||
|
||||
assert(ret);
|
||||
|
@ -672,16 +672,8 @@ TFilePath ExportScenePopup::createNewProject() {
|
|||
return TFilePath();
|
||||
}
|
||||
|
||||
TFilePath currentProjectRoot;
|
||||
DvDirModelFileFolderNode *node = dynamic_cast<DvDirModelFileFolderNode *>(
|
||||
m_projectTreeView->getCurrentNode());
|
||||
if (node)
|
||||
currentProjectRoot = node->getPath();
|
||||
else
|
||||
currentProjectRoot = pm->getCurrentProjectRoot();
|
||||
TFilePath projectFolder = currentProjectRoot + projectName;
|
||||
TFilePath projectPath = pm->projectFolderToProjectPath(projectFolder);
|
||||
TProject *project = new TProject();
|
||||
TFilePath projectPath = pm->projectNameToProjectPath(projectName);
|
||||
TProject *project = new TProject();
|
||||
|
||||
TProjectP currentProject = pm->getCurrentProject();
|
||||
assert(currentProject);
|
||||
|
@ -690,7 +682,7 @@ TFilePath ExportScenePopup::createNewProject() {
|
|||
project->setFolder(currentProject->getFolderName(i),
|
||||
currentProject->getFolder(i));
|
||||
project->save(projectPath);
|
||||
DvDirModel::instance()->refreshFolder(currentProjectRoot);
|
||||
DvDirModel::instance()->refreshFolder(projectPath.getParentDir());
|
||||
|
||||
return projectPath;
|
||||
}
|
||||
|
|
|
@ -2067,8 +2067,10 @@ void FileBrowser::onSelectedItems(const std::set<int> &indexes) {
|
|||
}
|
||||
|
||||
for (it = indexes.begin(); it != indexes.end(); ++it) {
|
||||
filePaths.insert(m_items[*it].m_path);
|
||||
frameIDs.insert(frameIDs.begin(), m_items[*it].m_frameIds);
|
||||
if (*it < m_items.size()) {
|
||||
filePaths.insert(m_items[*it].m_path);
|
||||
frameIDs.insert(frameIDs.begin(), m_items[*it].m_frameIds);
|
||||
}
|
||||
}
|
||||
|
||||
// reuse the list of TFrameId in order to skip loadInfo() when loading the
|
||||
|
|
|
@ -217,7 +217,8 @@ DvDirModelFileFolderNode *DvDirModelFileFolderNode::createNode(
|
|||
DvDirModelNode *parent, const TFilePath &path) {
|
||||
DvDirModelFileFolderNode *node;
|
||||
// check the project nodes under the Poject Root Node
|
||||
if (QString::fromStdWString(parent->getName()).startsWith("Project root") &&
|
||||
if ( // QString::fromStdWString(parent->getName()).startsWith("Project root")
|
||||
// &&
|
||||
TProjectManager::instance()->isProject(path))
|
||||
node = new DvDirModelProjectNode(parent, path);
|
||||
else {
|
||||
|
@ -1070,21 +1071,21 @@ void DvDirModelRootNode::refreshChildren() {
|
|||
addChild(new DvDirModelHistoryNode(this));
|
||||
|
||||
TProjectManager *pm = TProjectManager::instance();
|
||||
std::vector<TFilePath> projectRoots;
|
||||
pm->getProjectRoots(projectRoots);
|
||||
// std::vector<TFilePath> projectRoots;
|
||||
// pm->getProjectRoots(projectRoots);
|
||||
|
||||
int i;
|
||||
for (i = 0; i < (int)projectRoots.size(); i++) {
|
||||
TFilePath projectRoot = projectRoots[i];
|
||||
std::wstring roothDir = projectRoot.getWideString();
|
||||
DvDirModelSpecialFileFolderNode *projectRootNode =
|
||||
new DvDirModelSpecialFileFolderNode(
|
||||
this, L"Project root (" + roothDir + L")", projectRoot);
|
||||
projectRootNode->setPixmap(
|
||||
QPixmap(svgToPixmap(":Resources/projects.svg")));
|
||||
m_projectRootNodes.push_back(projectRootNode);
|
||||
addChild(projectRootNode);
|
||||
}
|
||||
// int i;
|
||||
// for (i = 0; i < (int)projectRoots.size(); i++) {
|
||||
// TFilePath projectRoot = projectRoots[i];
|
||||
// std::wstring roothDir = projectRoot.getWideString();
|
||||
// DvDirModelSpecialFileFolderNode *projectRootNode =
|
||||
// new DvDirModelSpecialFileFolderNode(
|
||||
// this, L"Project root (" + roothDir + L")", projectRoot);
|
||||
// projectRootNode->setPixmap(
|
||||
// QPixmap(svgToPixmap(":Resources/projects.svg")));
|
||||
// m_projectRootNodes.push_back(projectRootNode);
|
||||
// addChild(projectRootNode);
|
||||
//}
|
||||
|
||||
TFilePath sandboxProjectPath = pm->getSandboxProjectFolder();
|
||||
m_sandboxProjectNode = new DvDirModelProjectNode(this, sandboxProjectPath);
|
||||
|
@ -1280,11 +1281,15 @@ void DvDirModel::onFolderChanged(const TFilePath &path) { refreshFolder(path); }
|
|||
void DvDirModel::refresh(const QModelIndex &index) {
|
||||
if (!index.isValid()) return;
|
||||
DvDirModelNode *node = getNode(index);
|
||||
if (!node || node->getChildCount() < 1) return;
|
||||
if (!node) return;
|
||||
emit layoutAboutToBeChanged();
|
||||
emit beginRemoveRows(index, 0, node->getChildCount() - 1);
|
||||
bool emitBeginAndEnd = false;
|
||||
int rc = rowCount(index);
|
||||
int cc = node->getChildCount();
|
||||
if (cc < rc) emitBeginAndEnd = true;
|
||||
if (emitBeginAndEnd) emit beginRemoveRows(index, 0, node->getChildCount());
|
||||
node->refreshChildren();
|
||||
emit endRemoveRows();
|
||||
if (emitBeginAndEnd) emit endRemoveRows();
|
||||
emit layoutChanged();
|
||||
}
|
||||
|
||||
|
|
|
@ -254,8 +254,12 @@ void FileBrowserPopup::onOkPressed() {
|
|||
} else {
|
||||
if (!m_isDirectoryOnly)
|
||||
pathSet.insert(*pt);
|
||||
else
|
||||
pathSet.insert(folder);
|
||||
else {
|
||||
if (TFileStatus(*pt).isDirectory())
|
||||
pathSet.insert(*pt);
|
||||
else
|
||||
pathSet.insert(folder);
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_multiSelectionEnabled) break;
|
||||
|
@ -300,8 +304,12 @@ void FileBrowserPopup::onApplyPressed() {
|
|||
} else {
|
||||
if (!m_isDirectoryOnly)
|
||||
pathSet.insert(*it);
|
||||
else
|
||||
else {
|
||||
// if (TFileStatus(*it).isDirectory())
|
||||
// pathSet.insert(*it);
|
||||
// else
|
||||
pathSet.insert(folder);
|
||||
}
|
||||
}
|
||||
if (!m_multiSelectionEnabled) break;
|
||||
++it;
|
||||
|
@ -338,8 +346,13 @@ void FileBrowserPopup::onFilePathsSelected(
|
|||
QString text;
|
||||
if (!m_isDirectoryOnly)
|
||||
text = QString::fromStdWString(fp.getLevelNameW());
|
||||
else
|
||||
text = QString::fromStdWString(m_browser->getFolder().getWideString());
|
||||
else {
|
||||
if (TFileStatus(fp).isDirectory())
|
||||
text = fp.getQString();
|
||||
else
|
||||
text = QString::fromStdWString(m_browser->getFolder().getWideString());
|
||||
}
|
||||
std::string textStr = text.toStdString();
|
||||
|
||||
m_nameField->setText(text);
|
||||
} else
|
||||
|
|
|
@ -1812,33 +1812,35 @@ bool IoCmd::loadScene(const TFilePath &path, bool updateRecentFile,
|
|||
DVGui::warning(msg);
|
||||
}
|
||||
if (sceneProject && !sceneProject->isCurrent()) {
|
||||
QString currentProjectName = QString::fromStdWString(
|
||||
pm->getCurrentProject()->getName().getWideString());
|
||||
QString sceneProjectName =
|
||||
QString::fromStdWString(sceneProject->getName().getWideString());
|
||||
|
||||
/*QString question = "The Scene '"
|
||||
+ QString::fromStdWString(scenePath.getWideString())
|
||||
+ "' belongs to project '" + sceneProjectName + "'.\n"
|
||||
+ "What do you want to do?";*/
|
||||
QString question =
|
||||
QObject::tr(
|
||||
"The Scene '%1' belongs to project '%2'.\nWhat do you want to do?")
|
||||
.arg(QString::fromStdWString(scenePath.getWideString()))
|
||||
.arg(sceneProjectName);
|
||||
QString importAnswer = QObject::tr("Import Scene");
|
||||
QString switchProjectAnswer = QObject::tr("Change Project");
|
||||
QString cancelAnswer = QObject::tr("Cancel");
|
||||
int ret = DVGui::MsgBox(question, importAnswer, switchProjectAnswer,
|
||||
cancelAnswer, 0);
|
||||
if (ret == 3 || ret == 0) {
|
||||
newScene();
|
||||
return false;
|
||||
}
|
||||
if (ret == 2)
|
||||
pm->setCurrentProjectPath(sceneProject->getProjectPath());
|
||||
else
|
||||
importScene = true;
|
||||
pm->setCurrentProjectPath(sceneProject->getProjectPath());
|
||||
// QString currentProjectName = QString::fromStdWString(
|
||||
// pm->getCurrentProject()->getName().getWideString());
|
||||
// QString sceneProjectName =
|
||||
// QString::fromStdWString(sceneProject->getName().getWideString());
|
||||
//
|
||||
// /*QString question = "The Scene '"
|
||||
// + QString::fromStdWString(scenePath.getWideString())
|
||||
//+ "' belongs to project '" + sceneProjectName + "'.\n"
|
||||
//+ "What do you want to do?";*/
|
||||
// QString question =
|
||||
// QObject::tr(
|
||||
// "The Scene '%1' belongs to project '%2'.\nWhat do you want to
|
||||
// do?")
|
||||
// .arg(QString::fromStdWString(scenePath.getWideString()))
|
||||
// .arg(sceneProjectName);
|
||||
// QString importAnswer = QObject::tr("Import Scene");
|
||||
// QString switchProjectAnswer = QObject::tr("Change Project");
|
||||
// QString cancelAnswer = QObject::tr("Cancel");
|
||||
// int ret = DVGui::MsgBox(question, importAnswer, switchProjectAnswer,
|
||||
// cancelAnswer, 0);
|
||||
// if (ret == 3 || ret == 0) {
|
||||
// newScene();
|
||||
// return false;
|
||||
// }
|
||||
// if (ret == 2)
|
||||
// pm->setCurrentProjectPath(sceneProject->getProjectPath());
|
||||
// else
|
||||
// importScene = true;
|
||||
}
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
|
||||
|
|
|
@ -204,10 +204,10 @@ static void initToonzEnv(QHash<QString, QString> &argPathValues) {
|
|||
/*--
|
||||
* TOONZPROJECTSのパスセットを取得する。(TOONZPROJECTSはセミコロンで区切って複数設定可能)
|
||||
* --*/
|
||||
TFilePathSet projectsRoots = ToonzFolder::getProjectsFolders();
|
||||
TFilePathSet::iterator it;
|
||||
for (it = projectsRoots.begin(); it != projectsRoots.end(); ++it)
|
||||
projectManager->addProjectsRoot(*it);
|
||||
// TFilePathSet projectsRoots = ToonzFolder::getProjectsFolders();
|
||||
// TFilePathSet::iterator it;
|
||||
// for (it = projectsRoots.begin(); it != projectsRoots.end(); ++it)
|
||||
// projectManager->addProjectsRoot(*it);
|
||||
|
||||
/*-- もしまだ無ければ、TOONZROOT/sandboxにsandboxプロジェクトを作る --*/
|
||||
projectManager->createSandboxIfNeeded();
|
||||
|
|
|
@ -1665,9 +1665,9 @@ void MainWindow::defineActions() {
|
|||
createMenuFileAction(MI_ImportMagpieFile,
|
||||
tr("&Import Toonz Lip Sync File..."), "");
|
||||
createMenuFileAction(MI_NewProject, tr("&New Project..."), "");
|
||||
createMenuFileAction(MI_ProjectSettings, tr("&Project Settings..."), "");
|
||||
createMenuFileAction(MI_SaveDefaultSettings, tr("&Save Default Settings"),
|
||||
"");
|
||||
// createMenuFileAction(MI_ProjectSettings, tr("&Project Settings..."), "");
|
||||
createMenuFileAction(MI_SaveDefaultSettings,
|
||||
tr("&Save Project Default Settings"), "");
|
||||
createMenuRenderAction(MI_OutputSettings, tr("&Output Settings..."),
|
||||
"Ctrl+O");
|
||||
createMenuRenderAction(MI_PreviewSettings, tr("&Preview Settings..."), "");
|
||||
|
|
|
@ -381,13 +381,13 @@ QMenuBar *StackedMenuBar::createFullMenuBar() {
|
|||
fileMenu->addSeparator();
|
||||
addMenuItem(fileMenu, MI_LoadColorModel);
|
||||
fileMenu->addSeparator();
|
||||
QMenu *projectManagementMenu = fileMenu->addMenu(tr("Project Management"));
|
||||
{
|
||||
addMenuItem(projectManagementMenu, MI_NewProject);
|
||||
addMenuItem(projectManagementMenu, MI_ProjectSettings);
|
||||
projectManagementMenu->addSeparator();
|
||||
addMenuItem(projectManagementMenu, MI_SaveDefaultSettings);
|
||||
}
|
||||
addMenuItem(fileMenu, MI_NewProject);
|
||||
fileMenu->addSeparator();
|
||||
addMenuItem(fileMenu, MI_SaveDefaultSettings);
|
||||
// QMenu *projectManagementMenu = fileMenu->addMenu(tr("Project Management"));
|
||||
//{
|
||||
// //addMenuItem(projectManagementMenu, MI_ProjectSettings);
|
||||
//}
|
||||
fileMenu->addSeparator();
|
||||
QMenu *importMenu = fileMenu->addMenu(tr("Import"));
|
||||
{ addMenuItem(importMenu, MI_ImportMagpieFile); }
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
#define MI_NewNoteLevel "MI_NewNoteLevel"
|
||||
#define MI_RemoveEmptyColumns "MI_RemoveEmptyColumns"
|
||||
#define MI_NewProject "MI_NewProject"
|
||||
#define MI_ProjectSettings "MI_ProjectSettings"
|
||||
//#define MI_ProjectSettings "MI_ProjectSettings"
|
||||
#define MI_SaveDefaultSettings "MI_SaveDefaultSettings"
|
||||
#define MI_OutputSettings "MI_OutputSettings"
|
||||
#define MI_PreviewSettings "MI_PreviewSettings"
|
||||
|
|
|
@ -581,15 +581,15 @@ void PreferencesPopup::onAutoSavePeriodExternallyChanged() {
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void PreferencesPopup::onProjectRootChanged() {
|
||||
int index = 0;
|
||||
// if (m_projectRootStuff->isChecked())
|
||||
index |= 0x08;
|
||||
if (m_projectRootDocuments->isChecked()) index |= 0x04;
|
||||
if (m_projectRootDesktop->isChecked()) index |= 0x02;
|
||||
if (m_projectRootCustom->isChecked()) index |= 0x01;
|
||||
m_pref->setValue(projectRoot, index);
|
||||
}
|
||||
// void PreferencesPopup::onProjectRootChanged() {
|
||||
// int index = 0;
|
||||
// // if (m_projectRootStuff->isChecked())
|
||||
// index |= 0x08;
|
||||
// if (m_projectRootDocuments->isChecked()) index |= 0x04;
|
||||
// if (m_projectRootDesktop->isChecked()) index |= 0x02;
|
||||
// if (m_projectRootCustom->isChecked()) index |= 0x01;
|
||||
// m_pref->setValue(projectRoot, index);
|
||||
//}
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void PreferencesPopup::onPixelUnitExternallySelected(bool on) {
|
||||
|
@ -1253,21 +1253,21 @@ PreferencesPopup::PreferencesPopup()
|
|||
//-----------------------------------------------------------------------------
|
||||
|
||||
QWidget* PreferencesPopup::createGeneralPage() {
|
||||
m_projectRootDocuments = new CheckBox(tr("My Documents/Tahoma*"), this);
|
||||
m_projectRootDesktop = new CheckBox(tr("Desktop/Tahoma*"), this);
|
||||
m_projectRootCustom = new CheckBox(tr("Custom*"), this);
|
||||
QWidget* customField = new QWidget(this);
|
||||
QGridLayout* customLay = new QGridLayout();
|
||||
setupLayout(customLay, 5);
|
||||
{
|
||||
insertUI(customProjectRoot, customLay);
|
||||
customLay->addWidget(
|
||||
new QLabel(
|
||||
tr("Advanced: Multiple paths can be separated by ** (No Spaces)"),
|
||||
this),
|
||||
customLay->rowCount(), 0, 1, 2, Qt::AlignLeft | Qt::AlignVCenter);
|
||||
}
|
||||
customField->setLayout(customLay);
|
||||
// m_projectRootDocuments = new CheckBox(tr("My Documents/Tahoma*"), this);
|
||||
// m_projectRootDesktop = new CheckBox(tr("Desktop/Tahoma*"), this);
|
||||
// m_projectRootCustom = new CheckBox(tr("Custom*"), this);
|
||||
// QWidget* customField = new QWidget(this);
|
||||
// QGridLayout* customLay = new QGridLayout();
|
||||
// setupLayout(customLay, 5);
|
||||
//{
|
||||
// insertUI(customProjectRoot, customLay);
|
||||
// customLay->addWidget(
|
||||
// new QLabel(
|
||||
// tr("Advanced: Multiple paths can be separated by ** (No Spaces)"),
|
||||
// this),
|
||||
// customLay->rowCount(), 0, 1, 2, Qt::AlignLeft | Qt::AlignVCenter);
|
||||
//}
|
||||
// customField->setLayout(customLay);
|
||||
|
||||
QWidget* widget = new QWidget(this);
|
||||
QGridLayout* lay = new QGridLayout();
|
||||
|
@ -1290,14 +1290,14 @@ QWidget* PreferencesPopup::createGeneralPage() {
|
|||
insertUI(sceneNumberingEnabled, lay);
|
||||
insertUI(watchFileSystemEnabled, lay);
|
||||
|
||||
QGridLayout* projectRootLay =
|
||||
insertGroupBox(tr("Additional Project Locations"), lay);
|
||||
{
|
||||
projectRootLay->addWidget(m_projectRootDocuments, 0, 0, 1, 2);
|
||||
projectRootLay->addWidget(m_projectRootDesktop, 1, 0, 1, 2);
|
||||
projectRootLay->addWidget(m_projectRootCustom, 2, 0, 1, 2);
|
||||
projectRootLay->addWidget(customField, 3, 0, 1, 2);
|
||||
}
|
||||
// QGridLayout* projectRootLay =
|
||||
// insertGroupBox(tr("Additional Project Locations"), lay);
|
||||
//{
|
||||
// projectRootLay->addWidget(m_projectRootDocuments, 0, 0, 1, 2);
|
||||
// projectRootLay->addWidget(m_projectRootDesktop, 1, 0, 1, 2);
|
||||
// projectRootLay->addWidget(m_projectRootCustom, 2, 0, 1, 2);
|
||||
// projectRootLay->addWidget(customField, 3, 0, 1, 2);
|
||||
//}
|
||||
|
||||
insertUI(pathAliasPriority, lay, getComboItemList(pathAliasPriority));
|
||||
|
||||
|
@ -1305,11 +1305,11 @@ QWidget* PreferencesPopup::createGeneralPage() {
|
|||
insertFootNote(lay);
|
||||
widget->setLayout(lay);
|
||||
|
||||
int projectPaths = m_pref->getIntValue(projectRoot);
|
||||
m_projectRootDocuments->setChecked(projectPaths & 0x04);
|
||||
m_projectRootDesktop->setChecked(projectPaths & 0x02);
|
||||
m_projectRootCustom->setChecked(projectPaths & 0x01);
|
||||
if (!(projectPaths & 0x01)) customField->hide();
|
||||
// int projectPaths = m_pref->getIntValue(projectRoot);
|
||||
// m_projectRootDocuments->setChecked(projectPaths & 0x04);
|
||||
// m_projectRootDesktop->setChecked(projectPaths & 0x02);
|
||||
// m_projectRootCustom->setChecked(projectPaths & 0x01);
|
||||
// if (!(projectPaths & 0x01)) customField->hide();
|
||||
|
||||
QComboBox* pathAliasPriorityCB = getUI<QComboBox*>(pathAliasPriority);
|
||||
pathAliasPriorityCB->setToolTip(
|
||||
|
@ -1341,14 +1341,15 @@ QWidget* PreferencesPopup::createGeneralPage() {
|
|||
ret = ret && connect(m_pref, SIGNAL(autoSavePeriodChanged()), this,
|
||||
SLOT(onAutoSavePeriodExternallyChanged()));
|
||||
|
||||
ret = ret && connect(m_projectRootDocuments, SIGNAL(stateChanged(int)),
|
||||
SLOT(onProjectRootChanged()));
|
||||
ret = ret && connect(m_projectRootDesktop, SIGNAL(stateChanged(int)),
|
||||
SLOT(onProjectRootChanged()));
|
||||
ret = ret && connect(m_projectRootCustom, SIGNAL(stateChanged(int)),
|
||||
SLOT(onProjectRootChanged()));
|
||||
ret = ret && connect(m_projectRootCustom, SIGNAL(clicked(bool)), customField,
|
||||
SLOT(setVisible(bool)));
|
||||
// ret = ret && connect(m_projectRootDocuments, SIGNAL(stateChanged(int)),
|
||||
// SLOT(onProjectRootChanged()));
|
||||
// ret = ret && connect(m_projectRootDesktop, SIGNAL(stateChanged(int)),
|
||||
// SLOT(onProjectRootChanged()));
|
||||
// ret = ret && connect(m_projectRootCustom, SIGNAL(stateChanged(int)),
|
||||
// SLOT(onProjectRootChanged()));
|
||||
// ret = ret && connect(m_projectRootCustom, SIGNAL(clicked(bool)),
|
||||
// customField,
|
||||
// SLOT(setVisible(bool)));
|
||||
assert(ret);
|
||||
|
||||
return widget;
|
||||
|
|
|
@ -68,8 +68,8 @@ private:
|
|||
Preferences* m_pref;
|
||||
FormatProperties* m_formatProperties;
|
||||
|
||||
DVGui::CheckBox *m_projectRootDocuments, *m_projectRootDesktop,
|
||||
*m_projectRootCustom;
|
||||
// DVGui::CheckBox *m_projectRootDocuments, *m_projectRootDesktop,
|
||||
// *m_projectRootCustom;
|
||||
QPushButton* m_editLevelFormat;
|
||||
QComboBox* m_levelFormatNames;
|
||||
|
||||
|
@ -147,7 +147,7 @@ private slots:
|
|||
|
||||
void onAutoSaveExternallyChanged();
|
||||
void onAutoSavePeriodExternallyChanged();
|
||||
void onProjectRootChanged();
|
||||
// void onProjectRootChanged();
|
||||
void onPixelUnitExternallySelected(bool on);
|
||||
void onInterfaceFontChanged(const QString& text);
|
||||
void onLutPathChanged();
|
||||
|
|
|
@ -28,239 +28,16 @@
|
|||
#include <QLabel>
|
||||
#include <QMainWindow>
|
||||
#include <QComboBox>
|
||||
#include <QStandardPaths>
|
||||
|
||||
using namespace DVGui;
|
||||
|
||||
//=============================================================================
|
||||
// ProjectDvDirModelProjectNode
|
||||
//-----------------------------------------------------------------------------
|
||||
//===================================================================
|
||||
|
||||
QPixmap ProjectDvDirModelProjectNode::getPixmap(bool isOpen) const {
|
||||
static QPixmap openProjectPixmap(
|
||||
svgToPixmap(":Resources/browser_project_open.svg"));
|
||||
static QPixmap closeProjectPixmap(
|
||||
svgToPixmap(":Resources/browser_project_close.svg"));
|
||||
return isOpen ? openProjectPixmap : closeProjectPixmap;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
// ProjectDvDirModelFileFolderNode [Root]
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
DvDirModelNode *ProjectDvDirModelFileFolderNode::makeChild(std::wstring name) {
|
||||
return createNode(this, m_path + name);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
DvDirModelFileFolderNode *ProjectDvDirModelFileFolderNode::createNode(
|
||||
DvDirModelNode *parent, const TFilePath &path) {
|
||||
DvDirModelFileFolderNode *node;
|
||||
if (TProjectManager::instance()->isProject(path))
|
||||
node = new ProjectDvDirModelProjectNode(parent, path);
|
||||
else
|
||||
node = new ProjectDvDirModelFileFolderNode(parent, path);
|
||||
return node;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
// ProjectDvDirModelSpecialFileFolderNode
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//=============================================================================
|
||||
// ProjectDvDirModelRootNode [Root]
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ProjectDvDirModelRootNode::ProjectDvDirModelRootNode()
|
||||
: DvDirModelNode(0, L"Root") {
|
||||
m_nodeType = "Root";
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void ProjectDvDirModelRootNode::refreshChildren() {
|
||||
m_childrenValid = true;
|
||||
if (m_children.empty()) {
|
||||
TProjectManager *pm = TProjectManager::instance();
|
||||
std::vector<TFilePath> projectRoots;
|
||||
pm->getProjectRoots(projectRoots);
|
||||
|
||||
int i;
|
||||
for (i = 0; i < (int)projectRoots.size(); i++) {
|
||||
TFilePath projectRoot = projectRoots[i];
|
||||
std::wstring rootDir = projectRoot.getWideString();
|
||||
ProjectDvDirModelSpecialFileFolderNode *projectRootNode =
|
||||
new ProjectDvDirModelSpecialFileFolderNode(
|
||||
this, L"Project root (" + rootDir + L")", projectRoot);
|
||||
projectRootNode->setPixmap(svgToPixmap(":Resources/projects.svg"));
|
||||
addChild(projectRootNode);
|
||||
}
|
||||
|
||||
// SVN Repository
|
||||
QList<SVNRepository> repositories =
|
||||
VersionControl::instance()->getRepositories();
|
||||
int count = repositories.size();
|
||||
for (int i = 0; i < count; i++) {
|
||||
SVNRepository repo = repositories.at(i);
|
||||
|
||||
ProjectDvDirModelSpecialFileFolderNode *node =
|
||||
new ProjectDvDirModelSpecialFileFolderNode(
|
||||
this, repo.m_name.toStdWString(),
|
||||
TFilePath(repo.m_localPath.toStdWString()));
|
||||
node->setPixmap(svgToPixmap(":Resources/vcroot.svg"));
|
||||
addChild(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
// ProjectDirModel
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ProjectDirModel::ProjectDirModel() {
|
||||
m_root = new ProjectDvDirModelRootNode();
|
||||
m_root->refreshChildren();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ProjectDirModel::~ProjectDirModel() { delete m_root; }
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
DvDirModelNode *ProjectDirModel::getNode(const QModelIndex &index) const {
|
||||
if (index.isValid())
|
||||
return static_cast<DvDirModelNode *>(index.internalPointer());
|
||||
else
|
||||
return m_root;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
QModelIndex ProjectDirModel::index(int row, int column,
|
||||
const QModelIndex &parent) const {
|
||||
if (column != 0) return QModelIndex();
|
||||
DvDirModelNode *parentNode = m_root;
|
||||
if (parent.isValid()) parentNode = getNode(parent);
|
||||
if (row < 0 || row >= parentNode->getChildCount()) return QModelIndex();
|
||||
DvDirModelNode *node = parentNode->getChild(row);
|
||||
return createIndex(row, column, node);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
QModelIndex ProjectDirModel::parent(const QModelIndex &index) const {
|
||||
if (!index.isValid()) return QModelIndex();
|
||||
DvDirModelNode *node = getNode(index);
|
||||
DvDirModelNode *parentNode = node->getParent();
|
||||
if (!parentNode || parentNode == m_root)
|
||||
return QModelIndex();
|
||||
else
|
||||
return createIndex(parentNode->getRow(), 0, parentNode);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
QModelIndex ProjectDirModel::childByName(const QModelIndex &parent,
|
||||
const std::wstring &name) const {
|
||||
if (!parent.isValid()) return QModelIndex();
|
||||
DvDirModelNode *parentNode = getNode(parent);
|
||||
if (!parentNode) return QModelIndex();
|
||||
int row = parentNode->rowByName(name);
|
||||
if (row < 0 || row >= parentNode->getChildCount()) return QModelIndex();
|
||||
DvDirModelNode *childNode = parentNode->getChild(row);
|
||||
return createIndex(row, 0, childNode);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int ProjectDirModel::rowCount(const QModelIndex &parent) const {
|
||||
DvDirModelNode *node = getNode(parent);
|
||||
int childCount = node->getChildCount();
|
||||
return childCount;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
QVariant ProjectDirModel::data(const QModelIndex &index, int role) const {
|
||||
if (!index.isValid()) return QVariant();
|
||||
DvDirModelNode *node = getNode(index);
|
||||
if (role == Qt::DisplayRole || role == Qt::EditRole)
|
||||
return QString::fromStdWString(node->getName());
|
||||
else if (role == Qt::DecorationRole) {
|
||||
return QVariant();
|
||||
} else if (role == Qt::ForegroundRole) {
|
||||
if (!node || !node->isRenameEnabled())
|
||||
return QBrush(Qt::blue);
|
||||
else
|
||||
return QVariant();
|
||||
} else
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
Qt::ItemFlags ProjectDirModel::flags(const QModelIndex &index) const {
|
||||
Qt::ItemFlags flags = QAbstractItemModel::flags(index);
|
||||
if (index.isValid()) {
|
||||
DvDirModelNode *node = getNode(index);
|
||||
if (node && node->isRenameEnabled()) flags |= Qt::ItemIsEditable;
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool ProjectDirModel::setData(const QModelIndex &index, const QVariant &value,
|
||||
int role) {
|
||||
if (!index.isValid()) return false;
|
||||
DvDirModelNode *node = getNode(index);
|
||||
if (!node || !node->isRenameEnabled()) return false;
|
||||
QString newName = value.toString();
|
||||
if (newName == "") return false;
|
||||
if (!node->setName(newName.toStdWString())) return false;
|
||||
emit dataChanged(index, index);
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool ProjectDirModel::hasChildren(const QModelIndex &parent) const {
|
||||
DvDirModelNode *node = getNode(parent);
|
||||
return node->hasChildren();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void ProjectDirModel::refresh(const QModelIndex &index) {
|
||||
if (!index.isValid()) return;
|
||||
DvDirModelNode *node = getNode(index);
|
||||
if (!node) return;
|
||||
emit layoutAboutToBeChanged();
|
||||
emit beginRemoveRows(index, 0, node->getChildCount());
|
||||
node->refreshChildren();
|
||||
emit endRemoveRows();
|
||||
emit layoutChanged();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void ProjectDirModel::refreshFolderChild(const QModelIndex &i) {
|
||||
DvDirModelNode *node = getNode(i);
|
||||
if (!node || !node->areChildrenValid()) return;
|
||||
|
||||
if (node->isFolder() || dynamic_cast<DvDirModelMyComputerNode *>(node))
|
||||
refresh(i);
|
||||
int count = rowCount(i);
|
||||
int r;
|
||||
for (r = 0; r < count; r++) refreshFolderChild(index(r, 0, i));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
QModelIndex ProjectDirModel::getIndexByNode(DvDirModelNode *node) const {
|
||||
if (!node) return QModelIndex();
|
||||
return createIndex(node->getRow(), 0, node);
|
||||
TFilePath getDocumentsPath() {
|
||||
QString documentsPath =
|
||||
QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation)[0];
|
||||
return TFilePath(documentsPath);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
@ -271,35 +48,31 @@ ProjectPopup::ProjectPopup(bool isModal)
|
|||
: Dialog(TApp::instance()->getMainWindow(), isModal, false, "Project") {
|
||||
TProjectManager *pm = TProjectManager::instance();
|
||||
|
||||
m_choosePrjLabel = new QLabel(tr("Project:"), this);
|
||||
m_chooseProjectCombo = new QComboBox();
|
||||
m_prjNameLabel = new QLabel(tr("Project Name:"), this);
|
||||
m_nameFld = new LineEdit();
|
||||
m_model = new ProjectDirModel;
|
||||
m_treeView = new DvDirTreeView(this);
|
||||
m_choosePrjLabel = new QLabel(tr("Project:"), this);
|
||||
m_prjNameLabel = new QLabel(tr("Project Name:"), this);
|
||||
m_nameFld = new LineEdit();
|
||||
|
||||
m_projectLocationFld =
|
||||
new DVGui::FileField(this, getDocumentsPath().getQString());
|
||||
|
||||
m_nameFld->setMaximumHeight(WidgetHeight);
|
||||
m_treeView->setModel(m_model);
|
||||
m_treeView->setStyleSheet("border:1px solid rgb(120,120,120);");
|
||||
|
||||
//----layout
|
||||
m_topLayout->setMargin(5);
|
||||
m_topLayout->setSpacing(10);
|
||||
{
|
||||
m_topLayout->addWidget(m_treeView, 0);
|
||||
|
||||
QGridLayout *upperLayout = new QGridLayout();
|
||||
upperLayout->setMargin(5);
|
||||
upperLayout->setHorizontalSpacing(5);
|
||||
upperLayout->setVerticalSpacing(10);
|
||||
{
|
||||
upperLayout->addWidget(m_choosePrjLabel, 0, 0,
|
||||
upperLayout->addWidget(m_prjNameLabel, 0, 0,
|
||||
Qt::AlignRight | Qt::AlignVCenter);
|
||||
upperLayout->addWidget(m_chooseProjectCombo, 0, 1);
|
||||
upperLayout->addWidget(m_nameFld, 0, 1);
|
||||
|
||||
upperLayout->addWidget(m_prjNameLabel, 1, 0,
|
||||
upperLayout->addWidget(new QLabel(tr("Create Project In:"), this), 1, 0,
|
||||
Qt::AlignRight | Qt::AlignVCenter);
|
||||
upperLayout->addWidget(m_nameFld, 1, 1);
|
||||
upperLayout->addWidget(m_projectLocationFld, 1, 1);
|
||||
}
|
||||
upperLayout->setColumnStretch(0, 0);
|
||||
upperLayout->setColumnStretch(1, 1);
|
||||
|
@ -312,9 +85,10 @@ ProjectPopup::ProjectPopup(bool isModal)
|
|||
QString qName = QString::fromStdString(name);
|
||||
FileField *ff = new FileField(0, qName);
|
||||
m_folderFlds.append(qMakePair(name, ff));
|
||||
upperLayout->addWidget(new QLabel("+" + qName, this), i + 2, 0,
|
||||
Qt::AlignRight | Qt::AlignVCenter);
|
||||
upperLayout->addWidget(ff, i + 2, 1);
|
||||
// upperLayout->addWidget(new QLabel("+" + qName, this), i + 2, 0,
|
||||
// Qt::AlignRight | Qt::AlignVCenter);
|
||||
upperLayout->addWidget(ff, i + 3, 1);
|
||||
ff->hide();
|
||||
}
|
||||
std::vector<std::tuple<QString, std::string>> cbs = {
|
||||
std::make_tuple(tr("Append $scenepath to +drawings"),
|
||||
|
@ -330,6 +104,7 @@ ProjectPopup::ProjectPopup(bool isModal)
|
|||
cb->setMaximumHeight(WidgetHeight);
|
||||
upperLayout->addWidget(cb, currentRow + i, 1);
|
||||
m_useScenePathCbs.append(qMakePair(folderName, cb));
|
||||
cb->hide();
|
||||
}
|
||||
m_topLayout->addLayout(upperLayout);
|
||||
}
|
||||
|
@ -339,51 +114,6 @@ ProjectPopup::ProjectPopup(bool isModal)
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void ProjectPopup::updateChooseProjectCombo() {
|
||||
m_projectPaths.clear();
|
||||
m_chooseProjectCombo->clear();
|
||||
|
||||
TProjectManager *pm = TProjectManager::instance();
|
||||
|
||||
TFilePath sandboxFp = pm->getSandboxProjectFolder() + "sandbox_otprj.xml";
|
||||
m_projectPaths.push_back(sandboxFp);
|
||||
m_chooseProjectCombo->addItem("sandbox");
|
||||
|
||||
std::vector<TFilePath> prjRoots;
|
||||
pm->getProjectRoots(prjRoots);
|
||||
for (int i = 0; i < prjRoots.size(); i++) {
|
||||
TFilePathSet fps;
|
||||
TSystem::readDirectory_Dir_ReadExe(fps, prjRoots[i]);
|
||||
|
||||
TFilePathSet::iterator it;
|
||||
for (it = fps.begin(); it != fps.end(); ++it) {
|
||||
TFilePath fp(*it);
|
||||
if (pm->isProject(fp)) {
|
||||
m_projectPaths.push_back(pm->projectFolderToProjectPath(fp));
|
||||
TFilePath prjFile = pm->getProjectPathByProjectFolder(fp);
|
||||
m_chooseProjectCombo->addItem(
|
||||
QString::fromStdString(prjFile.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
// Add in project of current project if outside known Project root folders
|
||||
TProjectP currentProject = pm->getCurrentProject();
|
||||
TFilePath currentProjectFP = currentProject->getProjectPath();
|
||||
if (m_projectPaths.indexOf(currentProjectFP) == -1) {
|
||||
m_projectPaths.push_back(currentProjectFP);
|
||||
m_chooseProjectCombo->addItem(
|
||||
QString::fromStdString(currentProject->getName().getName()));
|
||||
}
|
||||
for (int i = 0; i < m_projectPaths.size(); i++) {
|
||||
if (pm->getCurrentProjectPath() == m_projectPaths[i]) {
|
||||
m_chooseProjectCombo->setCurrentIndex(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void ProjectPopup::updateFieldsFromProject(TProject *project) {
|
||||
m_nameFld->setText(toQString(project->getName()));
|
||||
int i;
|
||||
|
@ -431,13 +161,8 @@ void ProjectPopup::onProjectSwitched() {
|
|||
//-----------------------------------------------------------------------------
|
||||
|
||||
void ProjectPopup::showEvent(QShowEvent *) {
|
||||
// Must refresh the tree.
|
||||
DvDirModelNode *rootNode = m_model->getNode(QModelIndex());
|
||||
QModelIndex index = m_model->getIndexByNode(rootNode);
|
||||
m_model->refreshFolderChild(index);
|
||||
TProjectP currentProject = TProjectManager::instance()->getCurrentProject();
|
||||
updateFieldsFromProject(currentProject.getPointer());
|
||||
updateChooseProjectCombo();
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
@ -455,9 +180,7 @@ ProjectSettingsPopup::ProjectSettingsPopup() : ProjectPopup(false) {
|
|||
m_prjNameLabel->hide();
|
||||
m_nameFld->hide();
|
||||
m_choosePrjLabel->show();
|
||||
m_chooseProjectCombo->show();
|
||||
|
||||
m_treeView->hide();
|
||||
int i;
|
||||
for (i = 0; i < m_folderFlds.size(); i++) {
|
||||
FileField *ff = m_folderFlds[i].second;
|
||||
|
@ -468,31 +191,6 @@ ProjectSettingsPopup::ProjectSettingsPopup() : ProjectPopup(false) {
|
|||
connect(cb, SIGNAL(stateChanged(int)), this,
|
||||
SLOT(onUseSceneChekboxChanged(int)));
|
||||
}
|
||||
|
||||
connect(m_chooseProjectCombo, SIGNAL(activated(int)), this,
|
||||
SLOT(onChooseProjectChanged(int)));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void ProjectSettingsPopup::onChooseProjectChanged(int index) {
|
||||
TFilePath projectFp = m_projectPaths[index];
|
||||
|
||||
TProjectManager *pm = TProjectManager::instance();
|
||||
pm->setCurrentProjectPath(projectFp);
|
||||
|
||||
TProject *projectP =
|
||||
TProjectManager::instance()->getCurrentProject().getPointer();
|
||||
|
||||
// In case the project file was upgraded to current version, save it now
|
||||
if (projectP->getProjectPath() != projectFp) {
|
||||
m_projectPaths[index] = projectP->getProjectPath();
|
||||
projectP->save();
|
||||
}
|
||||
|
||||
updateFieldsFromProject(projectP);
|
||||
IoCmd::saveSceneIfNeeded("Change project");
|
||||
IoCmd::newScene();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -525,8 +223,8 @@ void ProjectSettingsPopup::onUseSceneChekboxChanged(int) {
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
OpenPopupCommandHandler<ProjectSettingsPopup> openProjectSettingsPopup(
|
||||
MI_ProjectSettings);
|
||||
// OpenPopupCommandHandler<ProjectSettingsPopup> openProjectSettingsPopup(
|
||||
// MI_ProjectSettings);
|
||||
|
||||
//=============================================================================
|
||||
/*! \class ProjectCreatePopup
|
||||
|
@ -557,7 +255,6 @@ ProjectCreatePopup::ProjectCreatePopup() : ProjectPopup(true) {
|
|||
m_prjNameLabel->show();
|
||||
m_nameFld->show();
|
||||
m_choosePrjLabel->hide();
|
||||
m_chooseProjectCombo->hide();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -590,23 +287,25 @@ void ProjectCreatePopup::createProject() {
|
|||
return;
|
||||
}
|
||||
|
||||
if (pm->getProjectPathByName(projectName) != TFilePath()) {
|
||||
// if (pm->getProjectPathByName(projectName) != TFilePath()) {
|
||||
// error(tr("Project '%1' already exists").arg(m_nameFld->text()));
|
||||
// // project already exists
|
||||
// return;
|
||||
//}
|
||||
|
||||
TFilePath newLocation = TFilePath(m_projectLocationFld->getPath());
|
||||
std::string newLocStr = newLocation.getQString().toStdString();
|
||||
TFilePath projectFolder = newLocation + projectName;
|
||||
TFilePath projectPath = pm->projectFolderToProjectPath(projectFolder);
|
||||
std::string projectPathStr = projectPath.getQString().toStdString();
|
||||
|
||||
if (TSystem::doesExistFileOrLevel(projectPath)) {
|
||||
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();
|
||||
TProject *project = new TProject();
|
||||
updateProjectFromFields(project);
|
||||
TProjectP currentProject = pm->getCurrentProject();
|
||||
project->setSceneProperties(currentProject->getSceneProperties());
|
||||
|
@ -642,15 +341,20 @@ void ProjectCreatePopup::showEvent(QShowEvent *) {
|
|||
}
|
||||
|
||||
m_nameFld->setText("");
|
||||
// Must refresh the tree.
|
||||
DvDirModelNode *rootNode = m_model->getNode(QModelIndex());
|
||||
QModelIndex index = m_model->getIndexByNode(rootNode);
|
||||
m_model->refreshFolderChild(index);
|
||||
// Select the first Item in the treeView
|
||||
QItemSelectionModel *selection = new QItemSelectionModel(m_model);
|
||||
index = m_model->index(0, 0, QModelIndex());
|
||||
selection->select(index, QItemSelectionModel::Select);
|
||||
m_treeView->setSelectionModel(selection);
|
||||
|
||||
resize(600, 150);
|
||||
QSizePolicy sizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
|
||||
sizePolicy.setHorizontalStretch(0);
|
||||
sizePolicy.setVerticalStretch(0);
|
||||
setSizePolicy(sizePolicy);
|
||||
setMinimumSize(QSize(600, 150));
|
||||
setMaximumSize(QSize(600, 150));
|
||||
setFixedSize(width(), height());
|
||||
setSizeGripEnabled(false);
|
||||
}
|
||||
|
||||
void ProjectCreatePopup::setPath(QString path) {
|
||||
m_projectLocationFld->setPath(path);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
|
@ -107,16 +107,14 @@ class ProjectPopup : public DVGui::Dialog, public TProjectManager::Listener {
|
|||
Q_OBJECT
|
||||
|
||||
protected:
|
||||
ProjectDirModel *m_model;
|
||||
DvDirTreeView *m_treeView;
|
||||
DVGui::LineEdit *m_nameFld;
|
||||
QList<QPair<std::string, DVGui::FileField *>> m_folderFlds;
|
||||
QList<QPair<std::string, DVGui::CheckBox *>> m_useScenePathCbs;
|
||||
|
||||
QLabel *m_prjNameLabel;
|
||||
QLabel *m_choosePrjLabel;
|
||||
QComboBox *m_chooseProjectCombo;
|
||||
QList<TFilePath> m_projectPaths;
|
||||
|
||||
DVGui::FileField *m_projectLocationFld;
|
||||
|
||||
public:
|
||||
ProjectPopup(bool isModal);
|
||||
|
@ -128,8 +126,6 @@ public:
|
|||
void updateProjectFromFields(TProject *);
|
||||
void updateFieldsFromProject(TProject *);
|
||||
|
||||
void updateChooseProjectCombo();
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent *) override;
|
||||
};
|
||||
|
@ -147,8 +143,6 @@ public:
|
|||
public slots:
|
||||
void onFolderChanged();
|
||||
void onUseSceneChekboxChanged(int);
|
||||
|
||||
void onChooseProjectChanged(int);
|
||||
};
|
||||
|
||||
//=============================================================================
|
||||
|
@ -160,6 +154,7 @@ class ProjectCreatePopup final : public ProjectPopup {
|
|||
|
||||
public:
|
||||
ProjectCreatePopup();
|
||||
void setPath(QString path);
|
||||
|
||||
public slots:
|
||||
void createProject();
|
||||
|
|
|
@ -11,11 +11,13 @@
|
|||
#include "menubarcommandids.h"
|
||||
#include "tenv.h"
|
||||
#include "toonz/stage.h"
|
||||
#include "projectpopup.h"
|
||||
|
||||
// TnzQt includes
|
||||
#include "toonzqt/menubarcommand.h"
|
||||
#include "toonzqt/gutil.h"
|
||||
#include "toonzqt/doublefield.h"
|
||||
#include "toonzqt/lineedit.h"
|
||||
|
||||
// TnzLib includes
|
||||
#include "toonz/toonzscene.h"
|
||||
|
@ -99,8 +101,14 @@ StartupPopup::StartupPopup()
|
|||
m_sceneBox = new QGroupBox(tr("Create a New Scene"), this);
|
||||
m_recentBox = new QGroupBox(tr("Recent Scenes [Project]"), this);
|
||||
m_projectBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
m_nameFld = new LineEdit(this);
|
||||
m_pathFld = new FileField(this);
|
||||
m_nameFld = new LineEdit(this);
|
||||
m_pathFld = new FileField(this);
|
||||
m_projectLocationFld = new FileField(this);
|
||||
QString currProjectPath = TProjectManager::instance()
|
||||
->getCurrentProjectPath()
|
||||
.getParentDir()
|
||||
.getQString();
|
||||
m_projectLocationFld->setPath(currProjectPath);
|
||||
m_sceneNameLabel = new QLabel(tr("Scene Name:"));
|
||||
m_widthLabel = new QLabel(tr("Width:"), this);
|
||||
m_widthFld = new MeasuredDoubleLineEdit(this);
|
||||
|
@ -126,7 +134,6 @@ StartupPopup::StartupPopup()
|
|||
QPushButton *newProjectButton = new QPushButton(tr("New Project..."), this);
|
||||
QPushButton *loadOtherSceneButton =
|
||||
new QPushButton(tr("Open Another Scene..."), this);
|
||||
m_projectsCB = new QComboBox(this);
|
||||
// QStringList type;
|
||||
// type << tr("pixel") << tr("cm") << tr("mm") << tr("inch") << tr("field");
|
||||
// m_unitsCB->addItems(type);
|
||||
|
@ -138,10 +145,13 @@ StartupPopup::StartupPopup()
|
|||
|
||||
m_widthFld->setMeasure("camera.lx");
|
||||
m_heightFld->setMeasure("camera.ly");
|
||||
m_widthFld->setFixedWidth(60);
|
||||
m_heightFld->setFixedWidth(60);
|
||||
|
||||
m_widthFld->setRange(0.1, (std::numeric_limits<double>::max)());
|
||||
m_heightFld->setRange(0.1, (std::numeric_limits<double>::max)());
|
||||
m_fpsFld->setRange(1.0, (std::numeric_limits<double>::max)());
|
||||
m_fpsFld->setFixedWidth(30);
|
||||
// m_dpiFld->setRange(1.0, (std::numeric_limits<double>::max)());
|
||||
m_resXFld->setRange(0.1, (std::numeric_limits<double>::max)());
|
||||
m_resYFld->setRange(0.1, (std::numeric_limits<double>::max)());
|
||||
|
@ -165,8 +175,8 @@ StartupPopup::StartupPopup()
|
|||
m_sceneBox->setContentsMargins(10, 10, 10, 10);
|
||||
m_recentBox->setContentsMargins(10, 10, 10, 10);
|
||||
m_recentBox->setFixedWidth(200);
|
||||
m_sceneBox->setMinimumWidth(480);
|
||||
m_projectBox->setMinimumWidth(480);
|
||||
m_sceneBox->setFixedWidth(480);
|
||||
m_projectBox->setFixedWidth(480);
|
||||
m_buttonFrame->setFixedHeight(34);
|
||||
|
||||
//--- layout
|
||||
|
@ -186,7 +196,7 @@ StartupPopup::StartupPopup()
|
|||
projectLay->setSpacing(8);
|
||||
projectLay->setMargin(8);
|
||||
{
|
||||
projectLay->addWidget(m_projectsCB, 1);
|
||||
projectLay->addWidget(m_projectLocationFld, 1);
|
||||
projectLay->addWidget(newProjectButton, 0);
|
||||
}
|
||||
m_projectBox->setLayout(projectLay);
|
||||
|
@ -199,13 +209,14 @@ StartupPopup::StartupPopup()
|
|||
// Scene Name
|
||||
newSceneLay->addWidget(m_sceneNameLabel, 0, 0,
|
||||
Qt::AlignRight | Qt::AlignVCenter);
|
||||
newSceneLay->addWidget(m_nameFld, 0, 1, 1, 3);
|
||||
newSceneLay->addWidget(m_nameFld, 0, 1, 1, 5);
|
||||
|
||||
// Save In
|
||||
newSceneLay->addWidget(new QLabel(tr("Save In:")), 1, 0,
|
||||
Qt::AlignRight | Qt::AlignVCenter);
|
||||
newSceneLay->addWidget(m_pathFld, 1, 1, 1, 3);
|
||||
newSceneLay->addWidget(new QLabel(tr("Camera Size:")), 2, 0,
|
||||
// newSceneLay->addWidget(new QLabel(tr("Save In:")), 1, 0,
|
||||
// Qt::AlignRight | Qt::AlignVCenter);
|
||||
newSceneLay->addWidget(m_pathFld, 1, 1, 1, 5);
|
||||
m_pathFld->hide();
|
||||
newSceneLay->addWidget(new QLabel(tr("Preset:")), 2, 0,
|
||||
Qt::AlignRight | Qt::AlignVCenter);
|
||||
QHBoxLayout *resListLay = new QHBoxLayout();
|
||||
resListLay->setSpacing(3);
|
||||
|
@ -215,7 +226,7 @@ StartupPopup::StartupPopup()
|
|||
resListLay->addWidget(m_addPresetBtn, 0);
|
||||
resListLay->addWidget(m_removePresetBtn, 0);
|
||||
}
|
||||
newSceneLay->addLayout(resListLay, 2, 1, 1, 3, Qt::AlignLeft);
|
||||
newSceneLay->addLayout(resListLay, 2, 1, 1, 5, Qt::AlignLeft);
|
||||
|
||||
// Width - Height
|
||||
newSceneLay->addWidget(m_widthLabel, 3, 0,
|
||||
|
@ -224,21 +235,22 @@ StartupPopup::StartupPopup()
|
|||
newSceneLay->addWidget(m_heightLabel, 3, 2,
|
||||
Qt::AlignRight | Qt::AlignVCenter);
|
||||
newSceneLay->addWidget(m_heightFld, 3, 3);
|
||||
newSceneLay->addWidget(m_fpsLabel, 3, 4,
|
||||
Qt::AlignRight | Qt::AlignVCenter);
|
||||
QHBoxLayout *fpsLay = new QHBoxLayout();
|
||||
fpsLay->addWidget(m_fpsFld);
|
||||
fpsLay->addWidget(new QLabel(tr("fps"), this));
|
||||
newSceneLay->addLayout(fpsLay, 3, 5);
|
||||
|
||||
newSceneLay->addWidget(m_resTextLabel, 4, 0, 1, 1, Qt::AlignRight);
|
||||
newSceneLay->addWidget(m_resXFld, 4, 1);
|
||||
newSceneLay->addWidget(m_resXLabel, 4, 2, 1, 1, Qt::AlignCenter);
|
||||
newSceneLay->addWidget(m_resYFld, 4, 3);
|
||||
// newSceneLay->addWidget(new QLabel(tr("Units:")), 5, 0,
|
||||
// newSceneLay->addWidget(m_fpsLabel, 5, 0,
|
||||
// Qt::AlignRight | Qt::AlignVCenter);
|
||||
// newSceneLay->addWidget(m_unitsCB, 5, 1, 1, 1);
|
||||
// newSceneLay->addWidget(m_dpiLabel, 5, 2,
|
||||
// Qt::AlignRight | Qt::AlignVCenter);
|
||||
// newSceneLay->addWidget(m_dpiFld, 5, 3, 1, 1);
|
||||
newSceneLay->addWidget(m_fpsLabel, 5, 0,
|
||||
Qt::AlignRight | Qt::AlignVCenter);
|
||||
newSceneLay->addWidget(m_fpsFld, 5, 1, 1, 1);
|
||||
// newSceneLay->addWidget(m_fpsFld, 5, 1, 1, 1);
|
||||
newSceneLay->addWidget(createButton, 6, 1, 1, 3, Qt::AlignLeft);
|
||||
newSceneLay->setColumnStretch(4, 1);
|
||||
}
|
||||
m_sceneBox->setLayout(newSceneLay);
|
||||
guiLay->addWidget(m_sceneBox, 2, 0, 4, 1, Qt::AlignTop);
|
||||
|
@ -278,10 +290,10 @@ StartupPopup::StartupPopup()
|
|||
SLOT(onSceneChanged()));
|
||||
ret = ret && connect(newProjectButton, SIGNAL(clicked()), this,
|
||||
SLOT(onNewProjectButtonPressed()));
|
||||
ret = ret && connect(m_projectLocationFld, SIGNAL(pathChanged()), this,
|
||||
SLOT(onProjectLocationChanged()));
|
||||
ret = ret && connect(loadOtherSceneButton, SIGNAL(clicked()), this,
|
||||
SLOT(onLoadSceneButtonPressed()));
|
||||
ret = ret && connect(m_projectsCB, SIGNAL(currentIndexChanged(int)),
|
||||
SLOT(onProjectChanged(int)));
|
||||
ret = ret &&
|
||||
connect(createButton, SIGNAL(clicked()), this, SLOT(onCreateButton()));
|
||||
ret = ret && connect(m_showAtStartCB, SIGNAL(stateChanged(int)), this,
|
||||
|
@ -294,13 +306,9 @@ StartupPopup::StartupPopup()
|
|||
connect(m_resXFld, SIGNAL(valueChanged()), this, SLOT(updateSize()));
|
||||
ret = ret &&
|
||||
connect(m_resYFld, SIGNAL(valueChanged()), this, SLOT(updateSize()));
|
||||
// ret = ret && connect(m_dpiFld, SIGNAL(editingFinished()), this,
|
||||
// SLOT(onDpiChanged()));
|
||||
ret = ret && connect(m_presetCombo, SIGNAL(activated(const QString &)),
|
||||
SLOT(onPresetSelected(const QString &)));
|
||||
ret = ret && connect(m_addPresetBtn, SIGNAL(clicked()), SLOT(addPreset()));
|
||||
// ret = ret && connect(m_unitsCB, SIGNAL(currentIndexChanged(int)),
|
||||
// SLOT(onCameraUnitChanged(int)));
|
||||
ret = ret &&
|
||||
connect(m_removePresetBtn, SIGNAL(clicked()), SLOT(removePreset()));
|
||||
ret = ret && connect(m_nameFld, SIGNAL(returnPressedNow()), createButton,
|
||||
|
@ -309,14 +317,16 @@ StartupPopup::StartupPopup()
|
|||
SLOT(onAutoSaveOnChanged(int)));
|
||||
ret = ret && connect(m_autoSaveTimeFld, SIGNAL(editingFinished()), this,
|
||||
SLOT(onAutoSaveTimeChanged()));
|
||||
ret = ret && connect(m_projectLocationFld, SIGNAL(pathChanged()), this,
|
||||
SLOT(checkProject()));
|
||||
assert(ret);
|
||||
checkProject();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void StartupPopup::showEvent(QShowEvent *) {
|
||||
loadPresetList();
|
||||
updateProjectCB();
|
||||
m_nameFld->setFocus();
|
||||
m_pathFld->setPath(TApp::instance()
|
||||
->getCurrentScene()
|
||||
|
@ -349,8 +359,6 @@ void StartupPopup::showEvent(QShowEvent *) {
|
|||
m_resXFld->hide();
|
||||
m_resYFld->hide();
|
||||
m_resXLabel->hide();
|
||||
// m_dpiFld->hide();
|
||||
// m_dpiLabel->hide();
|
||||
} else {
|
||||
m_widthFld->setDecimals(4);
|
||||
m_heightFld->setDecimals(4);
|
||||
|
@ -358,8 +366,6 @@ void StartupPopup::showEvent(QShowEvent *) {
|
|||
m_resYFld->show();
|
||||
m_resXLabel->show();
|
||||
m_resTextLabel->show();
|
||||
// m_dpiFld->show();
|
||||
// m_dpiLabel->show();
|
||||
}
|
||||
|
||||
m_fpsFld->setValue(fps);
|
||||
|
@ -435,6 +441,27 @@ void StartupPopup::refreshRecentScenes() {
|
|||
//-----------------------------------------------------------------------------
|
||||
|
||||
void StartupPopup::onCreateButton() {
|
||||
TProjectManager *pm = TProjectManager::instance();
|
||||
|
||||
TFilePath projectFolder = TFilePath(m_projectLocationFld->getPath());
|
||||
TFilePath projectPath = pm->projectFolderToProjectPath(projectFolder);
|
||||
if (!checkProject()) {
|
||||
DVGui::warning(
|
||||
tr("The project needs to be a valid project.\n"
|
||||
"Please select a valid project or create a new project."));
|
||||
m_projectLocationFld->setFocus();
|
||||
return;
|
||||
}
|
||||
|
||||
assert(TFileStatus(projectPath).doesExist());
|
||||
pm->setCurrentProjectPath(projectPath);
|
||||
IoCmd::newScene();
|
||||
m_pathFld->setPath(TApp::instance()
|
||||
->getCurrentScene()
|
||||
->getScene()
|
||||
->getProject()
|
||||
->getScenesPath()
|
||||
.getQString());
|
||||
if (m_nameFld->text().trimmed() == "") {
|
||||
DVGui::warning(tr("The name cannot be empty."));
|
||||
m_nameFld->setFocus();
|
||||
|
@ -515,55 +542,40 @@ void StartupPopup::onCreateButton() {
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void StartupPopup::updateProjectCB() {
|
||||
m_updating = true;
|
||||
m_projectPaths.clear();
|
||||
m_projectsCB->clear();
|
||||
|
||||
void StartupPopup::onProjectLocationChanged() {
|
||||
TProjectManager *pm = TProjectManager::instance();
|
||||
|
||||
TFilePath sandboxFp = pm->getSandboxProjectFolder() + "sandbox_otprj.xml";
|
||||
m_projectPaths.push_back(sandboxFp);
|
||||
m_projectsCB->addItem("sandbox");
|
||||
|
||||
std::vector<TFilePath> prjRoots;
|
||||
pm->getProjectRoots(prjRoots);
|
||||
for (int i = 0; i < prjRoots.size(); i++) {
|
||||
TFilePathSet fps;
|
||||
TSystem::readDirectory_Dir_ReadExe(fps, prjRoots[i]);
|
||||
|
||||
TFilePathSet::iterator it;
|
||||
for (it = fps.begin(); it != fps.end(); ++it) {
|
||||
TFilePath fp(*it);
|
||||
if (pm->isProject(fp)) {
|
||||
m_projectPaths.push_back(pm->projectFolderToProjectPath(fp));
|
||||
TFilePath prjFile = pm->getProjectPathByProjectFolder(fp);
|
||||
m_projectsCB->addItem(QString::fromStdString(prjFile.getName()));
|
||||
}
|
||||
TFilePath path = TFilePath(m_projectLocationFld->getPath());
|
||||
if (!TSystem::doesExistFileOrLevel(path)) {
|
||||
path =
|
||||
TApp::instance()->getCurrentScene()->getScene()->decodeFilePath(path);
|
||||
m_projectLocationFld->setPath(path.getQString());
|
||||
if (!TSystem::doesExistFileOrLevel(path)) {
|
||||
DVGui::warning(tr(
|
||||
"This is not a valid folder. Please choose an existing location."));
|
||||
checkProject();
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Add in project of current project if outside known Project root folders
|
||||
TProjectP currentProject = pm->getCurrentProject();
|
||||
TFilePath currentProjectFP = currentProject->getProjectPath();
|
||||
if (m_projectPaths.indexOf(currentProjectFP) == -1) {
|
||||
m_projectPaths.push_back(currentProjectFP);
|
||||
m_projectsCB->addItem(
|
||||
QString::fromStdString(currentProject->getName().getName()));
|
||||
}
|
||||
int i;
|
||||
for (i = 0; i < m_projectPaths.size(); i++) {
|
||||
if (pm->getCurrentProjectPath() == m_projectPaths[i]) {
|
||||
m_projectsCB->setCurrentIndex(i);
|
||||
break;
|
||||
if (!pm->isProject(path)) {
|
||||
QStringList buttonList;
|
||||
buttonList.append(tr("Yes"));
|
||||
buttonList.append(tr("No"));
|
||||
int answer = DVGui::MsgBox(tr("No project found at this location \n"
|
||||
"What would you like to do?"),
|
||||
tr("Make a new project"), tr("Cancel"), 1, this);
|
||||
if (answer != 1) {
|
||||
m_projectLocationFld->setPath(TApp::instance()
|
||||
->getCurrentScene()
|
||||
->getScene()
|
||||
->getProject()
|
||||
->getProjectFolder()
|
||||
.getQString());
|
||||
} else {
|
||||
ProjectCreatePopup *popup = new ProjectCreatePopup();
|
||||
popup->setPath(path.getQString());
|
||||
popup->exec();
|
||||
}
|
||||
}
|
||||
m_pathFld->setPath(TApp::instance()
|
||||
->getCurrentScene()
|
||||
->getScene()
|
||||
->getProject()
|
||||
->getScenesPath()
|
||||
.getQString());
|
||||
m_updating = false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -613,7 +625,6 @@ void StartupPopup::onProjectChanged(int index) {
|
|||
m_widthFld->setValue(size.lx);
|
||||
m_heightFld->setValue(size.ly);
|
||||
m_dpi = m_xRes / size.lx;
|
||||
// m_dpiFld->setValue(m_dpi);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -726,7 +737,6 @@ void StartupPopup::onPresetSelected(const QString &str) {
|
|||
if (Preferences::instance()->getPixelsOnly()) {
|
||||
m_widthFld->setValue((double)xres / Stage::standardDpi);
|
||||
m_heightFld->setValue((double)yres / Stage::standardDpi);
|
||||
// m_dpiFld->setValue(Stage::standardDpi);
|
||||
}
|
||||
m_resXFld->setValue(m_xRes);
|
||||
m_resYFld->setValue(m_yRes);
|
||||
|
@ -850,7 +860,7 @@ void StartupPopup::onSceneChanged() {
|
|||
if (!TApp::instance()->getCurrentScene()->getScene()->isUntitled()) {
|
||||
hide();
|
||||
} else {
|
||||
updateProjectCB();
|
||||
// updateProjectCB();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -859,7 +869,6 @@ void StartupPopup::onSceneChanged() {
|
|||
void StartupPopup::onDpiChanged() {
|
||||
if (Preferences::instance()->getPixelsOnly()) {
|
||||
m_dpi = Stage::standardDpi;
|
||||
// m_dpiFld->setValue(Stage::standardDpi);
|
||||
updateResolution();
|
||||
}
|
||||
}
|
||||
|
@ -887,14 +896,14 @@ void StartupPopup::onRecentSceneClicked(int index) {
|
|||
DVGui::warning(msg);
|
||||
refreshRecentScenes();
|
||||
} else {
|
||||
if (RecentFiles::instance()->getFileProject(index) != "-") {
|
||||
QString projectName = RecentFiles::instance()->getFileProject(index);
|
||||
int projectIndex = m_projectsCB->findText(projectName);
|
||||
if (projectIndex >= 0) {
|
||||
TFilePath projectFp = m_projectPaths[projectIndex];
|
||||
TProjectManager::instance()->setCurrentProjectPath(projectFp);
|
||||
}
|
||||
}
|
||||
// if (RecentFiles::instance()->getFileProject(index) != "-") {
|
||||
// QString projectName = RecentFiles::instance()->getFileProject(index);
|
||||
// int projectIndex = m_projectsCB->findText(projectName);
|
||||
// if (projectIndex >= 0) {
|
||||
// TFilePath projectFp = m_projectPaths[projectIndex];
|
||||
// TProjectManager::instance()->setCurrentProjectPath(projectFp);
|
||||
// }
|
||||
//}
|
||||
IoCmd::loadScene(TFilePath(path.toStdWString()), false, true);
|
||||
QString origProjectName = RecentFiles::instance()->getFileProject(index);
|
||||
QString projectName = QString::fromStdString(TApp::instance()
|
||||
|
@ -939,8 +948,6 @@ void StartupPopup::onCameraUnitChanged(int index) {
|
|||
m_resXFld->show();
|
||||
m_resYFld->show();
|
||||
m_resXLabel->show();
|
||||
// m_dpiFld->show();
|
||||
// m_dpiLabel->show();
|
||||
m_widthFld->setMeasure("camera.lx");
|
||||
m_heightFld->setMeasure("camera.ly");
|
||||
m_widthFld->setValue(width);
|
||||
|
@ -955,9 +962,6 @@ void StartupPopup::onCameraUnitChanged(int index) {
|
|||
m_resXFld->hide();
|
||||
m_resYFld->hide();
|
||||
m_resXLabel->hide();
|
||||
// m_dpiFld->hide();
|
||||
// m_dpiLabel->hide();
|
||||
// m_dpiFld->setValue(Stage::standardDpi);
|
||||
m_widthFld->setMeasure("camera.lx");
|
||||
m_heightFld->setMeasure("camera.ly");
|
||||
m_widthFld->setValue(m_xRes / Stage::standardDpi);
|
||||
|
@ -989,9 +993,6 @@ void StartupPopup::onAutoSaveTimeChanged() {
|
|||
|
||||
void StartupPopup::updateResolution() {
|
||||
if (Preferences::instance()->getPixelsOnly()) {
|
||||
// if (m_dpiFld->getValue() != Stage::standardDpi) {
|
||||
// m_dpiFld->setValue(Stage::standardDpi);
|
||||
//}
|
||||
m_xRes = m_widthFld->getValue() * Stage::standardDpi;
|
||||
m_yRes = m_heightFld->getValue() * Stage::standardDpi;
|
||||
m_resXFld->setValue(m_xRes);
|
||||
|
@ -1011,9 +1012,6 @@ void StartupPopup::updateSize() {
|
|||
m_xRes = m_resXFld->getValue();
|
||||
m_yRes = m_resYFld->getValue();
|
||||
if (Preferences::instance()->getPixelsOnly()) {
|
||||
// if (m_dpiFld->getValue() != Stage::standardDpi) {
|
||||
// m_dpiFld->setValue(Stage::standardDpi);
|
||||
//}
|
||||
m_widthFld->setValue((double)m_xRes / Stage::standardDpi);
|
||||
m_heightFld->setValue((double)m_yRes / Stage::standardDpi);
|
||||
} else {
|
||||
|
@ -1025,6 +1023,22 @@ void StartupPopup::updateSize() {
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool StartupPopup::checkProject() {
|
||||
TFilePath currPath = TFilePath(m_projectLocationFld->getPath());
|
||||
bool isProject = TProjectManager::instance()->isProject(currPath);
|
||||
if (isProject) {
|
||||
m_projectLocationFld->getField()->setStyleSheet(
|
||||
m_pathFld->getField()->styleSheet());
|
||||
m_projectLocationFld->setToolTip(tr(""));
|
||||
} else {
|
||||
m_projectLocationFld->getField()->setStyleSheet("color: red;");
|
||||
m_projectLocationFld->setToolTip(tr("Not a valid project location"));
|
||||
}
|
||||
return isProject;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
StartupLabel::StartupLabel(const QString &text, QWidget *parent, int index)
|
||||
: QLabel(parent), m_index(index) {
|
||||
setText(text);
|
||||
|
|
|
@ -27,14 +27,15 @@ class StartupPopup final : public DVGui::Dialog {
|
|||
|
||||
DVGui::LineEdit *m_nameFld;
|
||||
DVGui::FileField *m_pathFld;
|
||||
DVGui::FileField *m_projectLocationFld;
|
||||
QLabel *m_widthLabel;
|
||||
QLabel *m_heightLabel;
|
||||
QLabel *m_fpsLabel;
|
||||
QLabel *m_resXLabel;
|
||||
QLabel *m_resTextLabel;
|
||||
//QLabel *m_dpiLabel;
|
||||
// QLabel *m_dpiLabel;
|
||||
QLabel *m_sceneNameLabel;
|
||||
//DVGui::DoubleLineEdit *m_dpiFld;
|
||||
// DVGui::DoubleLineEdit *m_dpiFld;
|
||||
DVGui::MeasuredDoubleLineEdit *m_widthFld;
|
||||
DVGui::MeasuredDoubleLineEdit *m_heightFld;
|
||||
DVGui::DoubleLineEdit *m_fpsFld;
|
||||
|
@ -45,8 +46,7 @@ class StartupPopup final : public DVGui::Dialog {
|
|||
QList<TFilePath> m_projectPaths;
|
||||
QCheckBox *m_showAtStartCB;
|
||||
QCheckBox *m_autoSaveOnCB;
|
||||
QComboBox *m_projectsCB;
|
||||
//QComboBox *m_unitsCB;
|
||||
// QComboBox *m_unitsCB;
|
||||
QPushButton *m_loadOtherSceneButton;
|
||||
QPushButton *m_newProjectButton;
|
||||
QComboBox *m_presetCombo;
|
||||
|
@ -81,7 +81,6 @@ public slots:
|
|||
void onRecentSceneClicked(int index);
|
||||
void onCreateButton();
|
||||
void onShowAtStartChanged(int index);
|
||||
void updateProjectCB();
|
||||
void onProjectChanged(int index);
|
||||
void onNewProjectButtonPressed();
|
||||
void onLoadSceneButtonPressed();
|
||||
|
@ -95,6 +94,8 @@ public slots:
|
|||
void onCameraUnitChanged(int index);
|
||||
void onAutoSaveOnChanged(int index);
|
||||
void onAutoSaveTimeChanged();
|
||||
bool checkProject();
|
||||
void onProjectLocationChanged();
|
||||
};
|
||||
|
||||
class StartupLabel : public QLabel {
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
// Qt includes
|
||||
#include <QFileInfo>
|
||||
#include <QDir>
|
||||
#include <QStandardPaths>
|
||||
|
||||
// STD includes
|
||||
#include <fstream>
|
||||
|
@ -123,9 +124,12 @@ std::wstring getProjectSuffix(const TFilePath &path) {
|
|||
TFilePath getProjectFile(const TFilePath &fp) {
|
||||
const std::wstring &fpName = fp.getWideName();
|
||||
const std::wstring &folderName = fp.getParentDir().getWideName();
|
||||
std::wstring tahoma = L"tahomaproject";
|
||||
QDir dir(fp.getQString());
|
||||
TFilePath path = fp + (tahoma + xmlExt);
|
||||
if (TFileStatus(path).doesExist()) return path;
|
||||
for (int i = 0; i < prjSuffixCount; ++i) {
|
||||
TFilePath path = fp + (fpName + prjSuffix[i] + xmlExt);
|
||||
path = fp + (fpName + prjSuffix[i] + xmlExt);
|
||||
if (TFileStatus(path).doesExist()) return path;
|
||||
|
||||
QStringList filters;
|
||||
|
@ -144,6 +148,7 @@ TFilePath getProjectFile(const TFilePath &fp) {
|
|||
//! this function updates it to the most recent; otherwise,
|
||||
//! it is left untouched.
|
||||
TFilePath getLatestVersionProjectPath(const TFilePath &path) {
|
||||
return path.withName(L"tahomaproject");
|
||||
const std::wstring &suffix = getProjectSuffix(path);
|
||||
for (int i = 1; i < prjSuffixCount; ++i)
|
||||
if (suffix == prjSuffix[i]) {
|
||||
|
@ -173,7 +178,7 @@ TFilePath searchProjectPath(TFilePath folder) {
|
|||
if (projectPath != TFilePath()) return projectPath;
|
||||
|
||||
// If none exist in the folder, build the name with the most recent suffix
|
||||
return folder + TFilePath(projectName + prjSuffix[0] + xmlExt);
|
||||
return folder + TFilePath(L"tahomaproject" + xmlExt);
|
||||
}
|
||||
|
||||
//===================================================================
|
||||
|
@ -197,13 +202,29 @@ void hideOlderProjectFiles(const TFilePath &folderPath) {
|
|||
const std::wstring &name = folderPath.getWideName();
|
||||
|
||||
TFilePath path;
|
||||
for (int i = 1; i < prjSuffixCount; ++i) {
|
||||
for (int i = 0; i < prjSuffixCount; ++i) {
|
||||
path = folderPath + (name + prjSuffix[i] + xmlExt);
|
||||
if (TFileStatus(path).doesExist())
|
||||
TSystem::renameFile(path.withType("xml_"), path);
|
||||
}
|
||||
}
|
||||
|
||||
//===================================================================
|
||||
|
||||
TFilePath getDocumentsPath() {
|
||||
QString documentsPath =
|
||||
QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation)[0];
|
||||
return TFilePath(documentsPath);
|
||||
}
|
||||
|
||||
//===================================================================
|
||||
|
||||
TFilePath getDesktopPath() {
|
||||
QString desktopPath =
|
||||
QStandardPaths::standardLocations(QStandardPaths::DesktopLocation)[0];
|
||||
return TFilePath(desktopPath);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
//===================================================================
|
||||
|
@ -691,6 +712,7 @@ void TProject::load(const TFilePath &projectPath) {
|
|||
bool TProject::isAProjectPath(const TFilePath &fp) {
|
||||
if (fp.isAbsolute() && fp.getType() == "xml") {
|
||||
const std::wstring &fpName = fp.getWideName();
|
||||
if (fpName == L"tahomaproject") return true;
|
||||
for (int i = 0; i < prjSuffixCount; ++i)
|
||||
if (fpName.find(prjSuffix[i]) != std::wstring::npos) return true;
|
||||
}
|
||||
|
@ -764,12 +786,12 @@ TProjectManager *TProjectManager::instance() {
|
|||
/*! Adds the specified folder \b fp in the projecs roots container.\n
|
||||
If \b fp is already contained in the container, the method does nothing.
|
||||
\note \b fp must be a folder and not a file path.*/
|
||||
void TProjectManager::addProjectsRoot(const TFilePath &root) {
|
||||
// assert(TFileStatus(root).isDirectory());
|
||||
if (std::find(m_projectsRoots.begin(), m_projectsRoots.end(), root) ==
|
||||
m_projectsRoots.end())
|
||||
m_projectsRoots.push_back(root);
|
||||
}
|
||||
// void TProjectManager::addProjectsRoot(const TFilePath &root) {
|
||||
// // assert(TFileStatus(root).isDirectory());
|
||||
// if (std::find(m_projectsRoots.begin(), m_projectsRoots.end(), root) ==
|
||||
// m_projectsRoots.end())
|
||||
// m_projectsRoots.push_back(root);
|
||||
//}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
|
@ -786,25 +808,25 @@ void TProjectManager::addSVNProjectsRoot(const TFilePath &root) {
|
|||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
void TProjectManager::addDefaultProjectsRoot() {
|
||||
addProjectsRoot(TEnv::getStuffDir() + "projects");
|
||||
}
|
||||
// void TProjectManager::addDefaultProjectsRoot() {
|
||||
// addProjectsRoot(TEnv::getStuffDir() + "projects");
|
||||
//}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
TFilePath TProjectManager::getCurrentProjectRoot() {
|
||||
TFilePath currentProjectPath = getCurrentProjectPath();
|
||||
int i;
|
||||
for (i = 0; i < (int)m_projectsRoots.size(); i++)
|
||||
if (m_projectsRoots[i].isAncestorOf(currentProjectPath))
|
||||
return m_projectsRoots[i];
|
||||
for (i = 0; i < (int)m_svnProjectsRoots.size(); i++)
|
||||
if (m_svnProjectsRoots[i].isAncestorOf(currentProjectPath))
|
||||
return m_svnProjectsRoots[i];
|
||||
if (m_projectsRoots.empty())
|
||||
addDefaultProjectsRoot(); // shouldn't be necessary
|
||||
return m_projectsRoots[0];
|
||||
}
|
||||
// TFilePath TProjectManager::getCurrentProjectRoot() {
|
||||
// TFilePath currentProjectPath = getCurrentProjectPath();
|
||||
// int i;
|
||||
// for (i = 0; i < (int)m_projectsRoots.size(); i++)
|
||||
// if (m_projectsRoots[i].isAncestorOf(currentProjectPath))
|
||||
// return m_projectsRoots[i];
|
||||
// for (i = 0; i < (int)m_svnProjectsRoots.size(); i++)
|
||||
// if (m_svnProjectsRoots[i].isAncestorOf(currentProjectPath))
|
||||
// return m_svnProjectsRoots[i];
|
||||
// if (m_projectsRoots.empty())
|
||||
// addDefaultProjectsRoot(); // shouldn't be necessary
|
||||
// return m_projectsRoots[0];
|
||||
//}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/*! Returns the name of the specified \b projectPath.
|
||||
|
@ -814,40 +836,28 @@ TFilePath TProjectManager::projectPathToProjectName(
|
|||
const TFilePath &projectPath) {
|
||||
assert(projectPath.isAbsolute());
|
||||
TFilePath projectFolder = projectPath.getParentDir();
|
||||
if (m_projectsRoots.empty()) addDefaultProjectsRoot();
|
||||
// if (m_projectsRoots.empty()) addDefaultProjectsRoot();
|
||||
|
||||
// keep allowing for older project types
|
||||
std::wstring fpName = projectPath.getWideName();
|
||||
for (int i = 0; i < prjSuffixCount; ++i) {
|
||||
// std::wstring::size_type const i = fpName.find(prjSuffix[i]);
|
||||
if (fpName.find(prjSuffix[i]) != std::wstring::npos)
|
||||
return TFilePath(fpName.substr(0, fpName.find(prjSuffix[i])));
|
||||
}
|
||||
|
||||
int i;
|
||||
for (i = 0; i < (int)m_projectsRoots.size(); i++) {
|
||||
if (m_projectsRoots[i].isAncestorOf(projectFolder))
|
||||
return projectFolder - m_projectsRoots[i];
|
||||
}
|
||||
for (i = 0; i < (int)m_svnProjectsRoots.size(); i++) {
|
||||
if (m_svnProjectsRoots[i].isAncestorOf(projectFolder))
|
||||
return projectFolder - m_svnProjectsRoots[i];
|
||||
}
|
||||
// non dovrei mai arrivare qui: il progetto non sta sotto un project root
|
||||
return projectFolder.withoutParentDir();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/*! Returns an absolute path of the specified \b projectName.\n
|
||||
\note The returned project path is always computed used the first
|
||||
project root in the container.*/
|
||||
// Returns an absolute path of the specified \b projectName.
|
||||
TFilePath TProjectManager::projectNameToProjectPath(
|
||||
const TFilePath &projectName) {
|
||||
assert(!TProject::isAProjectPath(projectName));
|
||||
assert(!projectName.isAbsolute());
|
||||
if (m_projectsRoots.empty()) addDefaultProjectsRoot();
|
||||
// if (m_projectsRoots.empty()) addDefaultProjectsRoot();
|
||||
if (projectName == TProject::SandboxProjectName)
|
||||
return searchProjectPath(TEnv::getStuffDir() + projectName);
|
||||
return searchProjectPath(m_projectsRoots[0] + projectName);
|
||||
return searchProjectPath(getDocumentsPath() + projectName);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
@ -871,16 +881,25 @@ TFilePath TProjectManager::getProjectPathByName(const TFilePath &projectName) {
|
|||
assert(!projectName.isAbsolute());
|
||||
// TFilePath relativeProjectPath = projectName + (projectName.getName() +
|
||||
// projectPathSuffix);
|
||||
if (m_projectsRoots.empty()) addDefaultProjectsRoot();
|
||||
// if (m_projectsRoots.empty()) addDefaultProjectsRoot();
|
||||
if (projectName == TProject::SandboxProjectName)
|
||||
return searchProjectPath(TEnv::getStuffDir() + projectName);
|
||||
int i, n = (int)m_projectsRoots.size();
|
||||
for (i = 0; i < n; i++) {
|
||||
TFilePath projectPath = searchProjectPath(m_projectsRoots[i] + projectName);
|
||||
assert(TProject::isAProjectPath(projectPath));
|
||||
if (TFileStatus(projectPath).doesExist()) return projectPath;
|
||||
}
|
||||
for (i = 0; i < (int)m_svnProjectsRoots.size(); i++) {
|
||||
|
||||
TFilePath projectPath = searchProjectPath(getDocumentsPath() + projectName);
|
||||
assert(TProject::isAProjectPath(projectPath));
|
||||
if (TFileStatus(projectPath).doesExist()) return projectPath;
|
||||
|
||||
projectPath = searchProjectPath(getDesktopPath() + projectName);
|
||||
assert(TProject::isAProjectPath(projectPath));
|
||||
if (TFileStatus(projectPath).doesExist()) return projectPath;
|
||||
|
||||
// search the projects folder
|
||||
TFilePath projects = TFilePath(TEnv::getStuffDir() + TFilePath("projects"));
|
||||
projectPath = searchProjectPath(projects + projectName);
|
||||
assert(TProject::isAProjectPath(projectPath));
|
||||
if (TFileStatus(projectPath).doesExist()) return projectPath;
|
||||
|
||||
for (int i = 0; i < (int)m_svnProjectsRoots.size(); i++) {
|
||||
TFilePath projectPath =
|
||||
searchProjectPath(m_svnProjectsRoots[i] + projectName);
|
||||
assert(TProject::isAProjectPath(projectPath));
|
||||
|
@ -1149,6 +1168,7 @@ TFilePath TProjectManager::getSandboxProjectPath() {
|
|||
}
|
||||
|
||||
bool TProjectManager::isProject(const TFilePath &projectFolder) {
|
||||
if (!projectFolder.isAbsolute()) return false;
|
||||
TFilePath projectPath = projectFolderToProjectPath(projectFolder);
|
||||
return TFileStatus(projectPath).doesExist();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue