Add option to expand tabs

This commit is contained in:
Florian Bruhin 2014-06-10 14:30:31 +02:00
parent 2bcbfce8f9
commit 1c63ff620d
2 changed files with 16 additions and 1 deletions

View File

@ -431,6 +431,10 @@ DATA = OrderedDict([
SettingValue(types.Bool(), 'true'), SettingValue(types.Bool(), 'true'),
"Whether to show favicons in the tab bar."), "Whether to show favicons in the tab bar."),
('expand',
SettingValue(types.Bool(), 'false'),
"Whether to expand tabs to use the full window width."),
)), )),
('storage', sect.KeyValue( ('storage', sect.KeyValue(

View File

@ -17,7 +17,7 @@
"""The tab widget used for TabbedBrowser from browser.py.""" """The tab widget used for TabbedBrowser from browser.py."""
from PyQt5.QtCore import pyqtSlot, Qt from PyQt5.QtCore import pyqtSlot, Qt, QSize
from PyQt5.QtWidgets import QTabWidget, QTabBar, QSizePolicy from PyQt5.QtWidgets import QTabWidget, QTabBar, QSizePolicy
from PyQt5.QtGui import QIcon, QPixmap from PyQt5.QtGui import QIcon, QPixmap
@ -131,3 +131,14 @@ class TabBar(QTabBar):
if idx == -1: if idx == -1:
return super().mousePressEvent(e) return super().mousePressEvent(e)
self.tabCloseRequested.emit(idx) self.tabCloseRequested.emit(idx)
def tabSizeHint(self, index):
"""Override tabSizeHint so all tabs are the same size.
https://wiki.python.org/moin/PyQt/Customising%20tab%20bars
"""
if config.get('tabbar', 'expand'):
height = super().tabSizeHint(index).height()
return QSize(self.width() / self.count(), height)
else:
return super().tabSizeHint(index)