This repository has been archived on 2022-08-16. You can view files and clone it, but cannot push or open issues or pull requests.
fanny-app/sources/appsettings.cpp

41 lines
1.1 KiB
C++
Raw Normal View History

2018-06-21 16:41:02 +02:00
#include "headers/appsettings.h"
AppSettings * pGlobalAppSettings = nullptr;
2018-06-21 16:41:02 +02:00
AppSettings::AppSettings(QObject* parent)
:QObject(parent)
{
QString path = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
qDebug(path.toLatin1());
this->settingsManager = new QSettings(path+"/fannyapp/settings.ini", QSettings::IniFormat);
qDebug("AppSettings konstruktor");
if(loadSetting("init") == "false"){
this->writeSetting("init", 0);
}
if(loadSetting("grade") == "false"){
this->writeSetting("grade", 5);
}
2018-06-21 16:41:02 +02:00
}
QString AppSettings::loadSetting(const QString &key)
{
this->settingsManager->beginGroup("AppSettings");
QString value = this->settingsManager->value(key , false).toString();
this->settingsManager->endGroup();
return(value);
}
void AppSettings::writeSetting(const QString &key, const QVariant &variant)
{
this->settingsManager->beginGroup("AppSettings");
this->settingsManager->setValue(key , variant);
this->settingsManager->endGroup();
}
AppSettings::~AppSettings()
{
delete settingsManager;
}