updated paths

This commit is contained in:
itsmattkc
2019-01-05 23:43:38 +11:00
parent fcaed72865
commit 64c0f1e90d
4 changed files with 30 additions and 14 deletions
+1 -1
View File
@@ -11,7 +11,7 @@ QDebug debug_out(&debug_file);
void setup_debug() {
#ifndef QT_DEBUG
debug_file.setFileName(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/debug_log");
debug_file.setFileName(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/debug_log");
if (debug_file.open(QFile::WriteOnly)) {
QString debug_intro = "Olive Session " + QString::number(QDateTime::currentMSecsSinceEpoch());
debug_file.write(debug_intro.toUtf8());
+19 -10
View File
@@ -9,17 +9,26 @@ QString real_app_dir;
QString get_app_dir() {
if (real_app_dir.isEmpty()) {
QString app_path = QCoreApplication::applicationFilePath();
real_app_dir = app_path.left(app_path.lastIndexOf('/'));
}
return real_app_dir;
QString app_path = QCoreApplication::applicationFilePath();
real_app_dir = app_path.left(app_path.lastIndexOf('/'));
}
return real_app_dir;
}
QString get_data_path() {
QString app_dir = get_app_dir();
if (QFileInfo::exists(app_dir + "/portable")) {
return app_dir;
} else {
return QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
}
QString app_dir = get_app_dir();
if (QFileInfo::exists(app_dir + "/portable")) {
return app_dir;
} else {
return QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
}
}
QString get_config_path() {
QString app_dir = get_app_dir();
if (QFileInfo::exists(app_dir + "/portable")) {
return app_dir;
} else {
return QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation);
}
}
+1
View File
@@ -5,5 +5,6 @@
QString get_app_dir();
QString get_data_path();
QString get_config_path();
#endif // PATH_H
+9 -3
View File
@@ -187,9 +187,15 @@ MainWindow::MainWindow(QWidget *parent) :
}
f.close();
}
config_dir = data_dir + "/config.xml";
config.load(config_dir);
}
}
QString config_path = get_config_path();
if (!config_path.isEmpty()) {
QDir config_dir(config_path);
config_dir.mkpath(".");
QString config_fn = config_path + "/config.xml";
if (QFileInfo::exists(config_fn)) {
config.load(config_fn);
}
}