aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2018-06-07 13:03:47 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2018-06-07 13:03:47 +0200
commit7707fb4ed8ad8c951d9f41ce39823093d30a9f67 (patch)
treea70e08ba2d03afb68109ea89f370f8873e3645f5 /src
parentDon't copy profiles into profile manager plugin (diff)
downloadsmolbote-7707fb4ed8ad8c951d9f41ce39823093d30a9f67.tar.xz
Split webengine/webprofile into lib/web
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt7
-rw-r--r--src/browser.cpp2
-rw-r--r--src/mainwindow/subwindow.cpp2
-rw-r--r--src/webengine/webprofile.cpp148
-rw-r--r--src/webengine/webprofile.h114
-rw-r--r--src/webengine/widgets/pagemenu.cpp2
6 files changed, 6 insertions, 269 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d0ac915..0c6876d 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -33,8 +33,6 @@ add_executable(poi
# webengine
webengine/urlinterceptor.cpp
webengine/urlinterceptor.h
- webengine/webprofile.cpp
- webengine/webprofile.h
webengine/webpage.cpp
webengine/webpage.h
webengine/webview.cpp
@@ -51,7 +49,8 @@ add_executable(poi
target_include_directories(poi
PRIVATE ${Boost_INCLUDE_DIRS}
PRIVATE ../lib ../plugins
- PRIVATE ../lib/configuration)
+ PRIVATE ../lib/configuration
+ PRIVATE ../lib/web)
target_link_libraries(poi
Qt5::Core Qt5::Widgets Qt5::Concurrent Qt5::WebEngineWidgets
@@ -59,7 +58,7 @@ target_link_libraries(poi
about
addressbar
configuration
- bookmarks downloads)
+ bookmarks downloads web)
target_compile_definitions(poi
PRIVATE QTBUG_65223_WORKAROUND
diff --git a/src/browser.cpp b/src/browser.cpp
index 11feac0..bb29ff7 100644
--- a/src/browser.cpp
+++ b/src/browser.cpp
@@ -11,7 +11,7 @@
#include "mainwindow/mainwindow.h"
#include "mainwindow/subwindow.h"
#include "webengine/urlinterceptor.h"
-#include "webengine/webprofile.h"
+#include <webprofile.h>
#include <QAction>
#include <bookmarks/bookmarkswidget.h>
#include <configuration/configuration.h>
diff --git a/src/mainwindow/subwindow.cpp b/src/mainwindow/subwindow.cpp
index 17a2268..c282dd9 100644
--- a/src/mainwindow/subwindow.cpp
+++ b/src/mainwindow/subwindow.cpp
@@ -8,7 +8,7 @@
#include "subwindow.h"
#include "browser.h"
-#include "webengine/webprofile.h"
+#include <webprofile.h>
#include "webengine/webview.h"
#include "widgets/tabwidget.h"
#include <QAction>
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 <QFileInfo>
-#include <QSettings>
-#include <QWebEngineCookieStore>
-#include <QWebEngineSettings>
-
-WebProfile *WebProfile::profile = nullptr;
-
-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;
-
-#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<QWebEngineSettings::WebAttribute>(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());
-}
diff --git a/src/webengine/webprofile.h b/src/webengine/webprofile.h
deleted file mode 100644
index 31c5b44..0000000
--- a/src/webengine/webprofile.h
+++ /dev/null
@@ -1,114 +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
- */
-
-#ifndef SMOLBOTE_WEBENGINEPROFILE_H
-#define SMOLBOTE_WEBENGINEPROFILE_H
-
-#include <QHash>
-#include <QUrl>
-#include <QString>
-#include <QWebEngineProfile>
-
-class WebProfile : public QWebEngineProfile
-{
- Q_OBJECT
-
- Q_PROPERTY(QString search READ search WRITE setSearch NOTIFY searchChanged)
- Q_PROPERTY(QUrl homepage READ homepage WRITE setHomepage NOTIFY homepageChanged)
- Q_PROPERTY(QUrl newtab READ newtab WRITE setNewtab NOTIFY newtabChanged)
-
- // QWebEngineProfile should-be properties
- Q_PROPERTY(QString cachePath READ cachePath WRITE setCachePath NOTIFY cachePathChanged)
- Q_PROPERTY(QString persistentStoragePath READ persistentStoragePath WRITE setPersistentStoragePath NOTIFY persistentStoragePathChanged)
-
- Q_PROPERTY(QString httpAcceptLanguage READ httpAcceptLanguage WRITE setHttpAcceptLanguage NOTIFY httpAcceptLanguageChanged)
- Q_PROPERTY(int httpCacheMaximumSize READ httpCacheMaximumSize WRITE setHttpCacheMaximumSize NOTIFY httpCacheMaximumSizeChanged)
- Q_PROPERTY(QString httpUserAgent READ httpUserAgent WRITE setHttpUserAgent NOTIFY httpUserAgentChanged)
-
- Q_PROPERTY(bool spellCheckEnabled READ isSpellCheckEnabled WRITE setSpellCheckEnabled NOTIFY spellCheckEnabledChanged)
-
-public:
- // off-the-record constructor
- explicit WebProfile(QObject *parent = nullptr);
- // default constructor
- explicit WebProfile(const QString &name, QObject *parent = nullptr);
-
- ~WebProfile() = default;
-
- static void setDefaultProfile(WebProfile *profile)
- {
- Q_CHECK_PTR(profile);
- WebProfile::profile = profile;
- }
- static WebProfile *defaultProfile()
- {
- Q_CHECK_PTR(WebProfile::profile);
- return WebProfile::profile;
- }
-
- QString name() const
- {
- return m_name;
- }
-
- // search url
- QString search() const;
- void setSearch(const QString &url);
-
- // homepage url
- QUrl homepage() const;
- void setHomepage(const QUrl &url);
-
- // new tab url
- QUrl newtab() const;
- void setNewtab(const QUrl &url);
-
- void setCachePath(const QString &path);
- void setPersistentStoragePath(const QString &path);
-
- void setHttpAcceptLanguage(const QString &httpAcceptLanguage);
- void setHttpCacheMaximumSize(int maxSize);
- void setHttpUserAgent(const QString &userAgent);
-
- void setSpellCheckEnabled(bool enable);
-
- void addBookmark(const QString &title, const QString &url)
- {
- if(!title.isEmpty() && !url.isEmpty())
- emit addBookmarkRequested(title, url);
- }
-
-signals:
- void addBookmarkRequested(const QString &title, const QString &url);
-
- void searchChanged(const QString &url);
- void homepageChanged(const QUrl &url);
- void newtabChanged(const QUrl &url);
-
- void cachePathChanged(const QString &path);
- void persistentStoragePathChanged(const QString &path);
-
- void httpAcceptLanguageChanged(const QString &httpAcceptLanguage);
- void httpCacheMaximumSizeChanged(int maxSize);
- void httpUserAgentChanged(const QString &userAgent);
-
- void spellCheckEnabledChanged(bool enable);
-
-private:
- static WebProfile *profile;
-
- QString m_name;
- QString m_search = QString("about:blank");
- QUrl m_homepage = QUrl("about:blank");
- QUrl m_newtab = QUrl("about:blank");
-};
-
-void loadProfile(WebProfile *profile, const QHash<QString, QString> &defaults, const QString &path);
-//WebProfile *saveProfile(WebProfile *profile, const QString &path);
-
-#endif // SMOLBOTE_WEBENGINEPROFILE_H
diff --git a/src/webengine/widgets/pagemenu.cpp b/src/webengine/widgets/pagemenu.cpp
index dc104e6..c435d34 100644
--- a/src/webengine/widgets/pagemenu.cpp
+++ b/src/webengine/widgets/pagemenu.cpp
@@ -8,7 +8,7 @@
#include "pagemenu.h"
#include "../webview.h"
-#include "webengine/webprofile.h"
+#include <webprofile.h>
#include <QFileDialog>
#include <QLabel>
#include <QPrintDialog>