qutebrowser/qutebrowser/widgets/tabbar.py

54 lines
1.4 KiB
Python
Raw Normal View History

2014-01-29 15:30:19 +01:00
"""The tab widget used for TabbedBrowser from browser.py."""
2014-01-30 22:29:01 +01:00
from PyQt5.QtWidgets import QTabWidget, QSizePolicy
2014-01-19 16:56:33 +01:00
from PyQt5.QtCore import Qt
2013-12-15 20:29:39 +01:00
2014-01-28 12:21:00 +01:00
import qutebrowser.utils.config as config
2014-01-28 23:04:02 +01:00
2013-12-15 20:29:39 +01:00
class TabWidget(QTabWidget):
2014-01-29 15:30:19 +01:00
"""The tabwidget used for TabbedBrowser."""
2013-12-15 20:29:39 +01:00
2014-01-27 23:12:43 +01:00
# FIXME there is still some ugly 1px white stripe from somewhere if we do
# background-color: grey for QTabBar...
_stylesheet = """
2014-01-28 12:21:00 +01:00
QTabWidget::pane {{
position: absolute;
top: 0px;
2014-01-28 12:21:00 +01:00
}}
2014-01-28 12:21:00 +01:00
QTabBar {{
2014-01-28 15:20:58 +01:00
font-family: {monospace};
font-size: 8pt;
2014-01-30 22:29:01 +01:00
height: 13px;
2014-01-28 12:21:00 +01:00
}}
2013-12-15 20:29:39 +01:00
2014-01-28 12:21:00 +01:00
QTabBar::tab {{
{color[tab.bg]}
{color[tab.fg]}
padding-left: 5px;
padding-right: 5px;
padding-top: 0px;
padding-bottom: 0px;
2014-01-28 12:21:00 +01:00
}}
2013-12-15 20:29:39 +01:00
2014-01-28 12:21:00 +01:00
QTabBar::tab:first, QTabBar::tab:middle {{
border-right: 1px solid {color[tab.seperator]};
}}
2014-01-27 23:12:43 +01:00
2014-01-28 12:21:00 +01:00
QTabBar::tab:selected {{
{color[tab.bg.selected]}
}}
"""
def __init__(self, parent):
2014-01-30 22:29:13 +01:00
# FIXME export some settings (TabPosition, tabsClosable,
# usesScrollButtons)
super().__init__(parent)
2014-01-30 22:29:01 +01:00
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
2014-01-28 12:21:00 +01:00
self.setStyleSheet(config.get_stylesheet(self._stylesheet))
2013-12-15 20:29:39 +01:00
self.setDocumentMode(True)
2014-01-30 22:29:26 +01:00
self.setMovable(True)
2014-01-19 16:56:33 +01:00
self.setElideMode(Qt.ElideRight)