| 299 | } |
| 300 | |
| 301 | QWebEngineView* CFrmWebBrowser::CreateWindow( |
| 302 | QWebEnginePage::WebWindowType type, bool offTheRecord) |
| 303 | { |
| 304 | qDebug(log) << "Create window:" << type; |
| 305 | |
| 306 | CFrmWebView* pView = nullptr; |
| 307 | switch (type) { |
| 308 | case QWebEnginePage::WebBrowserTab: { |
| 309 | auto pTab = CreateTab(&pView, offTheRecord); |
| 310 | if(!pTab || !m_pTab) break; |
| 311 | int index = m_pTab->addTab(pTab, pView->favIcon(), tr("New page")); |
| 312 | if(-1 < index) |
| 313 | m_pTab->setCurrentIndex(index); |
| 314 | break; |
| 315 | } |
| 316 | case QWebEnginePage::WebBrowserBackgroundTab: { |
| 317 | auto pTab = CreateTab(&pView, offTheRecord); |
| 318 | if(!pTab || !m_pTab) break; |
| 319 | int index = m_pTab->currentIndex(); |
| 320 | m_pTab->addTab(pTab, pView->favIcon(), tr("New page")); |
| 321 | if(-1 < index && index != m_pTab->currentIndex()) |
| 322 | m_pTab->setCurrentIndex(index); |
| 323 | break; |
| 324 | } |
| 325 | case QWebEnginePage::WebBrowserWindow: { |
| 326 | auto pWin = new CFrmWebBrowser(m_pPara, true); |
| 327 | if(pWin) { |
| 328 | pView = qobject_cast<CFrmWebView*>( |
| 329 | pWin->CreateWindow(QWebEnginePage::WebBrowserTab)); |
| 330 | pWin->setAttribute(Qt::WA_DeleteOnClose); |
| 331 | auto pMainWin = RabbitCommon::CTools::GetMainWindow(); |
| 332 | if(pMainWin) |
| 333 | pWin->resize(pMainWin->frameGeometry().width(), |
| 334 | pMainWin->frameGeometry().height()); |
| 335 | pWin->show(); |
| 336 | } |
| 337 | break; |
| 338 | } |
| 339 | case QWebEnginePage::WebDialog: { |
| 340 | // Test: Resource\html\TestQWebEnginePageWebDialog.html |
| 341 | auto popup = new CFrmPopup(GetProfile(offTheRecord), this); |
| 342 | pView = popup->GetView(); |
| 343 | } |
| 344 | } |
| 345 | |
| 346 | return pView; |
| 347 | } |
| 348 | |
| 349 | void CFrmWebBrowser::SetConnect(CFrmWebView* pWeb) |
| 350 | { |
no test coverage detected