From ecf6f4bca08aa55233631a46b49c60e6c7c280d4 Mon Sep 17 00:00:00 2001 From: Jay Kamat Date: Mon, 6 Nov 2017 14:35:50 -0500 Subject: [PATCH] Fix Qt Mnemonics affecting min tab width See #3245 --- qutebrowser/mainwindow/tabwidget.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py index ddd7424c6..4da38092e 100644 --- a/qutebrowser/mainwindow/tabwidget.py +++ b/qutebrowser/mainwindow/tabwidget.py @@ -501,8 +501,12 @@ class TabBar(QTabBar): """ text = '\u2026' if ellipsis else tab_text # Don't ever shorten if text is shorter than the ellipsis - text_width = min(self.fontMetrics().width(text), - self.fontMetrics().width(tab_text)) + + def _text_to_width(text): + # Calculate text width taking into account qt mnemonics + return self.fontMetrics().size(Qt.TextShowMnemonic, text).width() + text_width = min(_text_to_width(text), + _text_to_width(tab_text)) padding = config.val.tabs.padding indicator_width = config.val.tabs.width.indicator indicator_padding = config.val.tabs.indicator_padding