From 7707fb4ed8ad8c951d9f41ce39823093d30a9f67 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Thu, 7 Jun 2018 13:03:47 +0200 Subject: Split webengine/webprofile into lib/web --- src/webengine/webprofile.cpp | 148 ------------------------------------------- 1 file changed, 148 deletions(-) delete mode 100644 src/webengine/webprofile.cpp (limited to 'src/webengine/webprofile.cpp') diff --git a/src/webengine/webprofile.cpp b/src/webengine/webprofile.cpp deleted file mode 100644 index b40a98c..0000000 --- a/src/webengine/webprofile.cpp +++ /dev/null @@ -1,148 +0,0 @@ -/* - * This file is part of smolbote. It's copyrighted by the contributors recorded - * in the version control history of the file, available from its original - * location: https://neueland.iserlohn-fortress.net/smolbote.hg - * - * SPDX-License-Identifier: GPL-3.0 - */ - -#include "webprofile.h" -#include -#include -#include -#include - -WebProfile *WebProfile::profile = nullptr; - -void loadProfile(WebProfile *profile, const QHash &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; - -#ifdef QT_DEBUG - qDebug("+ Reading config for profile '%s': %s", qUtf8Printable(profile->name()), qUtf8Printable(path)); -#endif - QSettings config(path, QSettings::IniFormat); - - config.beginGroup("properties"); - { - const auto keys = config.childKeys(); - for(const QString &key : keys) { -#ifdef QT_DEBUG - qDebug("- set property %s to %s", qUtf8Printable(key), qUtf8Printable(config.value(key).toString())); -#endif - profile->setProperty(qUtf8Printable(key), config.value(key)); - } - } - config.endGroup(); // properties - - config.beginGroup("attributes"); - { - const auto keys = config.childKeys(); - auto *settings = profile->settings(); - for(const QString &key : keys) { -#ifdef QT_DEBUG - qDebug("- set attribute %s to %s", qUtf8Printable(key), qUtf8Printable(config.value(key).toString())); -#endif - auto attribute = static_cast(key.toInt()); - settings->setAttribute(attribute, config.value(key).toBool()); - } - } - config.endGroup(); -} - -WebProfile::WebProfile(QObject *parent) - : QWebEngineProfile(parent) -{ - m_name = tr("Off-the-record"); - -#ifdef QT_DEBUG - qDebug("Creating off-the-record profile"); -#endif -} - -WebProfile::WebProfile(const QString &name, QObject *parent) - : QWebEngineProfile(name, parent) -{ - m_name = name; - -#ifdef QT_DEBUG - qDebug("Creating profile %s", qUtf8Printable(m_name)); -#endif -} - -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()); -} -- cgit v1.2.1