From 1adb46420e4692f86626dc2b068f68f810b91048 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 23 Jun 2020 17:25:22 +0200 Subject: Revert "Remove now unneeded WrapperLayout.unwrap" This reverts commit 370bd12a1512f5164be0e3ae1838515957e587fb. Turns one of out the workarounds removed in 87d7dd93420ab92a1a209919297371dc0fadcecd is still needed until Qt 5.12... --- qutebrowser/misc/miscwidgets.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/qutebrowser/misc/miscwidgets.py b/qutebrowser/misc/miscwidgets.py index 868796e99..95786e3c7 100644 --- a/qutebrowser/misc/miscwidgets.py +++ b/qutebrowser/misc/miscwidgets.py @@ -240,6 +240,7 @@ class WrapperLayout(QLayout): def __init__(self, parent=None): super().__init__(parent) self._widget = None # type: typing.Optional[QWidget] + self._container = None # type: typing.Optional[QWidget] def addItem(self, _widget): raise utils.Unreachable @@ -264,10 +265,23 @@ class WrapperLayout(QLayout): def wrap(self, container, widget): """Wrap the given widget in the given container.""" + self._container = container self._widget = widget container.setFocusProxy(widget) widget.setParent(container) + def unwrap(self): + """Remove the widget from this layout. + + Does nothing if it nothing was wrapped before. + """ + if self._widget is None: + return + assert self._container is not None + self._widget.setParent(None) # type: ignore[call-overload] + self._widget = None + self._container.setFocusProxy(None) # type: ignore[arg-type] + class PseudoLayout(QLayout): -- cgit v1.2.3-54-g00ecf