From 8c30d0d5f0ab93c44b6957040fd0a2b3b7749faa Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Thu, 12 Jan 2017 19:57:00 +0100 Subject: Profile config loading and saving --- src/webengine/webengineprofile.cpp | 31 +++++++++++++++++++++++++++++++ src/webengine/webengineprofile.h | 20 ++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 src/webengine/webengineprofile.cpp create mode 100644 src/webengine/webengineprofile.h (limited to 'src/webengine') diff --git a/src/webengine/webengineprofile.cpp b/src/webengine/webengineprofile.cpp new file mode 100644 index 0000000..1eb1112 --- /dev/null +++ b/src/webengine/webengineprofile.cpp @@ -0,0 +1,31 @@ +#include "webengineprofile.h" +#include + +WebEngineProfile::WebEngineProfile(QObject *parent) : + QWebEngineProfile(parent) +{ + // Off-the-record constructor +} + +WebEngineProfile::WebEngineProfile(const QString &storageName, QObject *parent) : + QWebEngineProfile(storageName, parent) +{ + qDebug("Reading WebEngineProfile..."); + QSettings config(persistentStoragePath() + "/profile.ini", QSettings::IniFormat); + + config.beginGroup("http"); + setHttpUserAgent(config.value("userAgent").toString()); + config.endGroup(); +} + +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(); + } +} diff --git a/src/webengine/webengineprofile.h b/src/webengine/webengineprofile.h new file mode 100644 index 0000000..ca2fd08 --- /dev/null +++ b/src/webengine/webengineprofile.h @@ -0,0 +1,20 @@ +#ifndef WEBENGINEPROFILE_H +#define WEBENGINEPROFILE_H + +#include + +class WebEngineProfile : public QWebEngineProfile +{ + Q_OBJECT +public: + WebEngineProfile(QObject *parent = Q_NULLPTR); + WebEngineProfile(const QString &storageName, QObject *parent = Q_NULLPTR); + + ~WebEngineProfile(); + +signals: + +public slots: +}; + +#endif // WEBENGINEPROFILE_H -- cgit v1.2.1