Initial proof of concept for pseudo layout

Fixes #3920 - hopefully properly this time...
This commit is contained in:
Florian Bruhin 2018-06-06 13:06:50 +02:00
parent 5635639ed4
commit cee88cd7ca
3 changed files with 26 additions and 22 deletions

View File

@ -1057,28 +1057,6 @@ class WebEngineTab(browsertab.AbstractTab):
def _on_navigation_request(self, navigation):
super()._on_navigation_request(navigation)
if qtutils.version_check('5.11.0', exact=True, compiled=False):
# WORKAROUND for https://bugreports.qt.io/browse/QTBUG-68224
layout = self._widget.layout()
count = layout.count()
children = self._widget.findChildren(QWidget)
if not count and children:
log.webview.warning("Found children not in layout: {}, "
"focus proxy {} (QTBUG-68224)".format(
children, self._widget.focusProxy()))
if count > 1:
log.webview.debug("Found {} widgets! (QTBUG-68224)"
.format(count))
for i in range(count):
item = layout.itemAt(i)
if item is None:
continue
widget = item.widget()
if widget is not self._widget.focusProxy():
log.webview.debug("Removing widget {} (QTBUG-68224)"
.format(widget))
layout.removeWidget(widget)
if not navigation.accepted or not navigation.is_main_frame:
return

View File

@ -21,6 +21,7 @@
import functools
import sip
from PyQt5.QtCore import pyqtSignal, pyqtSlot, QUrl, PYQT_VERSION
from PyQt5.QtGui import QPalette
from PyQt5.QtWebEngineWidgets import (QWebEngineView, QWebEnginePage,
@ -30,6 +31,7 @@ from qutebrowser.browser import shared
from qutebrowser.browser.webengine import certificateerror, webenginesettings
from qutebrowser.config import config
from qutebrowser.utils import log, debug, usertypes, jinja, objreg, qtutils
from qutebrowser.misc import miscwidgets
class WebEngineView(QWebEngineView):
@ -51,9 +53,17 @@ class WebEngineView(QWebEngineView):
parent=self)
self.setPage(page)
sip.delete(self.layout())
self._layout = miscwidgets.PseudoLayout(self)
def shutdown(self):
self.page().shutdown()
def resizeEvent(self, _event):
proxy = self.focusProxy()
if proxy:
proxy.setGeometry(self.rect())
def createWindow(self, wintype):
"""Called by Qt when a page wants to create a new window.

View File

@ -266,6 +266,22 @@ class WrapperLayout(QLayout):
self._widget.deleteLater()
class PseudoLayout(QLayout):
def addItem(self, item):
assert self.parent() is not None
item.widget().setParent(self.parent())
def removeItem(self, item):
item.widget().setParent(None)
def count(self):
return 0
def itemAt(self, _pos):
return None
class FullscreenNotification(QLabel):
"""A label telling the user this page is now fullscreen."""