diff options
author | Florian Bruhin <git@the-compiler.org> | 2014-12-10 14:29:14 +0100 |
---|---|---|
committer | Florian Bruhin <git@the-compiler.org> | 2014-12-10 14:29:14 +0100 |
commit | 92b9dc08f494b7d6f6ff633aa8bf9283c55db0de (patch) | |
tree | cf616eef99f821d31f455caceb749a6ec52a21f6 | |
parent | bac30b91928e87fdddbc13f0e03ec3e10cda51db (diff) | |
download | qutebrowser-92b9dc08f494b7d6f6ff633aa8bf9283c55db0de.tar.gz qutebrowser-92b9dc08f494b7d6f6ff633aa8bf9283c55db0de.zip |
tabwidget: Clean up and fix minimumTabSizeHint.
See #283.
The width now accounts for the indicator, and the wrong docstring has been
removed.
-rw-r--r-- | qutebrowser/widgets/tabwidget.py | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/qutebrowser/widgets/tabwidget.py b/qutebrowser/widgets/tabwidget.py index be9f3898b..cb8277b05 100644 --- a/qutebrowser/widgets/tabwidget.py +++ b/qutebrowser/widgets/tabwidget.py @@ -158,14 +158,7 @@ class TabBar(QTabBar): super().mousePressEvent(e) def minimumTabSizeHint(self, index): - """Override minimumTabSizeHint because we want no hard minimum. - - There are two problems with having a hard minimum tab size: - - When expanding is True, the window will expand without stopping - on some window managers. - - We don't want the main window to get bigger with many tabs. If - nothing else helps, we *do* want the tabs to get smaller instead - of enforcing a minimum window size. + """Set the minimum tab size to indicator/icon/... text. Args: index: The index of the tab to get a sizehint for. @@ -175,17 +168,21 @@ class TabBar(QTabBar): """ icon = self.tabIcon(index) padding_count = 0 - if not icon.isNull(): + if icon.isNull(): + icon_size = QSize(0, 0) + else: extent = self.style().pixelMetric(QStyle.PM_TabBarIconSize, None, self) icon_size = icon.actualSize(QSize(extent, extent)) padding_count += 1 - else: - icon_size = QSize(0, 0) + indicator_width = config.get('tabs', 'indicator-width') + if indicator_width != 0: + indicator_width += config.get('tabs', 'indicator-space') padding_width = self.style().pixelMetric(PM_TabBarPadding, None, self) height = self.fontMetrics().height() width = (self.fontMetrics().size(0, '\u2026').width() + - icon_size.width() + padding_count * padding_width) + icon_size.width() + padding_count * padding_width + + indicator_width) return QSize(width, height) def tabSizeHint(self, index): |