diff --git a/qutebrowser/config/configdata.yml b/qutebrowser/config/configdata.yml index a6a2d5317..f2fe79a1d 100644 --- a/qutebrowser/config/configdata.yml +++ b/qutebrowser/config/configdata.yml @@ -1406,6 +1406,16 @@ tabs.width: desc: "Width (in pixels or as percentage of the window) of the tab bar if it's vertical." +tabs.min_width: + default: -1 + type: + name: Int + minval: -1 + desc: >- + Minimum width (in pixels) of tabs (-1 to use text contents for min width). + + This setting only applies when tabs are horizontal. + tabs.width.indicator: renamed: tabs.indicator.width diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py index 8261492a9..0fc7fed40 100644 --- a/qutebrowser/mainwindow/tabwidget.py +++ b/qutebrowser/mainwindow/tabwidget.py @@ -358,7 +358,8 @@ class TabBar(QTabBar): # Clear _minimum_tab_size_hint_helper cache when appropriate if option in ["tabs.indicator.padding", "tabs.padding", - "tabs.indicator.width"]: + "tabs.indicator.width", + "tabs.min_width"]: self._minimum_tab_size_hint_helper.cache_clear() def _on_show_switching_delay_changed(self): @@ -495,13 +496,13 @@ class TabBar(QTabBar): # Never consider ellipsis an option for pinned tabs ellipsis = False return self._minimum_tab_size_hint_helper(self.tabText(index), - icon_width, - ellipsis) + icon_width, ellipsis, + pinned) @functools.lru_cache(maxsize=2**9) def _minimum_tab_size_hint_helper(self, tab_text: str, icon_width: int, - ellipsis: bool) -> QSize: + ellipsis: bool, pinned: bool) -> QSize: """Helper function to cache tab results. Config values accessed in here should be added to _on_config_changed to @@ -526,6 +527,9 @@ class TabBar(QTabBar): height = self.fontMetrics().height() + padding_v width = (text_width + icon_width + padding_h + indicator_width) + min_width = config.val.tabs.min_width + if not pinned and not self.vertical and min_width > 0: + width = max(min_width, width) return QSize(width, height) def _pinned_statistics(self) -> (int, int):