27 lines
706 B
C++
27 lines
706 B
C++
#include "settings.hpp"
|
|
|
|
#include <QDebug>
|
|
#include <QMutex>
|
|
#include <QStandardPaths>
|
|
|
|
QMutex *lock = new QMutex;
|
|
|
|
QSettings &settings::settings() {
|
|
QMutexLocker l(lock);
|
|
static QSettings settings(dir().absoluteFilePath("settings.ini"), QSettings::IniFormat);
|
|
return settings;
|
|
}
|
|
|
|
QDir settings::dir() {
|
|
static QDir configDir(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation));
|
|
if (configDir.dirName() != "KShare") {
|
|
if (!configDir.cd("KShare"))
|
|
if (!configDir.mkdir("KShare")) {
|
|
qFatal("Could not make config directory");
|
|
} else {
|
|
configDir.cd("KShare");
|
|
}
|
|
}
|
|
return configDir;
|
|
}
|