aboutsummaryrefslogtreecommitdiff
path: root/src/widgets
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/widgets/WebViewStack.cpp22
-rw-r--r--src/widgets/WebViewStack.hpp4
2 files changed, 21 insertions, 5 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);
+}
diff --git a/src/widgets/WebViewStack.hpp b/src/widgets/WebViewStack.hpp
index f9ce397..03581e8 100644
--- a/src/widgets/WebViewStack.hpp
+++ b/src/widgets/WebViewStack.hpp
@@ -38,6 +38,7 @@ public:
WebViewId current_webview_id();
uint32_t count();
QUrl current_url();
+ void set_webview_url(const QUrl &url, WebViewId webview_id);
bool has_webview(WebViewId webview_id);
@@ -53,7 +54,8 @@ protected:
WebView *get_webview(WebViewId webview_id);
public slots:
- void open_url(const QUrl &url, OpenType open_type = OpenType::OpenUrl);
+ void open_url(const QUrl &url, OpenType open_type = OpenType::OpenUrl,
+ WebViewId webview_id = 0);
void webview_history_back(WebViewId webview_id, qsizetype history_index);
void webview_history_forward(WebViewId webview_id, qsizetype history_index);
void close(WebViewId webview_id);