Work around the tabbar cut font issue

This commit is contained in:
Florian Bruhin 2014-05-12 21:23:16 +02:00
parent fd6e739281
commit 297a0e65c4
3 changed files with 25 additions and 4 deletions

3
TODO
View File

@ -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
======================

View File

@ -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):

View File

@ -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;