From bcecbced7e1af9d99443a7e823f18328c7943f09 Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Sat, 29 Mar 2025 11:45:18 +0530 Subject: Add window action router for multi-window --- src/widgets/WebViewStack.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/widgets/WebViewStack.cpp') diff --git a/src/widgets/WebViewStack.cpp b/src/widgets/WebViewStack.cpp index aee4af9..f1c799f 100644 --- a/src/widgets/WebViewStack.cpp +++ b/src/widgets/WebViewStack.cpp @@ -36,7 +36,7 @@ void WebViewStack::open_url(const QUrl &url, OpenType open_type) { } WebView *WebViewStack::create_new_webview(const QUrl &url, bool focus) { - auto *webview = new WebView(next_id++, profile); + auto *webview = new WebView(next_webview_id++, profile); webview->setUrl(url); layout->addWidget(webview); webview_list.append(webview); @@ -77,6 +77,9 @@ void WebViewStack::on_new_webview_request( } int32_t WebViewStack::get_webview_index(WebViewId webview_id) { + if (webview_id == 0 && window()->isActiveWindow()) + webview_id = current_webview_id(); + int index = 0; for (auto &webview : webview_list) { if (webview->get_id() == webview_id) @@ -177,6 +180,10 @@ WebView *WebViewStack::get_webview(WebViewId webview_id) { return webview_list.at(webview_index); } +bool WebViewStack::has_webview(WebViewId webview_id) { + return get_webview(webview_id) != nullptr; +} + QUrl WebViewStack::current_url() { auto *webview = current_webview(); if (webview == nullptr) { -- cgit v1.3.1