2017-04-23 15:05:48 +02:00
|
|
|
#include "settings.hpp"
|
|
|
|
|
2017-07-11 16:24:36 +02:00
|
|
|
#include <QDebug>
|
2017-04-23 15:05:48 +02:00
|
|
|
#include <QStandardPaths>
|
|
|
|
|
2017-05-06 13:21:12 +02:00
|
|
|
QSettings &settings::settings() {
|
2017-07-11 16:24:36 +02:00
|
|
|
static QSettings settings(dir().absoluteFilePath("settings.ini"), QSettings::IniFormat);
|
|
|
|
return settings;
|
|
|
|
}
|
|
|
|
|
|
|
|
QDir settings::dir() {
|
2017-05-09 17:26:00 +02:00
|
|
|
static QDir configDir(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation));
|
2017-06-04 01:04:42 +02:00
|
|
|
if (configDir.dirName() != "KShare") {
|
2017-07-23 13:32:02 +02:00
|
|
|
if (!configDir.cd("KShare")) {
|
2017-07-11 16:24:36 +02:00
|
|
|
if (!configDir.mkdir("KShare")) {
|
2017-07-29 17:22:17 +02:00
|
|
|
qFatal("%s", QObject::tr("Could not make config directory").toLocal8Bit().constData());
|
2017-07-11 16:24:36 +02:00
|
|
|
} else {
|
|
|
|
configDir.cd("KShare");
|
|
|
|
}
|
2017-07-23 13:32:02 +02:00
|
|
|
}
|
2017-05-09 17:26:00 +02:00
|
|
|
}
|
2017-07-11 16:24:36 +02:00
|
|
|
return configDir;
|
2017-04-23 15:05:48 +02:00
|
|
|
}
|