|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/toonzfolders.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tsystem.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tenv.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tconvert.h"
|
|
turtletooth |
8d9ba3 |
#include "toonz/preferences.h"
|
|
Jeremy Bullock |
e59b1f |
#include <qstandardpaths></qstandardpaths>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
using namespace TEnv;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Jeremy Bullock |
e59b1f |
//-------------------------------------------------------------------
|
|
Jeremy Bullock |
e59b1f |
namespace {
|
|
Jeremy Bullock |
e59b1f |
TFilePath getMyDocumentsPath() {
|
|
Jeremy Bullock |
e59b1f |
QString documentsPath =
|
|
Jeremy Bullock |
e59b1f |
QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation)[0];
|
|
Jeremy Bullock |
e59b1f |
return TFilePath(documentsPath);
|
|
Jeremy Bullock |
e59b1f |
}
|
|
Jeremy Bullock |
e59b1f |
|
|
Jeremy Bullock |
e59b1f |
// Desktop Path
|
|
Jeremy Bullock |
e59b1f |
TFilePath getDesktopPath() {
|
|
Jeremy Bullock |
e59b1f |
QString desktopPath =
|
|
Jeremy Bullock |
e59b1f |
QStandardPaths::standardLocations(QStandardPaths::DesktopLocation)[0];
|
|
Jeremy Bullock |
e59b1f |
return TFilePath(desktopPath);
|
|
Jeremy Bullock |
e59b1f |
}
|
|
Jeremy Bullock |
e59b1f |
}
|
|
Jeremy Bullock |
e59b1f |
//-------------------------------------------------------------------
|
|
Jeremy Bullock |
e59b1f |
|
|
Shinya Kitaoka |
120a6e |
TFilePath ToonzFolder::getModulesDir() {
|
|
Shinya Kitaoka |
120a6e |
return getProfileFolder() + "layouts";
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TFilePathSet ToonzFolder::getProjectsFolders() {
|
|
Jeremy Bullock |
e59b1f |
int location = Preferences::instance()->getProjectRoot();
|
|
Jeremy Bullock |
e59b1f |
QString path = Preferences::instance()->getCustomProjectRoot();
|
|
Jeremy Bullock |
e59b1f |
TFilePathSet fps;
|
|
Jeremy Bullock |
e59b1f |
int projectPaths = Preferences::instance()->getProjectRoot();
|
|
Jeremy Bullock |
e59b1f |
bool stuff = projectPaths & 0x08;
|
|
Jeremy Bullock |
e59b1f |
bool documents = projectPaths & 0x04;
|
|
Jeremy Bullock |
e59b1f |
bool desktop = projectPaths & 0x02;
|
|
Jeremy Bullock |
e59b1f |
bool custom = projectPaths & 0x01;
|
|
Jeremy Bullock |
e59b1f |
|
|
Jeremy Bullock |
e59b1f |
// make sure at least something is there
|
|
Jeremy Bullock |
e59b1f |
if (!desktop && !custom && !documents) stuff = 1;
|
|
Jeremy Bullock |
e59b1f |
TFilePathSet tempFps =
|
|
Shinya Kitaoka |
120a6e |
getSystemVarPathSetValue(getSystemVarPrefix() + "PROJECTS");
|
|
Jeremy Bullock |
e59b1f |
if (stuff) {
|
|
Jeremy Bullock |
e59b1f |
for (TFilePath tempPath : tempFps) {
|
|
Jeremy Bullock |
e59b1f |
if (TSystem::doesExistFileOrLevel(TFilePath(tempPath))) {
|
|
Jeremy Bullock |
e59b1f |
fps.push_back(TFilePath(tempPath));
|
|
Jeremy Bullock |
e59b1f |
}
|
|
Jeremy Bullock |
e59b1f |
}
|
|
Jeremy Bullock |
e59b1f |
if (tempFps.size() == 0) fps.push_back(TEnv::getStuffDir() + "Projects");
|
|
Jeremy Bullock |
e59b1f |
}
|
|
Jeremy Bullock |
e59b1f |
if (documents) {
|
|
Jeremy Bullock |
e59b1f |
fps.push_back(getMyDocumentsPath() + "OpenToonz");
|
|
Jeremy Bullock |
e59b1f |
if (!TSystem::doesExistFileOrLevel(getMyDocumentsPath() + "OpenToonz")) {
|
|
Jeremy Bullock |
e59b1f |
TSystem::mkDir(getMyDocumentsPath() + "OpenToonz");
|
|
Jeremy Bullock |
e59b1f |
}
|
|
Jeremy Bullock |
e59b1f |
}
|
|
Jeremy Bullock |
e59b1f |
if (desktop) {
|
|
Jeremy Bullock |
e59b1f |
fps.push_back(getDesktopPath() + "OpenToonz");
|
|
Jeremy Bullock |
e59b1f |
if (!TSystem::doesExistFileOrLevel(getDesktopPath() + "OpenToonz")) {
|
|
Jeremy Bullock |
e59b1f |
TSystem::mkDir(getDesktopPath() + "OpenToonz");
|
|
Jeremy Bullock |
e59b1f |
}
|
|
Jeremy Bullock |
e59b1f |
}
|
|
Jeremy Bullock |
e59b1f |
if (custom) {
|
|
Jeremy Bullock |
e59b1f |
QStringList paths = path.split("**");
|
|
Jeremy Bullock |
e59b1f |
for (QString tempPath : paths) {
|
|
Jeremy Bullock |
e59b1f |
if (TSystem::doesExistFileOrLevel(TFilePath(tempPath))) {
|
|
Jeremy Bullock |
e59b1f |
fps.push_back(TFilePath(tempPath));
|
|
Jeremy Bullock |
e59b1f |
}
|
|
Jeremy Bullock |
e59b1f |
}
|
|
Jeremy Bullock |
e59b1f |
}
|
|
Shinya Kitaoka |
120a6e |
return fps;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TFilePath ToonzFolder::getFirstProjectsFolder() {
|
|
Shinya Kitaoka |
120a6e |
TFilePathSet fps = getProjectsFolders();
|
|
Shinya Kitaoka |
120a6e |
if (fps.empty())
|
|
Shinya Kitaoka |
120a6e |
return TFilePath();
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
return *fps.begin();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TFilePath ToonzFolder::getLibraryFolder() {
|
|
Shinya Kitaoka |
120a6e |
TFilePath fp = getSystemVarPathValue(getSystemVarPrefix() + "LIBRARY");
|
|
Shinya Kitaoka |
120a6e |
if (fp == TFilePath()) fp = getStuffDir() + "library";
|
|
Shinya Kitaoka |
120a6e |
return fp;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TFilePath ToonzFolder::getStudioPaletteFolder() {
|
|
Shinya Kitaoka |
120a6e |
TFilePath fp = getSystemVarPathValue(getSystemVarPrefix() + "STUDIOPALETTE");
|
|
Shinya Kitaoka |
120a6e |
if (fp == TFilePath()) fp = getStuffDir() + "studiopalette";
|
|
Shinya Kitaoka |
120a6e |
return fp;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TFilePath ToonzFolder::getFxPresetFolder() {
|
|
Shinya Kitaoka |
120a6e |
TFilePath fp = getSystemVarPathValue(getSystemVarPrefix() + "FXPRESETS");
|
|
Shinya Kitaoka |
120a6e |
if (fp == TFilePath()) fp = getStuffDir() + "fxs";
|
|
Shinya Kitaoka |
120a6e |
return fp;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TFilePath ToonzFolder::getCacheRootFolder() {
|
|
Shinya Kitaoka |
120a6e |
TFilePath fp = getSystemVarPathValue(getSystemVarPrefix() + "CACHEROOT");
|
|
Shinya Kitaoka |
120a6e |
if (fp == TFilePath()) fp = getStuffDir() + "cache";
|
|
Shinya Kitaoka |
120a6e |
return fp;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TFilePath ToonzFolder::getProfileFolder() {
|
|
Shinya Kitaoka |
120a6e |
TFilePath fp = getSystemVarPathValue(getSystemVarPrefix() + "PROFILES");
|
|
Shinya Kitaoka |
120a6e |
if (fp == TFilePath()) fp = getStuffDir() + "profiles";
|
|
Shinya Kitaoka |
120a6e |
return fp;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TFilePath ToonzFolder::getReslistPath(bool forCleanup) {
|
|
Jeremy Bullock |
1d47b8 |
return getConfigDir() + (forCleanup ? "cleanupreslist.txt" : "reslist.txt");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TFilePath ToonzFolder::getTemplateModuleDir() {
|
|
Shinya Kitaoka |
120a6e |
// return getModulesDir() + getModuleName();
|
|
Shinya Kitaoka |
120a6e |
return getModulesDir() + "settings";
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TFilePath ToonzFolder::getMyModuleDir() {
|
|
Shinya Kitaoka |
120a6e |
TFilePath fp(getTemplateModuleDir());
|
|
Shinya Kitaoka |
120a6e |
return fp.withName(fp.getWideName() + L"." +
|
|
Shinya Kitaoka |
120a6e |
TSystem::getUserName().toStdWString());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TFilePath ToonzFolder::getModuleFile(TFilePath filename) {
|
|
Shinya Kitaoka |
120a6e |
TFilePath fp = getMyModuleDir() + filename;
|
|
Shinya Kitaoka |
120a6e |
if (TFileStatus(fp).doesExist()) return fp;
|
|
Shinya Kitaoka |
120a6e |
fp = getTemplateModuleDir() + filename;
|
|
Shinya Kitaoka |
120a6e |
return fp;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TFilePath ToonzFolder::getModuleFile(std::string fn) {
|
|
Shinya Kitaoka |
120a6e |
return ToonzFolder::getModuleFile(TFilePath(fn));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// turtle
|
|
Shinya Kitaoka |
120a6e |
TFilePath ToonzFolder::getRoomsDir() {
|
|
Shinya Kitaoka |
120a6e |
return getProfileFolder() + "layouts/rooms";
|
|
turtletooth |
8d9ba3 |
}
|
|
turtletooth |
8d9ba3 |
|
|
Shinya Kitaoka |
120a6e |
TFilePath ToonzFolder::getTemplateRoomsDir() {
|
|
Shinya Kitaoka |
120a6e |
return getRoomsDir() +
|
|
Shinya Kitaoka |
120a6e |
Preferences::instance()->getCurrentRoomChoice().toStdWString();
|
|
Shinya Kitaoka |
120a6e |
// TFilePath fp(getMyModuleDir() + TFilePath(mySettingsFileName));
|
|
Shinya Kitaoka |
120a6e |
// return getRoomsDir() + getModuleName();
|
|
turtletooth |
8d9ba3 |
}
|
|
turtletooth |
8d9ba3 |
|
|
Shinya Kitaoka |
120a6e |
TFilePath ToonzFolder::getMyRoomsDir() {
|
|
Shinya Kitaoka |
120a6e |
// TFilePath fp(getTemplateRoomsDir());
|
|
Shinya Kitaoka |
120a6e |
TFilePath fp(getProfileFolder());
|
|
Shinya Kitaoka |
120a6e |
return fp.withName(
|
|
Shinya Kitaoka |
120a6e |
fp.getWideName() + L"/layouts/personal/" +
|
|
Shinya Kitaoka |
120a6e |
Preferences::instance()->getCurrentRoomChoice().toStdWString() + L"." +
|
|
Shinya Kitaoka |
120a6e |
TSystem::getUserName().toStdWString());
|
|
turtletooth |
8d9ba3 |
}
|
|
turtletooth |
8d9ba3 |
|
|
Shinya Kitaoka |
120a6e |
TFilePath ToonzFolder::getRoomsFile(TFilePath filename) {
|
|
Shinya Kitaoka |
120a6e |
TFilePath fp = getMyRoomsDir() + filename;
|
|
Shinya Kitaoka |
120a6e |
if (TFileStatus(fp).doesExist()) return fp;
|
|
Shinya Kitaoka |
120a6e |
fp = getTemplateRoomsDir() + filename;
|
|
Shinya Kitaoka |
120a6e |
return fp;
|
|
turtletooth |
8d9ba3 |
}
|
|
turtletooth |
8d9ba3 |
|
|
Shinya Kitaoka |
120a6e |
TFilePath ToonzFolder::getRoomsFile(std::string fn) {
|
|
Shinya Kitaoka |
120a6e |
return ToonzFolder::getRoomsFile(TFilePath(fn));
|
|
turtletooth |
8d9ba3 |
}
|
|
turtletooth |
8d9ba3 |
|
|
Toshihiro Shimizu |
890ddd |
//===================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
FolderListenerManager::FolderListenerManager() {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
FolderListenerManager::~FolderListenerManager() {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
FolderListenerManager *FolderListenerManager::instance() {
|
|
Shinya Kitaoka |
120a6e |
static FolderListenerManager _instance;
|
|
Shinya Kitaoka |
120a6e |
return &_instance;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void FolderListenerManager::notifyFolderChanged(const TFilePath &path) {
|
|
Shinya Kitaoka |
120a6e |
for (std::set<listener *="">::iterator i = m_listeners.begin();</listener>
|
|
Shinya Kitaoka |
120a6e |
i != m_listeners.end(); ++i)
|
|
Shinya Kitaoka |
120a6e |
(*i)->onFolderChanged(path);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void FolderListenerManager::addListener(Listener *listener) {
|
|
Shinya Kitaoka |
120a6e |
m_listeners.insert(listener);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void FolderListenerManager::removeListener(Listener *listener) {
|
|
Shinya Kitaoka |
120a6e |
m_listeners.erase(listener);
|
|
Toshihiro Shimizu |
890ddd |
}
|