Use WrapperLayout instead of PseudoLayout
This commit is contained in:
parent
cee88cd7ca
commit
e0213e7447
@ -54,16 +54,11 @@ class WebEngineView(QWebEngineView):
|
|||||||
self.setPage(page)
|
self.setPage(page)
|
||||||
|
|
||||||
sip.delete(self.layout())
|
sip.delete(self.layout())
|
||||||
self._layout = miscwidgets.PseudoLayout(self)
|
self._layout = miscwidgets.WrapperLayout(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.
|
||||||
|
|
||||||
|
@ -240,8 +240,13 @@ class WrapperLayout(QLayout):
|
|||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
self._widget = None
|
self._widget = None
|
||||||
|
|
||||||
def addItem(self, _widget):
|
def addItem(self, item):
|
||||||
raise utils.Unreachable
|
assert self.parent() is not None
|
||||||
|
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()
|
||||||
@ -253,7 +258,8 @@ class WrapperLayout(QLayout):
|
|||||||
raise utils.Unreachable
|
raise utils.Unreachable
|
||||||
|
|
||||||
def setGeometry(self, rect):
|
def setGeometry(self, rect):
|
||||||
self._widget.setGeometry(rect)
|
if self._widget is not None:
|
||||||
|
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."""
|
||||||
@ -264,22 +270,7 @@ 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):
|
||||||
|
Loading…
Reference in New Issue
Block a user