From 4b2bf12efa73d29ac4e334ea58f80480952ca9af Mon Sep 17 00:00:00 2001 From: Marius Date: Sun, 18 Jun 2017 21:49:04 +0200 Subject: [PATCH 1/4] Fix padding of remaining tabbar space with pinned tabs --- qutebrowser/mainwindow/tabwidget.py | 36 +++++++++++++++-------------- 1 file changed, 19 insertions(+), 17 deletions(-) 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 From 68f172558bdbeee967e9b577e80d6796eeaad2ff Mon Sep 17 00:00:00 2001 From: Marius Date: Sun, 18 Jun 2017 22:44:06 +0200 Subject: [PATCH 2/4] fix line length --- qutebrowser/mainwindow/tabwidget.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py index 1264dba5b..14e1fd9f7 100644 --- a/qutebrowser/mainwindow/tabwidget.py +++ b/qutebrowser/mainwindow/tabwidget.py @@ -522,20 +522,22 @@ class TabBar(QTabBar): width = tab_width_pinned_conf else: - # 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. + # 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. + # 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: + # 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) From ebd442ea956cb968087b4adf59903aea54bd67c8 Mon Sep 17 00:00:00 2001 From: Marius Date: Sun, 18 Jun 2017 23:07:38 +0200 Subject: [PATCH 3/4] add needed parens and remove trailing whitespace --- qutebrowser/mainwindow/tabwidget.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py index 14e1fd9f7..9a34fc0fc 100644 --- a/qutebrowser/mainwindow/tabwidget.py +++ b/qutebrowser/mainwindow/tabwidget.py @@ -522,12 +522,12 @@ class TabBar(QTabBar): width = tab_width_pinned_conf else: - # If we *do* have enough space, tabs should occupy the whole - # window # width. If there are pinned tabs their size will be + # 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 + # 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 @@ -536,8 +536,8 @@ class TabBar(QTabBar): # 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: + if (no_pinned_count > 0 and + index < no_pinned_width % no_pinned_count): width += 1 size = QSize(width, height) From de743732aa5e8e7d2571cfa8c81668768f7c9099 Mon Sep 17 00:00:00 2001 From: Marius Date: Mon, 19 Jun 2017 08:29:23 +0200 Subject: [PATCH 4/4] remove # inside comment --- qutebrowser/mainwindow/tabwidget.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py index 9a34fc0fc..8356b069f 100644 --- a/qutebrowser/mainwindow/tabwidget.py +++ b/qutebrowser/mainwindow/tabwidget.py @@ -523,7 +523,7 @@ class TabBar(QTabBar): else: # If we *do* have enough space, tabs should occupy the whole - # window # width. If there are pinned tabs their size will be + # 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