56 lines
1.8 KiB
C++
56 lines
1.8 KiB
C++
/*
|
|
DasSchmalter - The smart switch
|
|
Copyright (C) 2019 Itsblue Development ( contact@itsblue.de )
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Affero General Public License as published
|
|
by the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Affero General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#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;
|
|
}
|
|
|