Merge commit '6549fd84ce461d3098c13818219df4e4bfd6b444' into haasn/favicon-scale
This commit is contained in:
commit
5823af0b7b
@ -126,6 +126,7 @@
|
||||
|<<tabs-close-mouse-button,close-mouse-button>>|On which mouse button to close tabs.
|
||||
|<<tabs-position,position>>|The position of the tab bar.
|
||||
|<<tabs-show-favicons,show-favicons>>|Whether to show favicons in the tab bar.
|
||||
|<<tabs-favicon-scale,favicon-scale>>|Scale for favicons in the tab bar. The tab size is unchanged, so big favicons also require extra `tabs->padding`.
|
||||
|<<tabs-width,width>>|The width of the tab bar if it's vertical, in px or as percentage of the window.
|
||||
|<<tabs-indicator-width,indicator-width>>|Width of the progress indicator (0 to disable).
|
||||
|<<tabs-tabs-are-windows,tabs-are-windows>>|Whether to open windows instead of tabs.
|
||||
@ -1206,6 +1207,12 @@ Valid values:
|
||||
|
||||
Default: +pass:[true]+
|
||||
|
||||
[[tabs-favicon-scale]]
|
||||
=== favicon-scale
|
||||
Scale for favicons in the tab bar. The tab size is unchanged, so big favicons also require extra `tabs->padding`.
|
||||
|
||||
Default: +pass:[1.0]+
|
||||
|
||||
[[tabs-width]]
|
||||
=== width
|
||||
The width of the tab bar if it's vertical, in px or as percentage of the window.
|
||||
|
@ -680,6 +680,11 @@ def data(readonly=False):
|
||||
SettingValue(typ.Bool(), 'true'),
|
||||
"Whether to show favicons in the tab bar."),
|
||||
|
||||
('favicon-scale',
|
||||
SettingValue(typ.Float(minval=0.0), '1.0'),
|
||||
"Scale for favicons in the tab bar. The tab size is unchanged, "
|
||||
"so big favicons also require extra `tabs->padding`."),
|
||||
|
||||
('width',
|
||||
SettingValue(typ.PercOrInt(minperc=0, maxperc=100, minint=1),
|
||||
'20%'),
|
||||
|
@ -22,7 +22,8 @@
|
||||
import collections
|
||||
import functools
|
||||
|
||||
from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt, QSize, QRect, QTimer, QUrl
|
||||
from PyQt5.QtCore import (pyqtSignal, pyqtSlot, Qt, QSize, QRect, QPoint,
|
||||
QTimer, QUrl)
|
||||
from PyQt5.QtWidgets import (QTabWidget, QTabBar, QSizePolicy, QCommonStyle,
|
||||
QStyle, QStylePainter, QStyleOptionTab,
|
||||
QStyleFactory)
|
||||
@ -274,6 +275,7 @@ class TabBar(QTabBar):
|
||||
self.set_font()
|
||||
config_obj = objreg.get('config')
|
||||
config_obj.changed.connect(self.set_font)
|
||||
config_obj.changed.connect(self.set_icon_size)
|
||||
self.vertical = False
|
||||
self._page_fullscreen = False
|
||||
self._auto_hide_timer = QTimer()
|
||||
@ -375,7 +377,13 @@ class TabBar(QTabBar):
|
||||
def set_font(self):
|
||||
"""Set the tab bar font."""
|
||||
self.setFont(config.get('fonts', 'tabbar'))
|
||||
self.set_icon_size()
|
||||
|
||||
@config.change_filter('tabs', 'favicon-scale')
|
||||
def set_icon_size(self):
|
||||
"""Set the tab bar favicon size."""
|
||||
size = self.fontMetrics().height() - 2
|
||||
size *= config.get('tabs', 'favicon-scale')
|
||||
self.setIconSize(QSize(size, size))
|
||||
|
||||
@config.change_filter('colors', 'tabs.bg.bar')
|
||||
@ -771,7 +779,7 @@ class TabBarStyle(QCommonStyle):
|
||||
tab_icon_size = QSize(
|
||||
min(actual_size.width(), icon_size.width()),
|
||||
min(actual_size.height(), icon_size.height()))
|
||||
icon_rect = QRect(text_rect.left(), text_rect.top() + 1,
|
||||
tab_icon_size.width(), tab_icon_size.height())
|
||||
icon_top = text_rect.center().y() + 1 - tab_icon_size.height() / 2
|
||||
icon_rect = QRect(QPoint(text_rect.left(), icon_top), tab_icon_size)
|
||||
icon_rect = self._style.visualRect(opt.direction, opt.rect, icon_rect)
|
||||
return icon_rect
|
||||
|
@ -44,6 +44,7 @@ class TestTabWidget:
|
||||
'select-on-remove': 1,
|
||||
'show': 'always',
|
||||
'show-favicons': True,
|
||||
'favicon-scale': 1.0,
|
||||
'padding': configtypes.PaddingValues(0, 0, 5, 5),
|
||||
'indicator-width': 3,
|
||||
'indicator-padding': configtypes.PaddingValues(2, 2, 0, 4),
|
||||
|
Loading…
Reference in New Issue
Block a user