Repository: qutebrowser/qutebrowser

Issue:
A way to make favicons bigger without affecting font sizes
Since 58aa1a738d86a7aca5dbc3e5658fe6891ec9b9c1 the favicon size is determined entirely by the font size, with no way to increase it further via padding etc.

But this is somewhat annoying for my use cases, because I'm using a tiny font (4pt) in order to fit as much text as possible into each tab - but this results in a favicon that's absolutely tiny. I would like the ability to make the favicon a bit bigger without (significantly) sacrificing characters.

Not sure what the best way to implement this would be. Perhaps just having a setting to scale the favicon would be enough? Since that would be independent of any specific layout.

ping @Carpetsmoker 


Discussion:
Note: Just increasing the `iconSize` in `tabbar.py` almost has the desired effect, but due to the layouting done in https://github.com/qutebrowser/qutebrowser/blob/master/qutebrowser/mainwindow/tabwidget.py#L749 etc. this means that the favicon now trails off the bottom edge. It would be better to rewrite the layouting code such that the favicon ends up center-aligned with the text instead, if “blindly increase the favicon size” is an intended solution.
Could add a `favicon-scale` setting,  I suppose, and change it to something like:

    size = (self.fontInfo().pixelSize() - 1) * config.get('tabs', 'favicon-scale')

The default would be `1`, and you could get your larger favicons by setting it to e.g. `1.5`.
Yep, that seems reasonable; although note that the drawing code would also have to be updated as mentioned.

Resolving patch:
diff --git a/qutebrowser/config/configdata.py b/qutebrowser/config/configdata.py
--- a/qutebrowser/config/configdata.py
+++ b/qutebrowser/config/configdata.py
@@ -680,6 +680,11 @@ def data(readonly=False):
              SettingValue(typ.Bool(), 'true'),
              "Whether to show favicons in the tab bar."),
 
+            ('favicon-scale',
+             SettingValue(typ.Float(minval=0.0), '1.0'),
+             "Scale for favicons in the tab bar. The tab size is unchanged, "
+             "so big favicons also require extra `tabs->padding`."),
+
             ('width',
              SettingValue(typ.PercOrInt(minperc=0, maxperc=100, minint=1),
                           '20%'),
diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py
--- a/qutebrowser/mainwindow/tabwidget.py
+++ b/qutebrowser/mainwindow/tabwidget.py
@@ -22,7 +22,8 @@
 import collections
 import functools
 
-from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt, QSize, QRect, QTimer, QUrl
+from PyQt5.QtCore import (pyqtSignal, pyqtSlot, Qt, QSize, QRect, QPoint,
+                          QTimer, QUrl)
 from PyQt5.QtWidgets import (QTabWidget, QTabBar, QSizePolicy, QCommonStyle,
                              QStyle, QStylePainter, QStyleOptionTab)
 from PyQt5.QtGui import QIcon, QPalette, QColor
@@ -273,6 +274,7 @@ def __init__(self, win_id, parent=None):
         self.set_font()
         config_obj = objreg.get('config')
         config_obj.changed.connect(self.set_font)
+        config_obj.changed.connect(self.set_icon_size)
         self.vertical = False
         self._page_fullscreen = False
         self._auto_hide_timer = QTimer()
@@ -374,7 +376,13 @@ def refresh(self):
     def set_font(self):
         """Set the tab bar font."""
         self.setFont(config.get('fonts', 'tabbar'))
+        self.set_icon_size()
+
+    @config.change_filter('tabs', 'favicon-scale')
+    def set_icon_size(self):
+        """Set the tab bar favicon size."""
         size = self.fontMetrics().height() - 2
+        size *= config.get('tabs', 'favicon-scale')
         self.setIconSize(QSize(size, size))
 
     @config.change_filter('colors', 'tabs.bg.bar')
@@ -775,7 +783,7 @@ def _get_icon_rect(self, opt, text_rect):
             tab_icon_size = QSize(
                 min(actual_size.width(), icon_size.width()),
                 min(actual_size.height(), icon_size.height()))
-        icon_rect = QRect(text_rect.left(), text_rect.top() + 1,
-                          tab_icon_size.width(), tab_icon_size.height())
+        icon_top = text_rect.center().y() + 1 - tab_icon_size.height() / 2
+        icon_rect = QRect(QPoint(text_rect.left(), icon_top), tab_icon_size)
         icon_rect = self._style.visualRect(opt.direction, opt.rect, icon_rect)
         return icon_rect


Test patch:
diff --git a/tests/unit/mainwindow/test_tabwidget.py b/tests/unit/mainwindow/test_tabwidget.py
--- a/tests/unit/mainwindow/test_tabwidget.py
+++ b/tests/unit/mainwindow/test_tabwidget.py
@@ -44,6 +44,7 @@ class TestTabWidget:
             'select-on-remove': 1,
             'show': 'always',
             'show-favicons': True,
+            'favicon-scale': 1.0,
             'padding': configtypes.PaddingValues(0, 0, 5, 5),
             'indicator-width': 3,
             'indicator-padding': configtypes.PaddingValues(2, 2, 0, 4),