From cf5168c849d5f575f8545628430d3db4f2b11022 Mon Sep 17 00:00:00 2001 From: Jay Kamat Date: Sat, 6 Oct 2018 14:57:16 -0700 Subject: [PATCH 1/2] Always show icons for pinned tabs --- qutebrowser/mainwindow/tabwidget.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py index 165052e78..d4337b88f 100644 --- a/qutebrowser/mainwindow/tabwidget.py +++ b/qutebrowser/mainwindow/tabwidget.py @@ -350,6 +350,15 @@ 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 + tab is not None and tab.data.pinned): + icon = self.style().standardIcon(QStyle.SP_FileIcon) + super().setTabIcon(idx, icon) + class TabBar(QTabBar): From 6a6b56bbf4f3d6066f51b6ae154c304ccd0ac404 Mon Sep 17 00:00:00 2001 From: Jay Kamat Date: Fri, 12 Oct 2018 20:53:07 -0700 Subject: [PATCH 2/2] Don't apply default icon to unshrunk and vertical tabs The rationale is that this is only useful to give pinned tabs space when shrunk in a horizontal tabbar. --- qutebrowser/mainwindow/tabwidget.py | 2 ++ tests/unit/mainwindow/test_tabwidget.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py index d4337b88f..30ee45509 100644 --- a/qutebrowser/mainwindow/tabwidget.py +++ b/qutebrowser/mainwindow/tabwidget.py @@ -355,6 +355,8 @@ class TabWidget(QTabWidget): 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) diff --git a/tests/unit/mainwindow/test_tabwidget.py b/tests/unit/mainwindow/test_tabwidget.py index e2bcf9b29..08ed3a886 100644 --- a/tests/unit/mainwindow/test_tabwidget.py +++ b/tests/unit/mainwindow/test_tabwidget.py @@ -84,7 +84,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: