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

45 lines
1.2 KiB
C++
Raw Normal View History

2018-07-28 23:05:26 +02:00
#include "headers/appsettings.h"
AppSettings::AppSettings(QObject* parent)
:QObject(parent)
{
QString path = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
2018-08-02 12:50:55 +02:00
this->settingsManager = new QSettings(path+"/settings.ini", QSettings::IniFormat);
2018-08-02 12:50:55 +02:00
this->setDefaultSetting("ready_en", "false");
this->setDefaultSetting("ready_delay", 0);
this->setDefaultSetting("at_marks_en", "false");
this->setDefaultSetting("at_marks_delay", 0);
}
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();
}
2018-08-02 12:50:55 +02:00
void AppSettings::setDefaultSetting(const QString &key, const QVariant &defaultVariant)
{
QString value = this->loadSetting(key);
if(value == "false"){
this->writeSetting(key, defaultVariant);
}
}
AppSettings::~AppSettings()
{
delete settingsManager;
}