summaryrefslogtreecommitdiffstats
path: root/src/core/api
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2021-07-14 11:08:33 +0200
committerKirill Burtsev <kirill.burtsev@qt.io>2021-07-21 19:15:19 +0000
commit9285872b0dd4da8c0ba1dd8ef6c6822f85622f4e (patch)
tree89194159f0aefa6976781e4b62709dd21fe9a181 /src/core/api
parentd031aa1a539d252bf674323f6757fe0c7e5c0011 (diff)
Add QWebEngineNewWindowRequest::openIn(QWebEnginePage *)
Makes for a nicer API Pick-to: 6.2 Change-Id: I15e72d526e9cf6cf9ca8bd3e24f5dd7e7b2e9fa5 Reviewed-by: Kirill Burtsev <kirill.burtsev@qt.io>
Diffstat (limited to 'src/core/api')
-rw-r--r--src/core/api/qwebenginenewwindowrequest.cpp16
-rw-r--r--src/core/api/qwebenginenewwindowrequest.h3
-rw-r--r--src/core/api/qwebenginepage.cpp8
3 files changed, 22 insertions, 5 deletions
diff --git a/src/core/api/qwebenginenewwindowrequest.cpp b/src/core/api/qwebenginenewwindowrequest.cpp
index 7d2762e1c..1322bb4dd 100644
--- a/src/core/api/qwebenginenewwindowrequest.cpp
+++ b/src/core/api/qwebenginenewwindowrequest.cpp
@@ -40,6 +40,8 @@
#include "qwebenginenewwindowrequest.h"
#include "qwebenginenewwindowrequest_p.h"
+#include "qwebenginepage.h"
+
#include "web_contents_adapter.h"
QT_BEGIN_NAMESPACE
@@ -172,4 +174,18 @@ bool QWebEngineNewWindowRequest::isUserInitiated() const
return d_ptr->isUserInitiated;
}
+/*!
+ Opens the requested window in the view represented by \a page.
+
+ \sa QWebEnginePage::newWindowRequested
+*/
+void QWebEngineNewWindowRequest::openIn(QWebEnginePage *page)
+{
+ if (!page) {
+ qWarning("Trying to open a QWebEngineNewWindowRequest in an invalid QWebEnginePage.");
+ return;
+ }
+ page->acceptAsNewWindow(*this);
+}
+
QT_END_NAMESPACE
diff --git a/src/core/api/qwebenginenewwindowrequest.h b/src/core/api/qwebenginenewwindowrequest.h
index 4066f1a65..8fd35ad6f 100644
--- a/src/core/api/qwebenginenewwindowrequest.h
+++ b/src/core/api/qwebenginenewwindowrequest.h
@@ -53,6 +53,7 @@ class WebContentsAdapter;
QT_BEGIN_NAMESPACE
+class QWebEnginePage;
struct QWebEngineNewWindowRequestPrivate;
class Q_WEBENGINECORE_EXPORT QWebEngineNewWindowRequest : public QObject
@@ -78,6 +79,8 @@ public:
QRect requestedGeometry() const;
bool isUserInitiated() const;
+ void openIn(QWebEnginePage *);
+
protected:
QWebEngineNewWindowRequest(DestinationType, const QRect &, const QUrl &, bool,
QSharedPointer<QtWebEngineCore::WebContentsAdapter>,
diff --git a/src/core/api/qwebenginepage.cpp b/src/core/api/qwebenginepage.cpp
index 4caa9d1cd..c17276a1f 100644
--- a/src/core/api/qwebenginepage.cpp
+++ b/src/core/api/qwebenginepage.cpp
@@ -2225,18 +2225,16 @@ QSizeF QWebEnginePage::contentsSize() const
while holding Shift, Ctrl, or a built-in combination that triggers the page to open
in a new window.
- The signal is handled by calling acceptAsNewWindow() on the destination page.
+ The signal is handled by calling openIn() with the new page on the request.
If this signal is not handled, the requested load will fail.
\note This signal is not emitted if \l createWindow() handled the request first.
- \sa createWindow()
+ \sa createWindow(), QWebEngineNewWindowRequest::openIn()
*/
/*!
- Handles the newWindowRequested() signal by opening the \a request in this page.
- \since 6.2
- \sa newWindowRequested()
+ \internal
*/
void QWebEnginePage::acceptAsNewWindow(QWebEngineNewWindowRequest &request)
{