File qtwebengine-2-createWindow.patch of Package kchmviewer
From 0c2e2503de5821bda2bb2a006982a7f41bc84cd2 Mon Sep 17 00:00:00 2001
From: "i.Dark_Templar" <darktemplar@dark-templar-archives.net>
Date: Fri, 11 Jun 2021 20:39:05 +0300
Subject: [PATCH 2/3] qtwebengine: implement opening additional windows except
for dialogs
---
src/viewwindow_webengine.cpp | 30 ++++++++++++++++++++++++++++++
src/viewwindow_webengine.h | 2 ++
2 files changed, 32 insertions(+)
diff --git a/src/viewwindow_webengine.cpp b/src/viewwindow_webengine.cpp
index 34f3396..df3859f 100644
--- a/src/viewwindow_webengine.cpp
+++ b/src/viewwindow_webengine.cpp
@@ -290,6 +290,36 @@ void ViewWindow::contextMenuEvent(QContextMenuEvent *e)
delete m;
}
+QWebEngineView *ViewWindow::createWindow(QWebEnginePage::WebWindowType type)
+{
+ QWebEngineView *tab = nullptr;
+
+ switch (type)
+ {
+ case QWebEnginePage::WebBrowserWindow:
+ case QWebEnginePage::WebBrowserTab:
+ case QWebEnginePage::WebBrowserBackgroundTab:
+ {
+ bool active = (type != QWebEnginePage::WebBrowserBackgroundTab);
+
+ tab = ::mainWindow->viewWindowMgr()->addNewTab(active);
+ tab->setZoomFactor( ::mainWindow->currentBrowser()->zoomFactor() );
+
+ if (active)
+ {
+ tab->setFocus( Qt::OtherFocusReason );
+ }
+ }
+ break;
+
+ case QWebEnginePage::WebDialog:
+ // TODO: implement
+ break;
+ }
+
+ return tab;
+}
+
void ViewWindow::onLoadFinished ( bool )
{
// If m_storedScrollbarPosition is -1 this means we have not had a request to set the scrollbar; change to 0
diff --git a/src/viewwindow_webengine.h b/src/viewwindow_webengine.h
index 3e96690..6312cfc 100644
--- a/src/viewwindow_webengine.h
+++ b/src/viewwindow_webengine.h
@@ -112,6 +112,8 @@ class ViewWindow : public QWebEngineView
void contextMenuEvent( QContextMenuEvent *e );
//void mouseReleaseEvent ( QMouseEvent * event );
+ virtual QWebEngineView* createWindow(QWebEnginePage::WebWindowType type) override;
+
private slots:
// Used to restore the scrollbar position and the navigation button status
void onLoadFinished ( bool ok );