|
@@ -3,32 +3,9 @@
|
|
|
|
|
|
namespace OPL {
|
|
|
|
|
|
-Paths::Paths()
|
|
|
-{
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-const bool Paths::setup()
|
|
|
-{
|
|
|
-
|
|
|
-// Define the application paths. This will be standard locations on all platforms eventually
|
|
|
-// but for now on Windows and MacOS use the application runtime directory to make it easier to
|
|
|
-// debug and develop. On Linux XDG standard directories are required for the flatpak to work.
|
|
|
-
|
|
|
-#ifdef linux
|
|
|
- LOG << "Setting up directories at: " << QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation);
|
|
|
- const QString dir_path = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation);
|
|
|
- for(const auto& str : qAsConst(directories)){
|
|
|
- QDir dir(dir_path + str);
|
|
|
- if(!dir.exists()) {
|
|
|
- if (!dir.mkpath(dir.absolutePath()))
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
- return true;
|
|
|
-#else
|
|
|
- LOG << "Setting up directories at: " << QCoreApplication::applicationDirPath();
|
|
|
- const QString dir_path = QCoreApplication::applicationDirPath();
|
|
|
+const bool Paths::setup() {
|
|
|
+ LOG << "Setting up directories at: " << basePath;
|
|
|
+ const QString dir_path = basePath;
|
|
|
for(const auto& str : qAsConst(directories)){
|
|
|
QDir dir(dir_path + str);
|
|
|
if(!dir.exists()) {
|
|
@@ -37,22 +14,21 @@ const bool Paths::setup()
|
|
|
}
|
|
|
}
|
|
|
return true;
|
|
|
-#endif
|
|
|
}
|
|
|
|
|
|
const QDir Paths::directory(Directories location)
|
|
|
{
|
|
|
- return QDir(QCoreApplication::applicationDirPath() + directories[location]);
|
|
|
+ return QDir(basePath + directories[location]);
|
|
|
}
|
|
|
|
|
|
const QString Paths::path(Directories location)
|
|
|
{
|
|
|
- return QDir::toNativeSeparators(QCoreApplication::applicationDirPath() + directories[location]);
|
|
|
+ return QDir::toNativeSeparators(basePath + directories[location]);
|
|
|
}
|
|
|
|
|
|
const QString Paths::filePath(Directories location, const QString &filename)
|
|
|
{
|
|
|
- QDir dir(QCoreApplication::applicationDirPath() + directories[location]);
|
|
|
+ QDir dir(basePath + directories[location]);
|
|
|
return dir.absoluteFilePath(filename);
|
|
|
}
|
|
|
|