aboutsummaryrefslogtreecommitdiff
path: root/src/webengine/webengineprofile.cpp
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2017-07-03 14:47:24 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2017-07-03 14:47:24 +0200
commit089abd62383516eb33cbc1c93b06826a0cba3d7b (patch)
treeff74a37b5115052a8ea27679b32aef20523d86c9 /src/webengine/webengineprofile.cpp
parentAdded homepage button (diff)
downloadsmolbote-089abd62383516eb33cbc1c93b06826a0cba3d7b.tar.xz
Added homepage and newtab to profile widget
Diffstat (limited to 'src/webengine/webengineprofile.cpp')
-rw-r--r--src/webengine/webengineprofile.cpp152
1 files changed, 77 insertions, 75 deletions
diff --git a/src/webengine/webengineprofile.cpp b/src/webengine/webengineprofile.cpp
index 5d00495..0a16cd5 100644
--- a/src/webengine/webengineprofile.cpp
+++ b/src/webengine/webengineprofile.cpp
@@ -23,86 +23,83 @@
#include <QSettings>
#include <QWebEngineSettings>
-WebEngineProfile::WebEngineProfile(QObject *parent) :
+WebEngineProfile::WebEngineProfile(const QString &name, QObject *parent) :
QWebEngineProfile(parent)
{
- // Off-the-record constructor
- m_name = tr("Off-the-record");
- m_homepage = QUrl("https://duckduckgo.com");
-}
-
-WebEngineProfile::WebEngineProfile(const QString &name, const QString &path, QObject *parent) :
- QWebEngineProfile(name, parent)
-{
- m_name = name;
- m_homepage = QUrl("https://duckduckgo.com");
- setPersistentStoragePath(path + name);
- setCachePath(path + name);
-
- QString profilePath = path + "/profile.ini";
- qDebug("Reading profile from [%s]", qUtf8Printable(profilePath));
- QSettings config(profilePath, QSettings::IniFormat);
-
- config.beginGroup("http");
- setHttpUserAgent(config.value("userAgent").toString());
- setHttpAcceptLanguage(config.value("accept-lang").toString());
- {
- QString cacheType = config.value("cacheType").toString();
- if(cacheType == "memory") {
- setHttpCacheType(MemoryHttpCache);
- } else if(cacheType == "disk") {
- setHttpCacheType(DiskHttpCache);
- } else if(cacheType == "disabled") {
- setHttpCacheType(NoCache);
- }
+ if(name.isEmpty()) {
+ m_name = tr("Off-the-record");
+ // off-the-record should have no storage or cache
+ } else {
+ m_name = name;
+ setPersistentStoragePath(sSettings->value("browser.profile.path").toString() + name);
+ setCachePath(sSettings->value("browser.profile.path").toString() + name);
}
- setHttpCacheMaximumSize(config.value("cacheSize").toInt());
- config.endGroup(); // http
- config.beginGroup("policy");
- {
- QString cookies = config.value("cookies").toString();
- if(cookies == "disabled") {
- setPersistentCookiesPolicy(NoPersistentCookies);
- } else if(cookies == "allow") {
- setPersistentCookiesPolicy(AllowPersistentCookies);
- } else if(cookies == "force") {
- setPersistentCookiesPolicy(ForcePersistentCookies);
+ QString profilePath = sSettings->value("browser.profile.path").toString() + name + "/profile.ini";
+ if(QFile::exists(profilePath)) {
+
+ qDebug("Reading profile from [%s]", qUtf8Printable(profilePath));
+ QSettings config(profilePath, QSettings::IniFormat);
+
+ m_homepage = config.value("homepage", m_homepage).toUrl();
+ m_newtab = config.value("newtab", m_newtab).toUrl();
+
+ config.beginGroup("http");
+ setHttpUserAgent(config.value("userAgent").toString());
+ setHttpAcceptLanguage(config.value("accept-lang").toString());
+ {
+ QString cacheType = config.value("cacheType").toString();
+ if(cacheType == "memory") {
+ setHttpCacheType(MemoryHttpCache);
+ } else if(cacheType == "disk") {
+ setHttpCacheType(DiskHttpCache);
+ } else if(cacheType == "disabled") {
+ setHttpCacheType(NoCache);
+ }
}
- }
- config.endGroup(); // policy
-
- config.beginGroup("attributes");
- settings()->setAttribute(QWebEngineSettings::AutoLoadImages, config.value("autoLoadImages", true).toBool());
- settings()->setAttribute(QWebEngineSettings::JavascriptEnabled, config.value("javascriptEnabled", true).toBool());
- settings()->setAttribute(QWebEngineSettings::JavascriptCanOpenWindows, config.value("javascriptCanOpenWindows", true).toBool());
- settings()->setAttribute(QWebEngineSettings::JavascriptCanAccessClipboard, config.value("javascriptCanAccessClipboard", false).toBool());
- settings()->setAttribute(QWebEngineSettings::LinksIncludedInFocusChain, config.value("linksIncludedInFocusChain", true).toBool());
- settings()->setAttribute(QWebEngineSettings::LocalStorageEnabled, config.value("localStorageEnabled", true).toBool());
- settings()->setAttribute(QWebEngineSettings::LocalContentCanAccessRemoteUrls, config.value("localContentCanAccessRemoteUrls", false).toBool());
- settings()->setAttribute(QWebEngineSettings::XSSAuditingEnabled, config.value("xssAuditingEnabled", false).toBool());
- settings()->setAttribute(QWebEngineSettings::SpatialNavigationEnabled, config.value("spatialNavigationEnabled", false).toBool());
- settings()->setAttribute(QWebEngineSettings::LocalContentCanAccessFileUrls, config.value("localContentCanAccessFileUrls", true).toBool());
- settings()->setAttribute(QWebEngineSettings::HyperlinkAuditingEnabled, config.value("hyperlinkAuditingEnabled", false).toBool());
- settings()->setAttribute(QWebEngineSettings::ScrollAnimatorEnabled, config.value("scrollAnimatorEnabled", false).toBool());
- settings()->setAttribute(QWebEngineSettings::ErrorPageEnabled, config.value("errorPageEnabled", true).toBool());
-#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
- settings()->setAttribute(QWebEngineSettings::PluginsEnabled, config.value("pluginsEnabled", false).toBool());
- settings()->setAttribute(QWebEngineSettings::FullScreenSupportEnabled, config.value("fullscreenSupportEnabled", false).toBool());
-#endif
-#if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)
- settings()->setAttribute(QWebEngineSettings::ScreenCaptureEnabled, config.value("screenCaptureEnabled", false).toBool());
- settings()->setAttribute(QWebEngineSettings::WebGLEnabled, config.value("webglEnabled", true).toBool());
- settings()->setAttribute(QWebEngineSettings::Accelerated2dCanvasEnabled, config.value("accelerated2dCanvasEnabled", true).toBool());
- settings()->setAttribute(QWebEngineSettings::AutoLoadIconsForPage, config.value("autoLoadIconsForPage", true).toBool());
- settings()->setAttribute(QWebEngineSettings::TouchIconsEnabled, config.value("touchIconsEnabled", false).toBool());
-#endif
-#if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0)
- settings()->setAttribute(QWebEngineSettings::FocusOnNavigationEnabled, config.value("focusOnNavigationEnabled", true).toBool());
- settings()->setAttribute(QWebEngineSettings::PrintElementBackgrounds, config.value("printElementBackgrounds", true).toBool());
- settings()->setAttribute(QWebEngineSettings::AllowRunningInsecureContent, config.value("allowRunningInsecureContent", false).toBool());
-#endif
- config.endGroup(); // attributes
+ setHttpCacheMaximumSize(config.value("cacheSize").toInt());
+ config.endGroup(); // http
+
+ config.beginGroup("policy");
+ {
+ QString cookies = config.value("cookies").toString();
+ if(cookies == "disabled") {
+ setPersistentCookiesPolicy(NoPersistentCookies);
+ } else if(cookies == "allow") {
+ setPersistentCookiesPolicy(AllowPersistentCookies);
+ } else if(cookies == "force") {
+ setPersistentCookiesPolicy(ForcePersistentCookies);
+ }
+ }
+ config.endGroup(); // policy
+
+ config.beginGroup("attributes");
+ settings()->setAttribute(QWebEngineSettings::AutoLoadImages, config.value("autoLoadImages", true).toBool());
+ settings()->setAttribute(QWebEngineSettings::JavascriptEnabled, config.value("javascriptEnabled", true).toBool());
+ settings()->setAttribute(QWebEngineSettings::JavascriptCanOpenWindows, config.value("javascriptCanOpenWindows", true).toBool());
+ settings()->setAttribute(QWebEngineSettings::JavascriptCanAccessClipboard, config.value("javascriptCanAccessClipboard", false).toBool());
+ settings()->setAttribute(QWebEngineSettings::LinksIncludedInFocusChain, config.value("linksIncludedInFocusChain", true).toBool());
+ settings()->setAttribute(QWebEngineSettings::LocalStorageEnabled, config.value("localStorageEnabled", true).toBool());
+ settings()->setAttribute(QWebEngineSettings::LocalContentCanAccessRemoteUrls, config.value("localContentCanAccessRemoteUrls", false).toBool());
+ settings()->setAttribute(QWebEngineSettings::XSSAuditingEnabled, config.value("xssAuditingEnabled", false).toBool());
+ settings()->setAttribute(QWebEngineSettings::SpatialNavigationEnabled, config.value("spatialNavigationEnabled", false).toBool());
+ settings()->setAttribute(QWebEngineSettings::LocalContentCanAccessFileUrls, config.value("localContentCanAccessFileUrls", true).toBool());
+ settings()->setAttribute(QWebEngineSettings::HyperlinkAuditingEnabled, config.value("hyperlinkAuditingEnabled", false).toBool());
+ settings()->setAttribute(QWebEngineSettings::ScrollAnimatorEnabled, config.value("scrollAnimatorEnabled", false).toBool());
+ settings()->setAttribute(QWebEngineSettings::ErrorPageEnabled, config.value("errorPageEnabled", true).toBool());
+ settings()->setAttribute(QWebEngineSettings::PluginsEnabled, config.value("pluginsEnabled", false).toBool());
+ settings()->setAttribute(QWebEngineSettings::FullScreenSupportEnabled, config.value("fullscreenSupportEnabled", false).toBool());
+ settings()->setAttribute(QWebEngineSettings::ScreenCaptureEnabled, config.value("screenCaptureEnabled", false).toBool());
+ settings()->setAttribute(QWebEngineSettings::WebGLEnabled, config.value("webglEnabled", true).toBool());
+ settings()->setAttribute(QWebEngineSettings::Accelerated2dCanvasEnabled, config.value("accelerated2dCanvasEnabled", true).toBool());
+ settings()->setAttribute(QWebEngineSettings::AutoLoadIconsForPage, config.value("autoLoadIconsForPage", true).toBool());
+ settings()->setAttribute(QWebEngineSettings::TouchIconsEnabled, config.value("touchIconsEnabled", false).toBool());
+ settings()->setAttribute(QWebEngineSettings::FocusOnNavigationEnabled, config.value("focusOnNavigationEnabled", true).toBool());
+ settings()->setAttribute(QWebEngineSettings::PrintElementBackgrounds, config.value("printElementBackgrounds", true).toBool());
+ settings()->setAttribute(QWebEngineSettings::AllowRunningInsecureContent, config.value("allowRunningInsecureContent", false).toBool());
+ config.endGroup(); // attributes
+
+ } // QFile::exists(profilePath)
}
WebEngineProfile::~WebEngineProfile()
@@ -133,6 +130,11 @@ QUrl WebEngineProfile::homepage() const
return m_homepage;
}
+QUrl WebEngineProfile::newtab() const
+{
+ return m_newtab;
+}
+
void WebEngineProfile::saveProfile()
{
QSettings config(persistentStoragePath() + "/profile.ini", QSettings::IniFormat);