Newer
Older
/**
* A library for Qt app
*
* LICENSE: The GNU Lesser General Public License, version 3.0
*
* @author Akira Ohgaki <akiraohgaki@gmail.com>
* @copyright Akira Ohgaki
* @license https://opensource.org/licenses/LGPL-3.0 The GNU Lesser General Public License, version 3.0
* @link https://github.com/akiraohgaki/qt-libs
*/
Config::Config(const QString &configsDir, QObject *parent) :
{}
QJsonObject Config::get(const QString &name)
{
if (json.isEmpty()) {
json = "{}"; // Blank JSON data as default
}
cacheData_[name] = utils::Json::convertStrToObj(json);
}
bool Config::set(const QString &name, const QJsonObject &jsonObj)
{
QString json = utils::Json::convertObjToStr(jsonObj);
utils::File::makeDir(configsDir_);
if (utils::File::writeText(configFile, json)) {