Merge remote-tracking branch 'origin/pr/3692'
This commit is contained in:
commit
0ee9d73fe2
@ -1409,6 +1409,19 @@ tabs.width:
|
|||||||
desc: "Width (in pixels or as percentage of the window) of the tab bar if
|
desc: "Width (in pixels or as percentage of the window) of the tab bar if
|
||||||
it's vertical."
|
it's vertical."
|
||||||
|
|
||||||
|
tabs.min_width:
|
||||||
|
default: -1
|
||||||
|
type:
|
||||||
|
name: Int
|
||||||
|
minval: -1
|
||||||
|
maxval: maxint
|
||||||
|
desc: >-
|
||||||
|
Minimum width (in pixels) of tabs (-1 for the default minimum size behavior).
|
||||||
|
|
||||||
|
This setting only applies when tabs are horizontal.
|
||||||
|
|
||||||
|
This setting does not apply to pinned tabs, unless `tabs.pinned.shrink` is False.
|
||||||
|
|
||||||
tabs.width.indicator:
|
tabs.width.indicator:
|
||||||
renamed: tabs.indicator.width
|
renamed: tabs.indicator.width
|
||||||
|
|
||||||
|
@ -358,7 +358,9 @@ class TabBar(QTabBar):
|
|||||||
# Clear _minimum_tab_size_hint_helper cache when appropriate
|
# Clear _minimum_tab_size_hint_helper cache when appropriate
|
||||||
if option in ["tabs.indicator.padding",
|
if option in ["tabs.indicator.padding",
|
||||||
"tabs.padding",
|
"tabs.padding",
|
||||||
"tabs.indicator.width"]:
|
"tabs.indicator.width",
|
||||||
|
"tabs.min_width",
|
||||||
|
"tabs.pinned.shrink"]:
|
||||||
self._minimum_tab_size_hint_helper.cache_clear()
|
self._minimum_tab_size_hint_helper.cache_clear()
|
||||||
|
|
||||||
def _on_show_switching_delay_changed(self):
|
def _on_show_switching_delay_changed(self):
|
||||||
@ -478,6 +480,7 @@ class TabBar(QTabBar):
|
|||||||
index: The index of the tab to get a size hint for.
|
index: The index of the tab to get a size hint for.
|
||||||
ellipsis: Whether to use ellipsis to calculate width
|
ellipsis: Whether to use ellipsis to calculate width
|
||||||
instead of the tab's text.
|
instead of the tab's text.
|
||||||
|
Forced to False for pinned tabs.
|
||||||
Return:
|
Return:
|
||||||
A QSize of the smallest tab size we can make.
|
A QSize of the smallest tab size we can make.
|
||||||
"""
|
"""
|
||||||
@ -489,14 +492,19 @@ class TabBar(QTabBar):
|
|||||||
else:
|
else:
|
||||||
icon_width = min(icon.actualSize(self.iconSize()).width(),
|
icon_width = min(icon.actualSize(self.iconSize()).width(),
|
||||||
self.iconSize().width()) + icon_padding
|
self.iconSize().width()) + icon_padding
|
||||||
|
|
||||||
|
pinned = self._tab_pinned(index)
|
||||||
|
if pinned:
|
||||||
|
# Never consider ellipsis an option for pinned tabs
|
||||||
|
ellipsis = False
|
||||||
return self._minimum_tab_size_hint_helper(self.tabText(index),
|
return self._minimum_tab_size_hint_helper(self.tabText(index),
|
||||||
icon_width,
|
icon_width, ellipsis,
|
||||||
ellipsis)
|
pinned)
|
||||||
|
|
||||||
@functools.lru_cache(maxsize=2**9)
|
@functools.lru_cache(maxsize=2**9)
|
||||||
def _minimum_tab_size_hint_helper(self, tab_text: str,
|
def _minimum_tab_size_hint_helper(self, tab_text: str,
|
||||||
icon_width: int,
|
icon_width: int,
|
||||||
ellipsis: bool) -> QSize:
|
ellipsis: bool, pinned: bool) -> QSize:
|
||||||
"""Helper function to cache tab results.
|
"""Helper function to cache tab results.
|
||||||
|
|
||||||
Config values accessed in here should be added to _on_config_changed to
|
Config values accessed in here should be added to _on_config_changed to
|
||||||
@ -521,6 +529,10 @@ class TabBar(QTabBar):
|
|||||||
height = self.fontMetrics().height() + padding_v
|
height = self.fontMetrics().height() + padding_v
|
||||||
width = (text_width + icon_width +
|
width = (text_width + icon_width +
|
||||||
padding_h + indicator_width)
|
padding_h + indicator_width)
|
||||||
|
min_width = config.val.tabs.min_width
|
||||||
|
if (not self.vertical and min_width > 0 and
|
||||||
|
not pinned or not config.val.tabs.pinned.shrink):
|
||||||
|
width = max(min_width, width)
|
||||||
return QSize(width, height)
|
return QSize(width, height)
|
||||||
|
|
||||||
def _pinned_statistics(self) -> (int, int):
|
def _pinned_statistics(self) -> (int, int):
|
||||||
@ -550,6 +562,12 @@ class TabBar(QTabBar):
|
|||||||
Return:
|
Return:
|
||||||
A QSize.
|
A QSize.
|
||||||
"""
|
"""
|
||||||
|
if self.count() == 0:
|
||||||
|
# This happens on startup on macOS.
|
||||||
|
# We return it directly rather than setting `size' because we don't
|
||||||
|
# want to ensure it's valid in this special case.
|
||||||
|
return QSize()
|
||||||
|
|
||||||
minimum_size = self.minimumTabSizeHint(index)
|
minimum_size = self.minimumTabSizeHint(index)
|
||||||
height = minimum_size.height()
|
height = minimum_size.height()
|
||||||
if self.vertical:
|
if self.vertical:
|
||||||
@ -562,11 +580,6 @@ class TabBar(QTabBar):
|
|||||||
else:
|
else:
|
||||||
width = int(confwidth)
|
width = int(confwidth)
|
||||||
size = QSize(max(minimum_size.width(), width), height)
|
size = QSize(max(minimum_size.width(), width), height)
|
||||||
elif self.count() == 0:
|
|
||||||
# This happens on startup on macOS.
|
|
||||||
# We return it directly rather than setting `size' because we don't
|
|
||||||
# want to ensure it's valid in this special case.
|
|
||||||
return QSize()
|
|
||||||
else:
|
else:
|
||||||
if config.val.tabs.pinned.shrink:
|
if config.val.tabs.pinned.shrink:
|
||||||
pinned = self._tab_pinned(index)
|
pinned = self._tab_pinned(index)
|
||||||
|
Loading…
Reference in New Issue
Block a user