From 5e6920c427b30232e47039d26cbaec7173c837d2 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Sat, 8 Sep 2018 15:41:10 +0200 Subject: Save WebProfile config when changed --- lib/web/profilemanager.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'lib/web/profilemanager.cpp') diff --git a/lib/web/profilemanager.cpp b/lib/web/profilemanager.cpp index b747bf6..960a03a 100644 --- a/lib/web/profilemanager.cpp +++ b/lib/web/profilemanager.cpp @@ -41,19 +41,22 @@ WebProfile *ProfileManager::loadProfile(const QString &path) ptr->profile = new WebProfile(id, ptr->settings.value("name", id).toString(), nullptr); } Q_CHECK_PTR(ptr->profile); + connect(ptr->profile, &WebProfile::nameChanged, [this, id](const QString &name) { + this->m_profiles.at(id)->settings.setValue("name", name); + }); ptr->profile->setSearch(ptr->settings.value("search", defaults.value("profile.search")).toString()); - connect(ptr->profile, &WebProfile::searchChanged, &ptr->settings, [this, id](const QString &url) { + connect(ptr->profile, &WebProfile::searchChanged, [this, id](const QString &url) { this->m_profiles.at(id)->settings.setValue("search", url); }); ptr->profile->setHomepage(ptr->settings.value("homepage", defaults.value("profile.homepage")).toUrl()); - connect(ptr->profile, &WebProfile::homepageChanged, &ptr->settings, [this, id](const QUrl &url) { + connect(ptr->profile, &WebProfile::homepageChanged, [this, id](const QUrl &url) { this->m_profiles.at(id)->settings.setValue("homepage", url); }); ptr->profile->setNewtab(ptr->settings.value("newtab", defaults.value("profile.newtab")).toUrl()); - connect(ptr->profile, &WebProfile::newtabChanged, &ptr->settings, [this, id](const QUrl &url) { + connect(ptr->profile, &WebProfile::newtabChanged, [this, id](const QUrl &url) { this->m_profiles.at(id)->settings.setValue("newtab", url); }); @@ -65,6 +68,9 @@ WebProfile *ProfileManager::loadProfile(const QString &path) } } ptr->settings.endGroup(); // properties + connect(ptr->profile, &WebProfile::propertyChanged, [this, id](const QString &property, const QVariant &value) { + this->m_profiles.at(id)->settings.setValue("properties/" + property, value); + }); ptr->settings.beginGroup("attributes"); { @@ -76,6 +82,9 @@ WebProfile *ProfileManager::loadProfile(const QString &path) } } ptr->settings.endGroup(); + connect(ptr->profile, &WebProfile::attributeChanged, [this, id](const QWebEngineSettings::WebAttribute attr, const bool value) { + this->m_profiles.at(id)->settings.setValue("attributes/" + QString::number(attr), value); + }); m_profiles[id] = std::move(ptr); return m_profiles.at(id)->profile; -- cgit v1.2.1