Restructure minimum tab size behavior
This commit is contained in:
parent
8dbb61e9e3
commit
27dfc72012
@ -503,10 +503,6 @@ class TabBar(QTabBar):
|
|||||||
# We return it directly rather than setting `size' because we don't
|
# We return it directly rather than setting `size' because we don't
|
||||||
# want to ensure it's valid in this special case.
|
# want to ensure it's valid in this special case.
|
||||||
return QSize()
|
return QSize()
|
||||||
elif self.count() * minimum_size.width() > self.width():
|
|
||||||
# If we don't have enough space, we return the minimum size so we
|
|
||||||
# get scroll buttons as soon as needed.
|
|
||||||
size = minimum_size
|
|
||||||
else:
|
else:
|
||||||
tab_width_pinned_conf = config.get('tabs', 'pinned-width')
|
tab_width_pinned_conf = config.get('tabs', 'pinned-width')
|
||||||
|
|
||||||
@ -517,21 +513,19 @@ class TabBar(QTabBar):
|
|||||||
|
|
||||||
no_pinned_count = self.count() - self.pinned_count
|
no_pinned_count = self.count() - self.pinned_count
|
||||||
pinned_width = tab_width_pinned_conf * self.pinned_count
|
pinned_width = tab_width_pinned_conf * self.pinned_count
|
||||||
# Prevent any tabs from being smaller than the min size
|
no_pinned_width = self.width() - pinned_width
|
||||||
no_pinned_width = max(self.width() - pinned_width,
|
|
||||||
minimum_size.width() * no_pinned_count)
|
|
||||||
|
|
||||||
if pinned:
|
if pinned:
|
||||||
width = tab_width_pinned_conf
|
width = tab_width_pinned_conf
|
||||||
else:
|
else:
|
||||||
|
|
||||||
# If we *do* have enough space, tabs should occupy the whole
|
# Tabs should attempt to occupy the whole window width. If
|
||||||
# window width. If there are pinned tabs their size will be
|
# there are pinned tabs their size will be subtracted from the
|
||||||
# subtracted from the total window width.
|
# total window width. During shutdown the self.count goes
|
||||||
# During shutdown the self.count goes down,
|
# down, but the self.pinned_count not - this generates some odd
|
||||||
# but the self.pinned_count not - this generates some odd
|
|
||||||
# behavior. To avoid this we compare self.count against
|
# behavior. To avoid this we compare self.count against
|
||||||
# self.pinned_count.
|
# self.pinned_count. If we end up having too little space, we
|
||||||
|
# set the minimum size below.
|
||||||
if self.pinned_count > 0 and no_pinned_count > 0:
|
if self.pinned_count > 0 and no_pinned_count > 0:
|
||||||
width = no_pinned_width / no_pinned_count
|
width = no_pinned_width / no_pinned_count
|
||||||
else:
|
else:
|
||||||
@ -543,6 +537,10 @@ class TabBar(QTabBar):
|
|||||||
index < no_pinned_width % no_pinned_count):
|
index < no_pinned_width % no_pinned_count):
|
||||||
width += 1
|
width += 1
|
||||||
|
|
||||||
|
# If we don't have enough space, we return the minimum size so we
|
||||||
|
# get scroll buttons as soon as needed.
|
||||||
|
width = max(width, minimum_size.width())
|
||||||
|
|
||||||
size = QSize(width, height)
|
size = QSize(width, height)
|
||||||
qtutils.ensure_valid(size)
|
qtutils.ensure_valid(size)
|
||||||
return size
|
return size
|
||||||
|
Loading…
Reference in New Issue
Block a user