#include "settings.h" Settings::Settings() { this->cloudEnabled = false; this->cloudEmail = ""; this->cloudPassword = ""; this->cloudUrl = ""; this->cloudAgent = DEFAULT_AGENT_KEY; } Settings* Settings::FromJSON(QJsonObject obj) { Settings *s = new Settings(); if (obj["cloud"].isObject()) { QJsonObject cloud = obj["cloud"].toObject(); s->cloudEnabled = cloud["enabled"].toBool(false); s->cloudUrl = cloud["url"].toString(""); s->cloudEmail = cloud["email"].toString(""); s->cloudPassword = cloud["password"].toString(""); s->cloudAgent = cloud["agent"].toString(DEFAULT_AGENT_KEY); } return s; } QJsonObject Settings::ToJSON() { QJsonObject s; QJsonObject cloud; cloud["enabled"] = this->cloudEnabled; cloud["url"] = this->cloudUrl; cloud["email"] = this->cloudEmail; cloud["password"] = this->cloudPassword; cloud["agent"] = this->cloudAgent; s["cloud"] = cloud; return s; } bool Settings::GetCloudEnabled() { return this->cloudEnabled; } QString Settings::GetCloudUrl() { return this->cloudUrl; } QString Settings::GetCloudEmail() { return this->cloudEmail; } QString Settings::GetCloudPassword() { return this->cloudPassword; } QString Settings::GetCloudAgent() { return this->cloudAgent; } QString Settings::GetCloudAgentDefault() { return DEFAULT_AGENT; } void Settings::SetCloudEnabled(bool enabled) { this->cloudEnabled = enabled; } void Settings::SetCloudUrl(QString url) { this->cloudUrl = url; } void Settings::SetCloudEmail(QString email) { this->cloudEmail = email; } void Settings::SetCloudPassword(QString password) { this->cloudPassword = password; } void Settings::SetCloudAgent(QString agent) { this->cloudAgent = agent; }