summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2021-07-14 11:08:33 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-07-23 14:32:37 +0000
commitdae47317c1089a438a92d8080109bde43f14b540 (patch)
tree96cdd51c25990215c34beae7899d4375100bb834 /src
parent90f8de8f95c5151a4cd4d94b7da37e6b8bdd9014 (diff)
Add QWebEngineNewWindowRequest::openIn(QWebEnginePage *)
Makes for a nicer API Change-Id: I15e72d526e9cf6cf9ca8bd3e24f5dd7e7b2e9fa5 Reviewed-by: Kirill Burtsev <kirill.burtsev@qt.io> (cherry picked from commit 9285872b0dd4da8c0ba1dd8ef6c6822f85622f4e) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-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 17a790d9f..b69fdfb92 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)
{