blob: a67897ed05fea28e12c18e29fa61490608dd0d40 (
plain) (
tree)
|
|
/*
* choosersettings.cpp
*
* Created on: Mar 24, 2014
* Author: nils
*/
#include "choosersettings.h"
#include "globals.h"
bool ChooserSettings::settingsLoaded = false;
ChooserSettings* ChooserSettings::chooserSettings = NULL;
ChooserSettings::ChooserSettings() {
// test (and make) directory
QDir saveFileDir(QFileInfo(previousSessionFile).absoluteDir());
if (!saveFileDir.exists()) {
if (!saveFileDir.mkpath(saveFileDir.path())) {
return;
}
}
settings = new QSettings(previousSessionFile, QSettings::IniFormat);
settings->setIniCodec("UTF-8");
if (settings->status() != QSettings::NoError) {
if (debugMode) {
qDebug() << "Settings: " << previousSessionFile << " contains erros.";
}
return;
}
settingsLoaded = true;
}
ChooserSettings::~ChooserSettings() {
settings->deleteLater();
}
QString ChooserSettings::getSetting(QString key) {
if (!settingsLoaded) {
chooserSettings = new ChooserSettings();
if (!settingsLoaded) return "";
}
return chooserSettings->settings->value(key).toString();
}
bool ChooserSettings::setSetting(QString key, QString value) {
if (!settingsLoaded) {
chooserSettings = new ChooserSettings();
if (!settingsLoaded) return false;
}
chooserSettings->settings->setValue(key, value);
// chooserSettings->settings->sync();
return true;
}
|