2018-08-12 20:51:57 +02:00
|
|
|
/*
|
|
|
|
Speed Climbing Stopwatch - Simple Stopwatch for Climbers
|
|
|
|
Copyright (C) 2018 Itsblue Development - Dorian Zeder
|
|
|
|
|
|
|
|
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, version 3 of the License.
|
|
|
|
|
|
|
|
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 <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2018-07-28 23:05:26 +02:00
|
|
|
#include "headers/appsettings.h"
|
2018-07-28 14:12:55 +02:00
|
|
|
|
2018-10-04 18:35:29 +02:00
|
|
|
AppSettings * pGlobalAppSettings = nullptr;
|
|
|
|
|
2018-07-28 14:12:55 +02:00
|
|
|
AppSettings::AppSettings(QObject* parent)
|
|
|
|
:QObject(parent)
|
|
|
|
{
|
|
|
|
QString path = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
2018-08-02 12:50:55 +02:00
|
|
|
|
2019-08-20 10:19:35 +02:00
|
|
|
this->settingsManager = new QSettings(path+"/settings.ini", QSettings::IniFormat, this);
|
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);
|
2018-08-28 23:03:35 +02:00
|
|
|
|
2019-03-27 22:26:59 +01:00
|
|
|
this->setDefaultSetting("theme", "Light");
|
2019-03-07 17:18:24 +01:00
|
|
|
|
2019-03-29 23:42:56 +01:00
|
|
|
this->setDefaultSetting("baseStationIpAdress", "192.168.4.1");
|
|
|
|
|
2019-03-07 17:18:24 +01:00
|
|
|
pGlobalAppSettings = this;
|
2018-07-28 14:12:55 +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();
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-07-28 14:12:55 +02:00
|
|
|
AppSettings::~AppSettings()
|
|
|
|
{
|
|
|
|
delete settingsManager;
|
|
|
|
}
|
|
|
|
|