aboutsummaryrefslogtreecommitdiff
path: root/src/webengine/webprofile.cpp
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2018-06-05 18:07:27 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2018-06-05 18:07:27 +0200
commit0f41f33263b7d09b1cac3b66beb4b3c5931f68ce (patch)
tree284aacbb197520ea7092ea0172531aea188b6336 /src/webengine/webprofile.cpp
parentAdd QString cast to Configuration::value (diff)
downloadsmolbote-0f41f33263b7d09b1cac3b66beb4b3c5931f68ce.tar.xz
Fix clazy warnings in WebProfile
- add missing notify signals - add more properties - apply defaults to all profiles - update manpage
Diffstat (limited to 'src/webengine/webprofile.cpp')
-rw-r--r--src/webengine/webprofile.cpp112
1 files changed, 76 insertions, 36 deletions
diff --git a/src/webengine/webprofile.cpp b/src/webengine/webprofile.cpp
index 5b07645..b40a98c 100644
--- a/src/webengine/webprofile.cpp
+++ b/src/webengine/webprofile.cpp
@@ -14,8 +14,14 @@
WebProfile *WebProfile::profile = nullptr;
-void loadProfile(WebProfile *profile, const QString &path)
+void loadProfile(WebProfile *profile, const QHash<QString, QString> &defaults, const QString &path)
{
+ Q_CHECK_PTR(profile);
+
+ profile->setSearch(defaults.value("profile.search"));
+ profile->setHomepage(QUrl::fromUserInput(defaults.value("profile.homepage")));
+ profile->setNewtab(QUrl::fromUserInput(defaults.value("profile.newtab")));
+
// return if there is no config file
if(!QFileInfo::exists(path))
return;
@@ -50,38 +56,9 @@ void loadProfile(WebProfile *profile, const QString &path)
}
}
config.endGroup();
-
-// config.beginGroup("http");
-// setHttpUserAgent(config.value("userAgent", httpUserAgent()).toString());
-// setHttpAcceptLanguage(config.value("accept-lang", httpAcceptLanguage()).toString());
-// {
-// QString cacheType = config.value("cacheType").toString();
-// if(cacheType == "memory") {
-// setHttpCacheType(QWebEngineProfile::MemoryHttpCache);
-// } else if(cacheType == "disk") {
-// setHttpCacheType(QWebEngineProfile::DiskHttpCache);
-// } else if(cacheType == "disabled") {
-// setHttpCacheType(QWebEngineProfile::NoCache);
-// }
-// }
-// setHttpCacheMaximumSize(config.value("cacheSize", httpCacheMaximumSize()).toInt());
-// config.endGroup(); // http
-
-// config.beginGroup("policy");
-// {
-// QString cookies = config.value("cookies").toString();
-// if(cookies == "disabled") {
-// setPersistentCookiesPolicy(QWebEngineProfile::NoPersistentCookies);
-// } else if(cookies == "allow") {
-// setPersistentCookiesPolicy(QWebEngineProfile::AllowPersistentCookies);
-// } else if(cookies == "force") {
-// setPersistentCookiesPolicy(QWebEngineProfile::ForcePersistentCookies);
-// }
-// }
-// config.endGroup(); // policy
}
-WebProfile::WebProfile(const QHash<QString, QString> &defaults, QObject *parent)
+WebProfile::WebProfile(QObject *parent)
: QWebEngineProfile(parent)
{
m_name = tr("Off-the-record");
@@ -89,10 +66,6 @@ WebProfile::WebProfile(const QHash<QString, QString> &defaults, QObject *parent)
#ifdef QT_DEBUG
qDebug("Creating off-the-record profile");
#endif
-
- m_search = defaults.value("profile.search");
- m_homepage = QUrl::fromUserInput(defaults.value("profile.homepage"));
- m_newtab = QUrl::fromUserInput(defaults.value("profile.newtab"));
}
WebProfile::WebProfile(const QString &name, QObject *parent)
@@ -105,4 +78,71 @@ WebProfile::WebProfile(const QString &name, QObject *parent)
#endif
}
-WebProfile::~WebProfile() = default;
+QString WebProfile::search() const
+{
+ return m_search;
+}
+
+void WebProfile::setSearch(const QString &url)
+{
+ m_search = url;
+ emit searchChanged(m_search);
+}
+
+QUrl WebProfile::homepage() const
+{
+ return m_homepage;
+}
+
+void WebProfile::setHomepage(const QUrl &url)
+{
+ m_homepage = url;
+ emit homepageChanged(m_homepage);
+}
+
+QUrl WebProfile::newtab() const
+{
+ return m_newtab;
+}
+
+void WebProfile::setNewtab(const QUrl &url)
+{
+ m_newtab = url;
+ emit newtabChanged(m_newtab);
+}
+
+void WebProfile::setCachePath(const QString &path)
+{
+ QWebEngineProfile::setCachePath(path);
+ emit cachePathChanged(QWebEngineProfile::cachePath());
+}
+
+void WebProfile::setPersistentStoragePath(const QString &path)
+{
+ QWebEngineProfile::setPersistentStoragePath(path);
+ emit persistentStoragePathChanged(QWebEngineProfile::persistentStoragePath());
+}
+
+void WebProfile::setHttpAcceptLanguage(const QString &httpAcceptLanguage)
+{
+ QWebEngineProfile::setHttpAcceptLanguage(httpAcceptLanguage);
+ emit httpAcceptLanguageChanged(QWebEngineProfile::httpAcceptLanguage());
+}
+
+void WebProfile::setHttpCacheMaximumSize(int maxSize)
+{
+ QWebEngineProfile::setHttpCacheMaximumSize(maxSize);
+ emit httpCacheMaximumSizeChanged(QWebEngineProfile::httpCacheMaximumSize());
+}
+
+void WebProfile::setHttpUserAgent(const QString &userAgent)
+{
+ QWebEngineProfile::setHttpUserAgent(userAgent);
+ emit httpUserAgentChanged(QWebEngineProfile::httpUserAgent());
+}
+
+void WebProfile::setSpellCheckEnabled(bool enable)
+{
+ QWebEngineProfile::setSpellCheckEnabled(enable);
+ emit spellCheckEnabledChanged(QWebEngineProfile::isSpellCheckEnabled());
+}