aboutsummaryrefslogtreecommitdiff
path: root/src/browser.cpp
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2017-12-11 18:16:50 +0100
committerAqua-sama <aqua@iserlohn-fortress.net>2017-12-11 18:16:50 +0100
commite25c011d5db32104ccdb3e8949082345efdba805 (patch)
treefb1892f8ae292a088638abaf158d086216106ad2 /src/browser.cpp
parentFixed new window action (diff)
downloadsmolbote-e25c011d5db32104ccdb3e8949082345efdba805.tar.xz
Simple filterlist
Diffstat (limited to 'src/browser.cpp')
-rw-r--r--src/browser.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/browser.cpp b/src/browser.cpp
index 354b179..82972dd 100644
--- a/src/browser.cpp
+++ b/src/browser.cpp
@@ -21,6 +21,7 @@
#include "browser.h"
#include <bookmarks/bookmarkswidget.h>
#include <downloads/downloadswidget.h>
+#include "webengine/urlinterceptor.h"
#include "mainwindow.h"
#include <QtWebEngine>
#include <QDir>
@@ -39,8 +40,12 @@ Browser::Browser(int &argc, char *argv[]) :
Browser::~Browser()
{
+ // TODO: fix crash here
// qDeleteAll(m_windows);
// m_windows.clear();
+
+// qDeleteAll(m_profiles);
+// m_profiles.clear();
}
void Browser::setConfiguration(std::shared_ptr<Configuration> &config)
@@ -49,6 +54,8 @@ void Browser::setConfiguration(std::shared_ptr<Configuration> &config)
m_bookmarksManager = std::make_shared<BookmarksWidget>(QString::fromStdString(m_config->value<std::string>("bookmarks.path").value()));
m_downloadManager = std::make_shared<DownloadsWidget>(QString::fromStdString(m_config->value<std::string>("downloads.path").value()));
+ m_urlRequestInterceptor = std::make_shared<UrlRequestInterceptor>(QString::fromStdString(m_config->value<std::string>("browser.filterPath").value()));
+
}
void Browser::loadProfiles()
@@ -66,11 +73,15 @@ void Browser::loadProfiles()
const QStringList profileList = profileDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
for(const QString &name : profileList) {
- m_profiles.insert(name, new WebEngineProfile(name, profileDir.absoluteFilePath(name), this));
+ WebEngineProfile *profile = new WebEngineProfile(name, profileDir.absoluteFilePath(name), this);
+ profile->setRequestInterceptor(m_urlRequestInterceptor.get());
+ m_profiles.insert(name, profile);
}
// Also add the Off-the-record profile
- m_profiles.insert("", new WebEngineProfile(this));
+ WebEngineProfile *otr = new WebEngineProfile(this);
+ otr->setRequestInterceptor(m_urlRequestInterceptor.get());
+ m_profiles.insert("", otr);
// set default profile
m_defaultProfile = m_profiles[QString::fromStdString(m_config->value<std::string>("browser.profile").value())];