diff --git a/qutebrowser/config/configdata.py b/qutebrowser/config/configdata.py index 915f3ae4d..801278e27 100644 --- a/qutebrowser/config/configdata.py +++ b/qutebrowser/config/configdata.py @@ -625,6 +625,10 @@ def data(readonly=False): "* `{id}`: The internal tab ID of this tab.\n" "* `{scroll_pos}`: The page scroll position."), + ('title-alignment', + SettingValue(typ.TextAlignment(), 'left'), + "Alignment of the text inside of tabs"), + ('mousewheel-tab-switching', SettingValue(typ.Bool(), 'true'), "Switch between tabs using the mouse wheel."), diff --git a/qutebrowser/config/configtypes.py b/qutebrowser/config/configtypes.py index a87c22596..e586b94e3 100644 --- a/qutebrowser/config/configtypes.py +++ b/qutebrowser/config/configtypes.py @@ -29,7 +29,7 @@ import collections import warnings import datetime -from PyQt5.QtCore import QUrl +from PyQt5.QtCore import QUrl, Qt from PyQt5.QtGui import QColor, QFont from PyQt5.QtNetwork import QNetworkProxy from PyQt5.QtWidgets import QTabWidget, QTabBar @@ -1336,6 +1336,22 @@ class Position(MappingType): valid_values=ValidValues('top', 'bottom', 'left', 'right')) +class TextAlignment(MappingType): + + """Alignment of text.""" + + MAPPING = { + 'left': Qt.AlignLeft, + 'right': Qt.AlignRight, + 'center': Qt.AlignCenter, + } + + def __init__(self, none_ok=False): + super().__init__( + none_ok, + valid_values=ValidValues('left', 'right', 'center')) + + class VerticalPosition(BaseType): """The position of the download bar.""" diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py index c67bfd6f2..3693e3e61 100644 --- a/qutebrowser/mainwindow/tabwidget.py +++ b/qutebrowser/mainwindow/tabwidget.py @@ -577,7 +577,8 @@ class TabBarStyle(QCommonStyle): elif element == QStyle.CE_TabBarTabLabel: if not opt.icon.isNull() and layouts.icon.isValid(): self._draw_icon(layouts, opt, p) - alignment = Qt.AlignLeft | Qt.AlignVCenter | Qt.TextHideMnemonic + alignment = (config.get('tabs', 'title-alignment') | + Qt.AlignVCenter | Qt.TextHideMnemonic) self._style.drawItemText(p, layouts.text, alignment, opt.palette, opt.state & QStyle.State_Enabled, opt.text, QPalette.WindowText) diff --git a/tests/unit/mainwindow/test_tabwidget.py b/tests/unit/mainwindow/test_tabwidget.py index 1547d905a..ff2d243df 100644 --- a/tests/unit/mainwindow/test_tabwidget.py +++ b/tests/unit/mainwindow/test_tabwidget.py @@ -24,6 +24,7 @@ import pytest from qutebrowser.mainwindow import tabwidget from qutebrowser.config import configtypes from PyQt5.QtGui import QIcon, QPixmap, QFont, QColor +from PyQt5.QtCore import Qt class TestTabWidget: @@ -44,6 +45,7 @@ class TestTabWidget: 'indicator-width': 3, 'indicator-padding': configtypes.PaddingValues(2, 2, 0, 4), 'title-format': '{index}: {title}', + 'title-alignment': Qt.AlignLeft, }, 'colors': { 'tabs.bg.bar': QColor(),