diff --git a/src/config.cpp b/src/config.cpp index be0612fa..0fa7e01e 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -10,6 +10,7 @@ #include #include #include +#include KeyValueConfigBase::~KeyValueConfigBase() { @@ -89,7 +90,14 @@ PorymapConfig porymapConfig; QString PorymapConfig::getConfigFilepath() { // porymap config file is in the same directory as porymap itself. - return "porymap.cfg"; + QString settingsPath = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); + QDir dir(settingsPath); + if (!dir.exists()) + dir.mkpath(settingsPath); + + QString configPath = dir.absoluteFilePath("porymap.cfg"); + + return configPath; } void PorymapConfig::parseConfigKeyValue(QString key, QString value) { diff --git a/src/log.cpp b/src/log.cpp index 28d33a29..73e29121 100644 --- a/src/log.cpp +++ b/src/log.cpp @@ -1,5 +1,7 @@ #include "log.h" #include +#include +#include void logInfo(QString message) { log(message, LogType::LOG_INFO); @@ -30,8 +32,16 @@ void log(QString message, LogType type) { } message = QString("%1 %2 %3").arg(now).arg(typeString).arg(message); + + QString settingsPath = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); + QDir dir(settingsPath); + if (!dir.exists()) + dir.mkpath(settingsPath); + + QString logPath = dir.absoluteFilePath("porymap.log"); + qDebug() << message; - QFile outFile("porymap.log"); + QFile outFile(logPath); outFile.open(QIODevice::WriteOnly | QIODevice::Append); QTextStream ts(&outFile); ts << message << endl;