Prevent calling _tab_pinned on every tab twice
This commit is contained in:
parent
caae1c7008
commit
b499474599
@ -486,17 +486,15 @@ class TabBar(QTabBar):
|
|||||||
padding_h + config.val.tabs.width.indicator)
|
padding_h + config.val.tabs.width.indicator)
|
||||||
return QSize(width, height)
|
return QSize(width, height)
|
||||||
|
|
||||||
def _tab_total_width_pinned(self):
|
def _pinned_statistics(self) -> (int, int):
|
||||||
"""Get the current total width of pinned tabs.
|
"""Get the number of pinned tabs and the total width of pinned tabs."""
|
||||||
|
pinned_list = [idx
|
||||||
This width is calculated assuming no shortening due to ellipsis."""
|
|
||||||
return sum(self.minimumTabSizeHint(idx, ellipsis=False).width()
|
|
||||||
for idx in range(self.count())
|
for idx in range(self.count())
|
||||||
if self._tab_pinned(idx))
|
if self._tab_pinned(idx)]
|
||||||
|
pinned_count = len(pinned_list)
|
||||||
def _pinnedCount(self) -> int:
|
pinned_width = sum(self.minimumTabSizeHint(idx, ellipsis=False).width()
|
||||||
"""Get the number of pinned tabs."""
|
for idx in pinned_list)
|
||||||
return sum(self._tab_pinned(idx) for idx in range(self.count()))
|
return (pinned_count, pinned_width)
|
||||||
|
|
||||||
def _tab_pinned(self, index: int) -> bool:
|
def _tab_pinned(self, index: int) -> bool:
|
||||||
"""Return True if tab is pinned."""
|
"""Return True if tab is pinned."""
|
||||||
@ -535,8 +533,8 @@ class TabBar(QTabBar):
|
|||||||
return QSize()
|
return QSize()
|
||||||
else:
|
else:
|
||||||
pinned = self._tab_pinned(index)
|
pinned = self._tab_pinned(index)
|
||||||
no_pinned_count = self.count() - self._pinnedCount()
|
pinned_count, pinned_width = self._pinned_statistics()
|
||||||
pinned_width = self._tab_total_width_pinned()
|
no_pinned_count = self.count() - pinned_count
|
||||||
no_pinned_width = self.width() - pinned_width
|
no_pinned_width = self.width() - pinned_width
|
||||||
|
|
||||||
if pinned:
|
if pinned:
|
||||||
|
Loading…
Reference in New Issue
Block a user