Merge remote-tracking branch 'origin/pr/4245'
This commit is contained in:
commit
62ea8f6ec2
@ -108,10 +108,7 @@ class TabWidget(QTabWidget):
|
||||
tab: The tab to pin
|
||||
pinned: Pinned tab state to set.
|
||||
"""
|
||||
bar = self.tabBar()
|
||||
idx = self.indexOf(tab)
|
||||
|
||||
bar.set_tab_data(idx, 'pinned', pinned)
|
||||
tab.data.pinned = pinned
|
||||
self.update_tab_favicon(tab)
|
||||
self.update_tab_title(idx)
|
||||
@ -570,10 +567,10 @@ class TabBar(QTabBar):
|
||||
|
||||
def _tab_pinned(self, index: int) -> bool:
|
||||
"""Return True if tab is pinned."""
|
||||
try:
|
||||
return self.tab_data(index, 'pinned')
|
||||
except KeyError:
|
||||
return False
|
||||
if not 0 <= index < self.count():
|
||||
raise IndexError("Tab index ({}) out of range ({})!".format(
|
||||
index, self.count()))
|
||||
return self.parent().widget(index).data.pinned
|
||||
|
||||
def tabSizeHint(self, index: int):
|
||||
"""Override tabSizeHint to customize qb's tab size.
|
||||
|
@ -20,6 +20,7 @@
|
||||
"""Tests for the custom TabWidget/TabBar."""
|
||||
|
||||
import pytest
|
||||
import functools
|
||||
|
||||
from PyQt5.QtGui import QIcon, QPixmap
|
||||
|
||||
@ -141,3 +142,9 @@ class TestTabWidget:
|
||||
browser.shutdown()
|
||||
|
||||
benchmark(_run_bench)
|
||||
|
||||
def test_tab_pinned_benchmark(self, benchmark, widget, fake_web_tab):
|
||||
"""Benchmark for _tab_pinned."""
|
||||
widget.addTab(fake_web_tab(), 'foobar')
|
||||
tab_bar = widget.tabBar()
|
||||
benchmark(functools.partial(tab_bar._tab_pinned, 0))
|
||||
|
Loading…
Reference in New Issue
Block a user