Add ability to customize cache folder

Add an advanced settings page, currently only housing the "Cache" category

Fix #541
This commit is contained in:
Rasmus Karlsson
2018-08-19 16:20:14 +02:00
parent 3fc91bded5
commit a07255be2d
9 changed files with 133 additions and 14 deletions
+24 -1
View File
@@ -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");
}