Merge branch 'sebastian-frysztak-master'

This commit is contained in:
Florian Bruhin 2016-10-05 21:20:19 +02:00
commit 69889f6bba
3 changed files with 16 additions and 9 deletions

View File

@ -195,6 +195,7 @@ Contributors, sorted by the number of commits in descending order:
* rikn00
* kanikaa1234
* haitaka
* Sebastian Frysztak
* Nick Ginther
* Michał Góral
* Michael Ilsaas

View File

@ -703,13 +703,10 @@ class TabBarStyle(QCommonStyle):
text_rect.adjust(indicator_width + indicator_padding.left +
indicator_padding.right, 0, 0, 0)
if opt.icon.isNull():
icon_rect = QRect()
else:
icon_rect = self._get_icon_rect(opt, text_rect)
if icon_rect.isValid():
icon_padding = self.pixelMetric(PixelMetrics.icon_padding, opt)
icon_rect = self._get_icon_rect(opt, text_rect)
if icon_rect.isValid():
text_rect.adjust(icon_rect.width() + icon_padding, 0, 0, 0)
text_rect.adjust(icon_rect.width() + icon_padding, 0, 0, 0)
text_rect = self._style.visualRect(opt.direction, opt.rect, text_rect)
return Layouts(text=text_rect, icon=icon_rect,
@ -733,9 +730,17 @@ class TabBarStyle(QCommonStyle):
else QIcon.Disabled)
icon_state = (QIcon.On if opt.state & QStyle.State_Selected
else QIcon.Off)
tab_icon_size = opt.icon.actualSize(icon_size, icon_mode, icon_state)
tab_icon_size = QSize(min(tab_icon_size.width(), icon_size.width()),
min(tab_icon_size.height(), icon_size.height()))
# reserve space for favicon when tab bar is vertical (issue #1968)
position = config.get('tabs', 'position')
if (opt.icon.isNull() and
position in [QTabWidget.East, QTabWidget.West] and
config.get('tabs', 'show-favicons')):
tab_icon_size = icon_size
else:
actual_size = opt.icon.actualSize(icon_size, icon_mode, icon_state)
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_rect = self._style.visualRect(opt.direction, opt.rect, icon_rect)

View File

@ -41,6 +41,7 @@ class TestTabWidget:
'position': 0,
'select-on-remove': 1,
'show': 'always',
'show-favicons': True,
'padding': configtypes.PaddingValues(0, 0, 5, 5),
'indicator-width': 3,
'indicator-padding': configtypes.PaddingValues(2, 2, 0, 4),