From f3b6ecf0983dbb85a61faee21f41160df63cc575 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Tue, 21 Feb 2017 16:40:25 +0100 Subject: Single instance --- src/webengine/webengineprofile.cpp | 23 ++++++++++++++--------- src/webengine/webengineprofile.h | 1 + 2 files changed, 15 insertions(+), 9 deletions(-) (limited to 'src/webengine') diff --git a/src/webengine/webengineprofile.cpp b/src/webengine/webengineprofile.cpp index 826bc44..de806df 100644 --- a/src/webengine/webengineprofile.cpp +++ b/src/webengine/webengineprofile.cpp @@ -30,8 +30,9 @@ WebEngineProfile::WebEngineProfile(QObject *parent) : WebEngineProfile::WebEngineProfile(const QString &storageName, QObject *parent) : QWebEngineProfile(storageName, parent) { - qDebug("Reading WebEngineProfile..."); - QSettings config(persistentStoragePath() + "/profile.ini", QSettings::IniFormat); + QString profilePath = persistentStoragePath() + "/profile.ini"; + qDebug("Reading profile from [%s]", qUtf8Printable(profilePath)); + QSettings config(profilePath, QSettings::IniFormat); config.beginGroup("http"); setHttpUserAgent(config.value("userAgent").toString()); @@ -40,12 +41,16 @@ WebEngineProfile::WebEngineProfile(const QString &storageName, QObject *parent) WebEngineProfile::~WebEngineProfile() { - if(!this->isOffTheRecord()) { - // save settings - QSettings config(persistentStoragePath() + "/profile.ini", QSettings::IniFormat); - config.beginGroup("http"); - config.setValue("userAgent", httpUserAgent()); - config.endGroup(); - config.sync(); + if(!isOffTheRecord()) { + saveProfile(); } } + +void WebEngineProfile::saveProfile() +{ + QSettings config(persistentStoragePath() + "/profile.ini", QSettings::IniFormat); + config.beginGroup("http"); + config.setValue("userAgent", httpUserAgent()); + config.endGroup(); + config.sync(); +} diff --git a/src/webengine/webengineprofile.h b/src/webengine/webengineprofile.h index dc07f4b..1845c99 100644 --- a/src/webengine/webengineprofile.h +++ b/src/webengine/webengineprofile.h @@ -35,6 +35,7 @@ public: signals: public slots: + void saveProfile(); }; #endif // WEBENGINEPROFILE_H -- cgit v1.2.1