2022-01-06 19:29:19 +00:00
|
|
|
#include "constants.h"
|
|
|
|
#include <QDir>
|
|
|
|
#include <QFileInfo>
|
|
|
|
#include <QMessageBox>
|
|
|
|
#include <QStandardPaths>
|
|
|
|
#include <QString>
|
|
|
|
|
|
|
|
// TODO: merge with constants from backend/
|
|
|
|
|
2022-02-22 08:02:34 +00:00
|
|
|
QString Constants::applicationPath(const QString& path)
|
2022-01-06 19:29:19 +00:00
|
|
|
{
|
2022-02-21 18:03:38 +00:00
|
|
|
return QFileInfo(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + path).absoluteFilePath();
|
2022-01-06 19:29:19 +00:00
|
|
|
}
|
|
|
|
|
2022-02-22 08:02:34 +00:00
|
|
|
QString Constants::tmpPath(const QString& path)
|
2022-01-06 19:29:19 +00:00
|
|
|
{
|
2022-02-21 18:03:38 +00:00
|
|
|
return QFileInfo(QStandardPaths::writableLocation(QStandardPaths::TempLocation) + path).absoluteFilePath();
|
2022-01-06 19:29:19 +00:00
|
|
|
}
|
|
|
|
|
2022-02-22 08:02:34 +00:00
|
|
|
QString Constants::cachePath(const QString& path)
|
2022-01-06 19:29:19 +00:00
|
|
|
{
|
2022-02-21 18:03:38 +00:00
|
|
|
return QFileInfo(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + path).absoluteFilePath();
|
2022-01-06 19:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Constants::ensureDirectories()
|
|
|
|
{
|
2022-02-21 18:03:38 +00:00
|
|
|
if(Constants::applicationPath().isEmpty())
|
|
|
|
{
|
|
|
|
QDir d{Constants::applicationPath()};
|
|
|
|
if(!d.mkpath(d.absolutePath()))
|
|
|
|
{
|
|
|
|
QMessageBox msgBox;
|
|
|
|
msgBox.setIcon(QMessageBox::Warning);
|
|
|
|
msgBox.setText("Cannot determine storage location");
|
|
|
|
msgBox.exec();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
2022-01-06 19:29:19 +00:00
|
|
|
}
|