added real portable mode

This commit is contained in:
itsmattkc
2018-10-29 18:15:50 +11:00
parent a54fee767d
commit 0817a1e486
10 changed files with 39 additions and 14 deletions
+16
View File
@@ -0,0 +1,16 @@
#include "path.h"
#include <QStandardPaths>
#include <QFileInfo>
#include <QCoreApplication>
QString get_data_path() {
QString app_path = QCoreApplication::applicationFilePath();
QString app_dir = app_path.left(app_path.lastIndexOf('/'));
if (QFileInfo::exists(app_dir + "/portable")) {
return app_dir;
} else {
return QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
}
}
+8
View File
@@ -0,0 +1,8 @@
#ifndef PATH_H
#define PATH_H
#include <QString>
QString get_data_path();
#endif // PATH_H
+3 -3
View File
@@ -4,7 +4,7 @@
#include "panels/viewer.h"
#include "panels/project.h"
#include "io/config.h"
#include "io/crc32.h"
#include "io/path.h"
#include "debug.h"
#include <QPainter>
@@ -14,8 +14,8 @@
#include <QSemaphore>
#include <QCryptographicHash>
#include <QFile>
#include <QStandardPaths>
#include <QDir>
#include <QDateTime>
#define WAVEFORM_RESOLUTION 64
@@ -38,7 +38,7 @@ PreviewGenerator::PreviewGenerator(QTreeWidgetItem* i, Media* m, bool r) :
replace(r),
cancelled(false)
{
data_path = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/previews";
data_path = get_data_path() + "/previews";
QDir data_dir(data_path);
if (!data_dir.exists()) {
data_dir.mkpath(".");