diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py index bf6d70010..1264dba5b 100644 --- a/qutebrowser/mainwindow/tabwidget.py +++ b/qutebrowser/mainwindow/tabwidget.py @@ -514,28 +514,30 @@ 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 + # 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 index < self.width() % self.count(): + 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