aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/browser.cpp18
-rw-r--r--src/browser.h3
-rw-r--r--src/mainwindow.cpp3
-rw-r--r--src/mainwindow.h1
4 files changed, 18 insertions, 7 deletions
diff --git a/src/browser.cpp b/src/browser.cpp
index 75f7d50..9bf93e6 100644
--- a/src/browser.cpp
+++ b/src/browser.cpp
@@ -35,8 +35,10 @@ Browser::Browser(int &argc, char *argv[]) :
m_localServer = nullptr;
m_networkAccessManager = nullptr;
+ m_urlRequestInterceptor = nullptr;
m_bookmarksManager = nullptr;
m_downloadManager = nullptr;
+ m_blocklistManager = nullptr;
}
Browser::~Browser()
@@ -107,6 +109,7 @@ bool Browser::prepare(QStringList urls)
m_networkAccessManager = new QNetworkAccessManager();
m_bookmarksManager = new BookmarksWidget;
m_downloadManager = new DownloadsWidget;
+ m_blocklistManager = new BlockerManager;
QtWebEngine::initialize();
@@ -138,6 +141,11 @@ DownloadsWidget *Browser::downloads()
return m_downloadManager;
}
+BlockerManager *Browser::blocklists()
+{
+ return m_blocklistManager;
+}
+
void Browser::setConfigPath(const QString &path)
{
// set custom config path if any
@@ -203,10 +211,12 @@ WebEngineProfile* Browser::profile(const QString name)
m_profiles.insert(name, new WebEngineProfile(name, this));
}
- // TODO: UrlRequestInterceptor
- // UrlRequestInterceptor *interceptor = new UrlRequestInterceptor(this);
- // interceptor->setSubscription(blocklistManager);
- // m_profile->setRequestInterceptor(interceptor);
+ if(!m_urlRequestInterceptor) {
+ m_urlRequestInterceptor = new UrlRequestInterceptor(this);
+ m_urlRequestInterceptor->setSubscription(m_blocklistManager);
+ }
+
+ m_profiles[name]->setRequestInterceptor(m_urlRequestInterceptor);
connect(m_profiles[name], SIGNAL(downloadRequested(QWebEngineDownloadItem*)), downloads(), SLOT(addDownload(QWebEngineDownloadItem*)));
}
diff --git a/src/browser.h b/src/browser.h
index 1f50599..a2e6513 100644
--- a/src/browser.h
+++ b/src/browser.h
@@ -56,6 +56,7 @@ public:
QNetworkAccessManager *network();
BookmarksWidget *bookmarks();
DownloadsWidget *downloads();
+ BlockerManager *blocklists();
void setConfigPath(const QString &path);
void addWindow(MainWindow* window);
@@ -77,8 +78,10 @@ private:
QHash<QString, WebEngineProfile *> m_profiles;
QNetworkAccessManager *m_networkAccessManager;
+ UrlRequestInterceptor *m_urlRequestInterceptor;
BookmarksWidget *m_bookmarksManager;
DownloadsWidget *m_downloadManager;
+ BlockerManager *m_blocklistManager;
};
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 7f6cf0d..587b072 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -34,7 +34,6 @@
MainWindow::MainWindow(QUrl defaultUrl, QWidget *parent) :
QMainWindow(parent),
- blocklistManager(new BlockerManager(this)),
ui(new Ui::MainWindow),
navigationToolBar(new QToolBar(tr("Navigation"), this)),
tabToolBar(new QToolBar(tr("Tab bar"), this)),
@@ -74,7 +73,7 @@ MainWindow::MainWindow(QUrl defaultUrl, QWidget *parent) :
bookmarksAction->setParent(this);
bookmarksAction->setShortcut(QKeySequence(sSettings->value("bookmarks.dialogShortcut").toString()));
toolsMenu->addSeparator();
- toolsMenu->addAction(tr("Blocker"), blocklistManager, SLOT(show()), QKeySequence::fromString(sSettings->value("blocker.shortcut").toString()));
+ toolsMenu->addAction(tr("Blocker"), qApp->blocklists(), SLOT(show()), QKeySequence::fromString(sSettings->value("blocker.shortcut").toString()));
// Profile menu
QMenu *profileMenu = new QMenu(tr("Profile"), menuBar);
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 2456490..a2f365c 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -68,7 +68,6 @@ private slots:
void handleTitleUpdated(const QString &title);
private:
- BlockerManager *blocklistManager;
WebEngineProfile *m_profile = nullptr;
// ui