From 58aa1a738d86a7aca5dbc3e5658fe6891ec9b9c1 Mon Sep 17 00:00:00 2001 From: Martin Tournoij Date: Wed, 5 Aug 2015 22:33:24 +0200 Subject: [PATCH 1/3] Favicon sizing is messed up with tabs -> orientation = west #847 Here's a patch which seems to work well in my initial testing. We now use the font size rather than the tabbar size, since the tabbar size is the window size when it's vertical. This also works nicer with the new tabs.padding setting (which didn't exist when I wrote the first patch). --- qutebrowser/mainwindow/tabwidget.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py index ea1426add..ffd33de7d 100644 --- a/qutebrowser/mainwindow/tabwidget.py +++ b/qutebrowser/mainwindow/tabwidget.py @@ -309,13 +309,9 @@ class TabBar(QTabBar): def set_font(self): """Set the tab bar font.""" self.setFont(config.get('fonts', 'tabbar')) + size = self.fontInfo().pixelSize() - 1 + self.setIconSize(QSize(size, size)) - def resizeEvent(self, e): - """Set the favicon size to the tabbar size minus some padding.""" - height = e.size().height() - if height != 0 and e.oldSize().height() != height: - height = math.ceil(height - height / 7) - self.setIconSize(QSize(height, height)) @config.change_filter('colors', 'tabs.bg.bar') def set_colors(self): From 58a9677af858751dcdf753345bde975a1297d26a Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 6 Aug 2015 21:11:06 +0200 Subject: [PATCH 2/3] Use QFontMetrics instead of QFontInfo. --- 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 ffd33de7d..d0fc3f931 100644 --- a/qutebrowser/mainwindow/tabwidget.py +++ b/qutebrowser/mainwindow/tabwidget.py @@ -309,7 +309,7 @@ class TabBar(QTabBar): def set_font(self): """Set the tab bar font.""" self.setFont(config.get('fonts', 'tabbar')) - size = self.fontInfo().pixelSize() - 1 + size = self.fontMetrics().height() - 1 self.setIconSize(QSize(size, size)) From 3f445ba6ca154b530f517863e1dd68c4ecac0c1d Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 6 Aug 2015 21:14:05 +0200 Subject: [PATCH 3/3] Draw favicon at correct position/size. --- qutebrowser/mainwindow/tabwidget.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py index d0fc3f931..a68fc0864 100644 --- a/qutebrowser/mainwindow/tabwidget.py +++ b/qutebrowser/mainwindow/tabwidget.py @@ -309,7 +309,7 @@ class TabBar(QTabBar): def set_font(self): """Set the tab bar font.""" self.setFont(config.get('fonts', 'tabbar')) - size = self.fontMetrics().height() - 1 + size = self.fontMetrics().height() - 2 self.setIconSize(QSize(size, size)) @@ -725,8 +725,7 @@ class TabBarStyle(QCommonStyle): tab_icon_size = opt.icon.actualSize(icon_size, icon_mode, icon_state) tab_icon_size = QSize(min(tab_icon_size.width(), icon_size.width()), min(tab_icon_size.height(), icon_size.height())) - icon_rect = QRect(text_rect.left(), - text_rect.center().y() - tab_icon_size.height() / 2, + icon_rect = QRect(text_rect.left(), text_rect.top() + 1, tab_icon_size.width(), tab_icon_size.height()) icon_rect = self._style.visualRect(opt.direction, opt.rect, icon_rect) qtutils.ensure_valid(icon_rect)