Merge branch 'fix-tabbar-padding' of https://github.com/kmarius/qutebrowser

This commit is contained in:
Florian Bruhin 2017-06-19 09:43:26 +02:00
commit 8494332c3a

View File

@ -514,28 +514,32 @@ class TabBar(QTabBar):
except KeyError:
pinned = False
no_pinned_count = self.count() - self.pinned_count
pinned_width = tab_width_pinned_conf * self.pinned_count
no_pinned_width = self.width() - pinned_width
if pinned:
size = QSize(tab_width_pinned_conf, height)
qtutils.ensure_valid(size)
return size
# If we *do* have enough space, tabs should occupy the whole window
# width. If there are pinned tabs their size will be subtracted
# from the total window width.
# During shutdown the self.count goes down,
# but the self.pinned_count not - this generates some odd behavior.
# To avoid this we compare self.count against self.pinned_count.
if self.pinned_count > 0 and self.count() > self.pinned_count:
pinned_width = tab_width_pinned_conf * self.pinned_count
no_pinned_width = self.width() - pinned_width
width = no_pinned_width / (self.count() - self.pinned_count)
width = tab_width_pinned_conf
else:
width = self.width() / self.count()
# If width is not divisible by count, add a pixel to some tabs so
# that there is no ugly leftover space.
if index < self.width() % self.count():
# If we *do* have enough space, tabs should occupy the whole
# window width. If there are pinned tabs their size will be
# subtracted from the total window width.
# During shutdown the self.count goes down,
# but the self.pinned_count not - this generates some odd
# behavior. To avoid this we compare self.count against
# self.pinned_count.
if self.pinned_count > 0 and no_pinned_count > 0:
width = no_pinned_width / no_pinned_count
else:
width = self.width() / self.count()
# If no_pinned_width is not divisible by no_pinned_count, add a
# pixel to some tabs so # that there is no ugly leftover space.
if (no_pinned_count > 0 and
index < no_pinned_width % no_pinned_count):
width += 1
size = QSize(width, height)
qtutils.ensure_valid(size)
return size