diff --git a/debug.cpp b/debug.cpp index 0c63079ef..1e64959d8 100644 --- a/debug.cpp +++ b/debug.cpp @@ -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()); diff --git a/io/path.cpp b/io/path.cpp index b90e13345..2d24812f0 100644 --- a/io/path.cpp +++ b/io/path.cpp @@ -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); + } } diff --git a/io/path.h b/io/path.h index 31ff1e651..9eff9033f 100644 --- a/io/path.h +++ b/io/path.h @@ -5,5 +5,6 @@ QString get_app_dir(); QString get_data_path(); +QString get_config_path(); #endif // PATH_H diff --git a/mainwindow.cpp b/mainwindow.cpp index ca2822b17..6b535e050 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -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); } }