diff options
| author | Akshay Nair <phenax5@gmail.com> | 2025-03-29 12:19:15 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2025-03-29 12:20:11 +0530 |
| commit | ed15eba453b7ddd0f4962c2d381fe40751973131 (patch) | |
| tree | 29f8dea45aeb882adfe600b24d789d24da7354dc /src/widgets/WebViewStack.cpp | |
| parent | bcecbced7e1af9d99443a7e823f18328c7943f09 (diff) | |
| download | null-browser-ed15eba453b7ddd0f4962c2d381fe40751973131.tar.gz null-browser-ed15eba453b7ddd0f4962c2d381fe40751973131.zip | |
Handle default for webview id
Diffstat (limited to '')
| -rw-r--r-- | src/widgets/WebViewStack.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/widgets/WebViewStack.cpp b/src/widgets/WebViewStack.cpp index f1c799f..6265855 100644 --- a/src/widgets/WebViewStack.cpp +++ b/src/widgets/WebViewStack.cpp @@ -18,10 +18,11 @@ WebViewStack::WebViewStack(const Configuration *configuration, create_new_webview(configuration->new_tab_url, true); } -void WebViewStack::open_url(const QUrl &url, OpenType open_type) { +void WebViewStack::open_url(const QUrl &url, OpenType open_type, + WebViewId webview_id) { switch (open_type) { case OpenType::OpenUrl: - set_current_url(url); + set_webview_url(url, webview_id); break; case OpenType::OpenUrlInTab: create_new_webview(url, true); @@ -77,8 +78,12 @@ 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(); + if (webview_id == 0) { + if (window()->isActiveWindow()) + webview_id = current_webview_id(); + else + return -1; + } int index = 0; for (auto &webview : webview_list) { @@ -203,3 +208,12 @@ void WebViewStack::set_current_url(const QUrl &url) { webview->setUrl(url); } +void WebViewStack::set_webview_url(const QUrl &url, WebViewId webview_id) { + auto *webview = get_webview(webview_id); + if (webview == nullptr) { + qDebug() << "No current webview"; + return; + } + + webview->setUrl(url); +} |
