diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py index 70fd47f9a..4fe041f55 100644 --- a/qutebrowser/mainwindow/tabwidget.py +++ b/qutebrowser/mainwindow/tabwidget.py @@ -355,6 +355,17 @@ class TabWidget(QTabWidget): if config.val.tabs.tabs_are_windows: self.window().setWindowIcon(self.window().windowIcon()) + def setTabIcon(self, idx: int, icon: QIcon): + """Add overrides for setting tab icon sometimes when it is empty.""" + tab = self.widget(idx) + if (icon.isNull() and + config.cache['tabs.favicons.show'] != 'never' and + config.cache['tabs.pinned.shrink'] and + not self.tabBar().vertical and + tab is not None and tab.data.pinned): + icon = self.style().standardIcon(QStyle.SP_FileIcon) + super().setTabIcon(idx, icon) + class TabBar(QTabBar): diff --git a/tests/unit/mainwindow/test_tabwidget.py b/tests/unit/mainwindow/test_tabwidget.py index 0b90b3d00..a16bda246 100644 --- a/tests/unit/mainwindow/test_tabwidget.py +++ b/tests/unit/mainwindow/test_tabwidget.py @@ -85,7 +85,7 @@ class TestTabWidget: widget.addTab(fake_web_tab(), 'foobar' + str(i)) # Set pinned title format longer than unpinned - config_stub.val.tabs.title.format_pinned = "_" * 20 + config_stub.val.tabs.title.format_pinned = "_" * 10 config_stub.val.tabs.title.format = "_" * 2 config_stub.val.tabs.pinned.shrink = shrink_pinned if vertical: