mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-03-06 14:27:43 +00:00
Added a UserThemeDirectory setting for relocating the user theme directory
This commit is contained in:
parent
6139c96d4c
commit
2209c384aa
|
@ -163,7 +163,31 @@ GuiThemeDownloader::GuiThemeDownloader(std::function<void()> updateCallback)
|
||||||
std::promise<bool>().swap(mPromise);
|
std::promise<bool>().swap(mPromise);
|
||||||
mFuture = mPromise.get_future();
|
mFuture = mPromise.get_future();
|
||||||
|
|
||||||
mThemeDirectory = Utils::FileSystem::getHomePath() + "/.emulationstation/themes/";
|
const std::string defaultUserThemeDir {Utils::FileSystem::getHomePath() +
|
||||||
|
"/.emulationstation/themes"};
|
||||||
|
std::string userThemeDirSetting {Utils::FileSystem::expandHomePath(
|
||||||
|
Settings::getInstance()->getString("UserThemeDirectory"))};
|
||||||
|
#if defined(_WIN64)
|
||||||
|
mThemeDirectory = Utils::String::replace(mThemeDirectory, "\\", "/");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (userThemeDirSetting == "") {
|
||||||
|
mThemeDirectory = defaultUserThemeDir;
|
||||||
|
}
|
||||||
|
else if (Utils::FileSystem::isDirectory(userThemeDirSetting) ||
|
||||||
|
Utils::FileSystem::isSymlink(userThemeDirSetting)) {
|
||||||
|
mThemeDirectory = userThemeDirSetting;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
LOG(LogWarning) << "GuiThemeDownloader: Requested user theme directory \""
|
||||||
|
<< userThemeDirSetting
|
||||||
|
<< "\" does not exist or is not a directory, reverting to \""
|
||||||
|
<< defaultUserThemeDir << "\"";
|
||||||
|
mThemeDirectory = defaultUserThemeDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mThemeDirectory.back() != '/')
|
||||||
|
mThemeDirectory.append("/");
|
||||||
}
|
}
|
||||||
|
|
||||||
GuiThemeDownloader::~GuiThemeDownloader()
|
GuiThemeDownloader::~GuiThemeDownloader()
|
||||||
|
|
|
@ -673,19 +673,32 @@ int main(int argc, char* argv[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the themes directory in the application home folder. This is not required but
|
// Create the themes directory in the application home directory (or elsewhere if the
|
||||||
// is rather a convenience in case the user wants to add additional themes.
|
// UserThemeDirectory setting has been defined).
|
||||||
const std::string themesDir {Utils::FileSystem::getHomePath() + "/.emulationstation/themes"};
|
const std::string defaultUserThemeDir {Utils::FileSystem::getHomePath() +
|
||||||
if (!Utils::FileSystem::exists(themesDir)) {
|
"/.emulationstation/themes"};
|
||||||
|
std::string userThemeDirSetting {Utils::FileSystem::expandHomePath(
|
||||||
|
Settings::getInstance()->getString("UserThemeDirectory"))};
|
||||||
#if defined(_WIN64)
|
#if defined(_WIN64)
|
||||||
LOG(LogInfo) << "Creating themes directory \""
|
userThemeDirSetting = Utils::String::replace(userThemeDirSetting, "\\", "/");
|
||||||
<< Utils::String::replace(themesDir, "/", "\\") << "\"...";
|
|
||||||
#else
|
|
||||||
LOG(LogInfo) << "Creating themes directory \"" << themesDir << "\"...";
|
|
||||||
#endif
|
#endif
|
||||||
Utils::FileSystem::createDirectory(themesDir);
|
std::string userThemeDirectory;
|
||||||
if (!Utils::FileSystem::exists(themesDir)) {
|
|
||||||
LOG(LogWarning) << "Couldn't create directory, permission problems?\n";
|
if (userThemeDirSetting == "")
|
||||||
|
userThemeDirectory = defaultUserThemeDir;
|
||||||
|
else
|
||||||
|
userThemeDirectory = userThemeDirSetting;
|
||||||
|
|
||||||
|
if (!Utils::FileSystem::exists(userThemeDirectory)) {
|
||||||
|
#if defined(_WIN64)
|
||||||
|
LOG(LogInfo) << "Creating user theme directory \""
|
||||||
|
<< Utils::String::replace(userThemeDirectory, "/", "\\") << "\"...";
|
||||||
|
#else
|
||||||
|
LOG(LogInfo) << "Creating themes directory \"" << userThemeDirectory << "\"...";
|
||||||
|
#endif
|
||||||
|
Utils::FileSystem::createDirectory(userThemeDirectory);
|
||||||
|
if (!Utils::FileSystem::exists(userThemeDirectory)) {
|
||||||
|
LOG(LogWarning) << "Couldn't create directory, permission problems?";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -316,6 +316,7 @@ void Settings::setDefaults()
|
||||||
mStringMap["OpenGLVersion"] = {"", ""};
|
mStringMap["OpenGLVersion"] = {"", ""};
|
||||||
mStringMap["ROMDirectory"] = {"", ""};
|
mStringMap["ROMDirectory"] = {"", ""};
|
||||||
mStringMap["UIMode_passkey"] = {"uuddlrlrba", "uuddlrlrba"};
|
mStringMap["UIMode_passkey"] = {"uuddlrlrba", "uuddlrlrba"};
|
||||||
|
mStringMap["UserThemeDirectory"] = {"", ""};
|
||||||
mIntMap["LottieMaxFileCache"] = {150, 150};
|
mIntMap["LottieMaxFileCache"] = {150, 150};
|
||||||
mIntMap["LottieMaxTotalCache"] = {1024, 1024};
|
mIntMap["LottieMaxTotalCache"] = {1024, 1024};
|
||||||
mIntMap["ScraperConnectionTimeout"] = {30, 30};
|
mIntMap["ScraperConnectionTimeout"] = {30, 30};
|
||||||
|
|
|
@ -771,8 +771,32 @@ void ThemeData::populateThemeSets()
|
||||||
sThemeSets.clear();
|
sThemeSets.clear();
|
||||||
LOG(LogInfo) << "Checking for available theme sets...";
|
LOG(LogInfo) << "Checking for available theme sets...";
|
||||||
|
|
||||||
// Check for themes first under the home directory, then under the data installation
|
// Check for themes first under the user theme directory (which is in the ES-DE home directory
|
||||||
// directory (Unix only) and last under the ES-DE binary directory.
|
// by default), then under the data installation directory (Unix only) and last under the ES-DE
|
||||||
|
// binary directory.
|
||||||
|
const std::string defaultUserThemeDir {Utils::FileSystem::getHomePath() +
|
||||||
|
"/.emulationstation/themes"};
|
||||||
|
std::string userThemeDirSetting {Utils::FileSystem::expandHomePath(
|
||||||
|
Settings::getInstance()->getString("UserThemeDirectory"))};
|
||||||
|
#if defined(_WIN64)
|
||||||
|
userThemeDirSetting = Utils::String::replace(userThemeDirSetting, "\\", "/");
|
||||||
|
#endif
|
||||||
|
std::string userThemeDirectory;
|
||||||
|
|
||||||
|
if (userThemeDirSetting == "") {
|
||||||
|
userThemeDirectory = defaultUserThemeDir;
|
||||||
|
}
|
||||||
|
else if (Utils::FileSystem::isDirectory(userThemeDirSetting) ||
|
||||||
|
Utils::FileSystem::isSymlink(userThemeDirSetting)) {
|
||||||
|
userThemeDirectory = userThemeDirSetting;
|
||||||
|
LOG(LogInfo) << "Setting user theme directory to \"" << userThemeDirectory << "\"";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
LOG(LogWarning) << "Requested user theme directory \"" << userThemeDirSetting
|
||||||
|
<< "\" does not exist or is not a directory, reverting to \""
|
||||||
|
<< defaultUserThemeDir << "\"";
|
||||||
|
userThemeDirectory = defaultUserThemeDir;
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(__unix__) || defined(__APPLE__)
|
#if defined(__unix__) || defined(__APPLE__)
|
||||||
#if defined(APPIMAGE_BUILD)
|
#if defined(APPIMAGE_BUILD)
|
||||||
|
@ -790,7 +814,7 @@ void ThemeData::populateThemeSets()
|
||||||
#elif defined(__unix__) && !defined(APPIMAGE_BUILD)
|
#elif defined(__unix__) && !defined(APPIMAGE_BUILD)
|
||||||
Utils::FileSystem::getProgramDataPath() + "/themes",
|
Utils::FileSystem::getProgramDataPath() + "/themes",
|
||||||
#endif
|
#endif
|
||||||
Utils::FileSystem::getHomePath() + "/.emulationstation/themes"
|
userThemeDirectory
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t i {0}; i < pathCount; ++i) {
|
for (size_t i {0}; i < pathCount; ++i) {
|
||||||
|
|
Loading…
Reference in a new issue