/* ============================================================ * The rekonq project * ============================================================ * SPDX-License-Identifier: GPL-3.0-only * Copyright (C) 2022 aqua * ============================================================ * Description: Application Settings * ============================================================ */ #include "settings.hpp" #include "../rekonq.hpp" #include "helpers.hpp" #include #include #include QString Settings::path() { return QDir(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation)).filePath("rekonqrc"); } Settings::Settings(const QString &path, QObject *parent) : RekonqSettings(parent) { d = new QSettings(path, QSettings::IniFormat, this); b = new QSettings(":/settings/rekonqrc", QSettings::IniFormat, this); } Settings::~Settings() { delete d; delete b; } void Settings::beginGroup(const QString &prefix) { d->beginGroup(prefix); b->beginGroup(prefix); } void Settings::endGroup() { d->endGroup(); b->endGroup(); } void Settings::setValue(const QString &key, const QVariant &value) { if (value == b->value(key)) d->remove(key); else d->setValue(key, value); emit changed(key, value); } void Settings::resetValue(const QString &key) { d->remove(key); } QVariant Settings::value(const QString &key) const { auto v = d->value(key); if (v.isValid()) return v; if (key == QL1S("standardFontFamily")) return getFont(QFont::System).family(); if (key == QL1S("fixedFontFamily")) return getFont(QFont::Monospace).family(); if (key == QL1S("serifFontFamily")) return getFont(QFont::Times).family(); if (key == QL1S("sansSerifFontFamily")) return getFont(QFont::Helvetica).family(); if (key == QL1S("cursiveFontFamily")) return getFont(QFont::Cursive).family(); if (key == QL1S("fantasyFontFamily")) return getFont(QFont::Fantasy).family(); v = b->value(key); Q_ASSERT_X(v.isValid(), __PRETTY_FUNCTION__, qUtf8Printable(key)); return v; } QString Settings::filePath() const { return d->fileName(); }