38 lines
1,009 B
C++
38 lines
1,009 B
C++
#include "appsettings.h"
|
|
|
|
AppSettings * pGlobalAppSettings = nullptr;
|
|
|
|
AppSettings::AppSettings(QObject* parent)
|
|
:QObject(parent)
|
|
{
|
|
qDebug() << "+ --- AppSettings konstruktor --- +";
|
|
|
|
pGlobalAppSettings = this;
|
|
|
|
QString path = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
|
qDebug() << "+ --- Settings Path:" << path << " --- +";
|
|
|
|
this->settingsManager = new QSettings(path+"/settings.ini", QSettings::IniFormat);
|
|
}
|
|
|
|
QString AppSettings::read(QString key)
|
|
{
|
|
this->settingsManager->beginGroup("AppSettings");
|
|
QString value = this->settingsManager->value(key , false).toString();
|
|
this->settingsManager->endGroup();
|
|
return(value);
|
|
}
|
|
|
|
void AppSettings::write(QString key, QVariant variant)
|
|
{
|
|
this->settingsManager->beginGroup("AppSettings");
|
|
this->settingsManager->setValue(key , variant);
|
|
this->settingsManager->endGroup();
|
|
}
|
|
|
|
AppSettings::~AppSettings()
|
|
{
|
|
qDebug("+----- AppSettings destruktor -----+");
|
|
delete settingsManager;
|
|
}
|
|
|