aboutsummaryrefslogtreecommitdiff
path: root/src/widgets/BrowserWindow.cpp
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2025-07-25 16:24:20 +0530
committerAkshay Nair <phenax5@gmail.com>2025-07-25 16:24:20 +0530
commit7e3b6182c4581fcb39ab1d0ef2eb07fe9fa1d8b6 (patch)
tree13808a26ad4e1f948d7fe0c042a2bdedb2658ee4 /src/widgets/BrowserWindow.cpp
parent43f3261635e1667367cfd31a2f746832e94c3957 (diff)
downloadnull-browser-7e3b6182c4581fcb39ab1d0ef2eb07fe9fa1d8b6.tar.gz
null-browser-7e3b6182c4581fcb39ab1d0ef2eb07fe9fa1d8b6.zip
Remove window mediator class
Diffstat (limited to 'src/widgets/BrowserWindow.cpp')
-rw-r--r--src/widgets/BrowserWindow.cpp28
1 files changed, 23 insertions, 5 deletions
diff --git a/src/widgets/BrowserWindow.cpp b/src/widgets/BrowserWindow.cpp
index 8e1555f..c565cb9 100644
--- a/src/widgets/BrowserWindow.cpp
+++ b/src/widgets/BrowserWindow.cpp
@@ -6,7 +6,6 @@
#include <QtCore>
#include "Configuration.hpp"
-#include "WindowMediator.hpp"
#include "keymap/KeymapEvaluator.hpp"
#include "widgets/BrowserWindow.hpp"
#include "widgets/WebViewStack.hpp"
@@ -23,7 +22,7 @@ BrowserWindow::BrowserWindow(const Configuration &configuration, QWebEngineProfi
centralWidget()->setLayout(layout);
// Stack of web views
- auto *webview_stack = new WebViewStack(&configuration, profile);
+ webview_stack = new WebViewStack(&configuration, profile, this);
layout->addWidget(webview_stack);
// Open webviews for given urls
@@ -40,16 +39,19 @@ BrowserWindow::BrowserWindow(const Configuration &configuration, QWebEngineProfi
keymap.define_mode("n", {.passthrough = false});
keymap.define_mode("i", {.passthrough = true});
- win_mediator = new WindowMediator(webview_stack);
-
// Update window title when webview changes
connect(webview_stack, &WebViewStack::current_webview_title_changed, this, [this](int index) {
- auto webviews = win_mediator->get_webview_list();
+ auto webviews = webview_stack->get_webview_list();
if (index >= 0 && index < webviews.count()) {
const auto &webview = webviews.at(index);
setWindowTitle(webview.title);
}
});
+
+ connect(webview_stack, &WebViewStack::new_window_requested, this,
+ &BrowserWindow::new_window_requested);
+ connect(webview_stack, &WebViewStack::close_window_requested, this,
+ &BrowserWindow::close_window_requested);
}
bool BrowserWindow::on_window_key_event(QKeyEvent *event) {
@@ -58,3 +60,19 @@ bool BrowserWindow::on_window_key_event(QKeyEvent *event) {
return should_skip;
}
+
+void BrowserWindow::update_user_agent(const QString &user_agent) {
+ auto *profile = webview_stack->get_profile();
+ profile->setHttpUserAgent(user_agent);
+}
+
+void BrowserWindow::update_downloads_dir(const QString &downloads_dir) {
+ auto *profile = webview_stack->get_profile();
+ profile->setDownloadPath(downloads_dir);
+}
+
+void BrowserWindow::update_permissions_persistance(const QString &persistance) {
+ auto *profile = webview_stack->get_profile();
+ auto persistance_policy = Configuration::to_permission_persistance_policy(persistance);
+ profile->setPersistentPermissionsPolicy(persistance_policy);
+}