Add ability to customize cache folder
Add an advanced settings page, currently only housing the "Cache" category Fix #541
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#include "singletons/Paths.hpp"
|
||||
|
||||
#include "singletons/Settings.hpp"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QCryptographicHash>
|
||||
#include <QDir>
|
||||
@@ -33,6 +35,27 @@ bool Paths::isPortable()
|
||||
return this->portable_.get();
|
||||
}
|
||||
|
||||
QString Paths::cacheDirectory()
|
||||
{
|
||||
static QStringSetting cachePathSetting = [] {
|
||||
QStringSetting cachePathSetting("/cache/path");
|
||||
|
||||
cachePathSetting.connect([](const auto &newPath, auto) {
|
||||
QDir().mkpath(newPath); //
|
||||
});
|
||||
|
||||
return cachePathSetting;
|
||||
}();
|
||||
|
||||
auto path = cachePathSetting.getValue();
|
||||
|
||||
if (path == "") {
|
||||
return this->cacheDirectory_;
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
void Paths::initAppFilePathHash()
|
||||
{
|
||||
this->applicationFilePathHash =
|
||||
@@ -104,7 +127,7 @@ void Paths::initSubDirectories()
|
||||
|
||||
makePath("");
|
||||
this->settingsDirectory = makePath("Settings");
|
||||
this->cacheDirectory = makePath("Cache");
|
||||
this->cacheDirectory_ = makePath("Cache");
|
||||
this->messageLogDirectory = makePath("Logs");
|
||||
this->miscDirectory = makePath("Misc");
|
||||
}
|
||||
|
||||
@@ -19,9 +19,6 @@ public:
|
||||
// Directory for settings files. Same as <appDataDirectory>/Settings
|
||||
QString settingsDirectory;
|
||||
|
||||
// Directory for cache files. Same as <appDataDirectory>/Misc
|
||||
QString cacheDirectory;
|
||||
|
||||
// Directory for message log files. Same as <appDataDirectory>/Misc
|
||||
QString messageLogDirectory;
|
||||
|
||||
@@ -34,6 +31,8 @@ public:
|
||||
bool createFolder(const QString &folderPath);
|
||||
bool isPortable();
|
||||
|
||||
QString cacheDirectory();
|
||||
|
||||
private:
|
||||
void initAppFilePathHash();
|
||||
void initCheckPortable();
|
||||
@@ -41,6 +40,9 @@ private:
|
||||
void initSubDirectories();
|
||||
|
||||
boost::optional<bool> portable_;
|
||||
|
||||
// Directory for cache files. Same as <appDataDirectory>/Misc
|
||||
QString cacheDirectory_;
|
||||
};
|
||||
|
||||
Paths *getPaths();
|
||||
|
||||
@@ -153,6 +153,8 @@ public:
|
||||
IntSetting startUpNotification = {"/misc/startUpNotification", 0};
|
||||
QStringSetting currentVersion = {"/misc/currentVersion", ""};
|
||||
|
||||
QStringSetting cachePath = {"/cache/path", ""};
|
||||
|
||||
void saveSnapshot();
|
||||
void restoreSnapshot();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user