diff --git a/examples/webenginewidgets/browser/webview.cpp b/examples/webenginewidgets/browser/webview.cpp index 193cb47977356c666f47927ce961f2d389e543c1..6fdf316bd41557deb7a57a2734bdc9cf3d8b169a 100644 --- a/examples/webenginewidgets/browser/webview.cpp +++ b/examples/webenginewidgets/browser/webview.cpp @@ -175,11 +175,10 @@ QWebEnginePage *WebPage::createWindow(QWebEnginePage::WebWindowType type) { if (m_keyboardModifiers & Qt::ControlModifier || m_pressedButtons == Qt::MidButton) m_openInNewTab = true; - if (m_openInNewTab) { + if (m_openInNewTab || type == QWebEnginePage::WebBrowserTab) { m_openInNewTab = false; return mainWindow()->tabWidget()->newTab()->page(); - } - if (type == QWebEnginePage::WebBrowserWindow) { + } else if (type == QWebEnginePage::WebBrowserWindow) { BrowserApplication::instance()->newMainWindow(); BrowserMainWindow *mainWindow = BrowserApplication::instance()->mainWindow(); return mainWindow->currentTab()->page(); diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp index 04f24c62a441b7465119131d32aff90c145454ed..80f780dde14625a8a65924056b8695489a5bb4f4 100644 --- a/src/webenginewidgets/api/qwebenginepage.cpp +++ b/src/webenginewidgets/api/qwebenginepage.cpp @@ -46,6 +46,21 @@ QT_BEGIN_NAMESPACE +static QWebEnginePage::WebWindowType toWindowType(WebContentsAdapterClient::WindowOpenDisposition disposition) +{ + switch (disposition) { + case WebContentsAdapterClient::NewForegroundTabDisposition: + case WebContentsAdapterClient::NewBackgroundTabDisposition: + return QWebEnginePage::WebBrowserTab; + case WebContentsAdapterClient::NewPopupDisposition: + return QWebEnginePage::WebDialog; + case WebContentsAdapterClient::NewWindowDisposition: + return QWebEnginePage::WebBrowserWindow; + default: + Q_UNREACHABLE(); + } +} + CallbackDirectory::~CallbackDirectory() { // "Cancel" pending callbacks by calling them with an invalid value. @@ -245,7 +260,7 @@ void QWebEnginePagePrivate::adoptNewWindow(WebContentsAdapter *newWebContents, W { Q_Q(QWebEnginePage); Q_UNUSED(userGesture); - QWebEnginePage *newPage = q->createWindow(disposition == WebContentsAdapterClient::NewPopupDisposition ? QWebEnginePage::WebModalDialog : QWebEnginePage::WebBrowserWindow); + QWebEnginePage *newPage = q->createWindow(toWindowType(disposition)); // Overwrite the new page's WebContents with ours. if (newPage && newPage->d_func() != this) { newPage->d_func()->adapter = newWebContents; diff --git a/src/webenginewidgets/api/qwebenginepage.h b/src/webenginewidgets/api/qwebenginepage.h index fcec92f85bebec2249a873e45194a785ab803835..eea7b52d269d2a986a07df3569fdca919ac04aca 100644 --- a/src/webenginewidgets/api/qwebenginepage.h +++ b/src/webenginewidgets/api/qwebenginepage.h @@ -261,7 +261,8 @@ public: enum WebWindowType { WebBrowserWindow, - WebModalDialog + WebBrowserTab, + WebDialog }; enum PermissionPolicy { diff --git a/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc b/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc index 54569bdc5b505a14e5497ee224655c4cd70a8a6f..225ad5a483f543e88e8f27e6da11af30e5187734 100644 --- a/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc +++ b/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc @@ -279,8 +279,9 @@ This enum describes the types of window that can be created by the createWindow() function. - \value WebBrowserWindow The window is a regular web browser window. - \value WebModalDialog The window acts as modal dialog. + \value WebBrowserWindow The page should be opened in a complete web browser window. + \value WebBrowserTab The page should be opened as a web browser tab. + \value WebDialog The page should be opened in a window without decoration. */ /*!