Simplify toggle_visibility
This commit is contained in:
parent
b8be4e5915
commit
8d489a40e4
@ -216,7 +216,7 @@ class TabWidget(QTabWidget):
|
|||||||
return fields
|
return fields
|
||||||
|
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
def _toggle_visibility(self, force_toggle=False):
|
def _toggle_visibility(self):
|
||||||
"""Toggle visibility while running.
|
"""Toggle visibility while running.
|
||||||
|
|
||||||
Every single call to setTabText calls the size hinting functions for
|
Every single call to setTabText calls the size hinting functions for
|
||||||
@ -224,18 +224,15 @@ class TabWidget(QTabWidget):
|
|||||||
the tab's titles, we can delay this processing by making the tab
|
the tab's titles, we can delay this processing by making the tab
|
||||||
non-visible. To avoid flickering, disable repaint updates whlie we
|
non-visible. To avoid flickering, disable repaint updates whlie we
|
||||||
work.
|
work.
|
||||||
|
|
||||||
Args:
|
|
||||||
force_toggle: Whether to always force the toggle, or only do it
|
|
||||||
if we have enough tabs for it to matter
|
|
||||||
"""
|
"""
|
||||||
if self.count() > 10:
|
toggle = self.count() > 10
|
||||||
force_toggle = True
|
if toggle:
|
||||||
if force_toggle:
|
|
||||||
self.setUpdatesEnabled(False)
|
self.setUpdatesEnabled(False)
|
||||||
self.setVisible(False)
|
self.setVisible(False)
|
||||||
|
|
||||||
yield
|
yield
|
||||||
if force_toggle:
|
|
||||||
|
if toggle:
|
||||||
self.setVisible(True)
|
self.setVisible(True)
|
||||||
self.setUpdatesEnabled(True)
|
self.setUpdatesEnabled(True)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user