From 297a0e65c4ddbd5038d9249306f3d9069befcf74 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 12 May 2014 21:23:16 +0200 Subject: [PATCH] Work around the tabbar cut font issue --- TODO | 3 +++ qutebrowser/widgets/_tabbedbrowser.py | 6 +++--- qutebrowser/widgets/_tabwidget.py | 20 +++++++++++++++++++- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/TODO b/TODO index 462dd2838..63b4f8bb1 100644 --- a/TODO +++ b/TODO @@ -187,6 +187,9 @@ Upstream Bugs - QNetworkReplyImplPrivate::error: Internal problem, this method must only be called once. https://bugreports.qt-project.org/browse/QTBUG-30298 +- Tabbar texts get cut off when styled and elided + https://bugreports.qt-project.org/browse/QTBUG-15203 + Probably fixed crashes ====================== diff --git a/qutebrowser/widgets/_tabbedbrowser.py b/qutebrowser/widgets/_tabbedbrowser.py index 0d3462faa..5fe323ee8 100644 --- a/qutebrowser/widgets/_tabbedbrowser.py +++ b/qutebrowser/widgets/_tabbedbrowser.py @@ -22,13 +22,13 @@ from functools import partial from PyQt5.QtWidgets import QApplication, QSizePolicy from PyQt5.QtCore import pyqtSignal, pyqtSlot, QSize -from PyQt5.QtGui import QClipboard, QIcon +from PyQt5.QtGui import QClipboard import qutebrowser.utils.url as urlutils import qutebrowser.utils.message as message import qutebrowser.config.config as config import qutebrowser.commands.utils as cmdutils -from qutebrowser.widgets._tabwidget import TabWidget +from qutebrowser.widgets._tabwidget import TabWidget, EmptyTabIcon from qutebrowser.widgets.webview import WebView from qutebrowser.browser.signalfilter import SignalFilter from qutebrowser.browser.curcommand import CurCommandDispatcher @@ -470,7 +470,7 @@ class TabbedBrowser(TabWidget): tab: The tab where the signal belongs to. """ tab.signal_cache.clear() - self.setTabIcon(self.indexOf(tab), QIcon()) + self.setTabIcon(self.indexOf(tab), EmptyTabIcon()) @pyqtSlot(str) def on_title_changed(self, text): diff --git a/qutebrowser/widgets/_tabwidget.py b/qutebrowser/widgets/_tabwidget.py index 2a4c26ecd..5c403e5b6 100644 --- a/qutebrowser/widgets/_tabwidget.py +++ b/qutebrowser/widgets/_tabwidget.py @@ -19,12 +19,31 @@ from PyQt5.QtCore import pyqtSlot, Qt from PyQt5.QtWidgets import QTabWidget, QTabBar, QSizePolicy +from PyQt5.QtGui import QIcon, QPixmap import qutebrowser.config.config as config from qutebrowser.config.style import set_register_stylesheet from qutebrowser.utils.style import Style +class EmptyTabIcon(QIcon): + + """An empty icon for a tab. + + Qt somehow cuts text off when padding is used for the tabbar, see + https://bugreports.qt-project.org/browse/QTBUG-15203 + + Until we find a better solution we use this hack of using a simple + transparent icon to get some padding, because when a real favicon is set, + the padding seems to be fine... + """ + + def __init__(self): + pix = QPixmap(2, 16) + pix.fill(Qt.transparent) + super().__init__(pix) + + class TabWidget(QTabWidget): """The tabwidget used for TabbedBrowser. @@ -47,7 +66,6 @@ class TabWidget(QTabWidget): QTabBar::tab {{ {color[tab.bg]} {color[tab.fg]} - padding: 0px 5px 0px 5px; border-right: 2px solid {color[tab.seperator]}; min-width: {config[tabbar][min-tab-width]}px; max-width: {config[tabbar][max-tab-width]}px;