Revert "Use WrapperLayout instead of PseudoLayout"

This reverts commit 6cc920472ee4170b257a0b588687b175162e83df.

Since self._widget can go stale in the layout, we need to somehow solve this differently...
This commit is contained in:
Florian Bruhin 2018-06-06 16:55:26 +02:00
parent e0213e7447
commit 34d054e8a5
2 changed files with 25 additions and 11 deletions

View File

@ -54,11 +54,16 @@ class WebEngineView(QWebEngineView):
self.setPage(page) self.setPage(page)
sip.delete(self.layout()) sip.delete(self.layout())
self._layout = miscwidgets.WrapperLayout(self) self._layout = miscwidgets.PseudoLayout(self)
def shutdown(self): def shutdown(self):
self.page().shutdown() self.page().shutdown()
def resizeEvent(self, _event):
proxy = self.focusProxy()
if proxy:
proxy.setGeometry(self.rect())
def createWindow(self, wintype): def createWindow(self, wintype):
"""Called by Qt when a page wants to create a new window. """Called by Qt when a page wants to create a new window.

View File

@ -240,13 +240,8 @@ class WrapperLayout(QLayout):
super().__init__(parent) super().__init__(parent)
self._widget = None self._widget = None
def addItem(self, item): def addItem(self, _widget):
assert self.parent() is not None raise utils.Unreachable
self.wrap(self.parent(), item.widget())
def removeItem(self, item):
assert item.widget() == self._widget
self.unwrap()
def sizeHint(self): def sizeHint(self):
return self._widget.sizeHint() return self._widget.sizeHint()
@ -258,8 +253,7 @@ class WrapperLayout(QLayout):
raise utils.Unreachable raise utils.Unreachable
def setGeometry(self, rect): def setGeometry(self, rect):
if self._widget is not None: self._widget.setGeometry(rect)
self._widget.setGeometry(rect)
def wrap(self, container, widget): def wrap(self, container, widget):
"""Wrap the given widget in the given container.""" """Wrap the given widget in the given container."""
@ -270,7 +264,22 @@ class WrapperLayout(QLayout):
def unwrap(self): def unwrap(self):
self._widget.setParent(None) self._widget.setParent(None)
self._widget.deleteLater() self._widget.deleteLater()
self._widget = None
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): class FullscreenNotification(QLabel):