This commit is contained in:
thuck 2016-11-11 11:07:30 +01:00
commit 00f2b4df96
5 changed files with 29 additions and 16 deletions

View File

@ -1091,8 +1091,7 @@ class CommandDispatcher:
cmdutils.check_overflow(new_idx, 'int')
self._tabbed_browser.setUpdatesEnabled(False)
try:
color = self._tabbed_browser.tabBar().tab_data(
cur_idx, 'indicator-color')
color = self._tabbed_browser.tab_indicator_color(cur_idx)
self._tabbed_browser.removeTab(cur_idx)
self._tabbed_browser.insertTab(new_idx, tab, icon, label)
self._set_current_index(new_idx)

View File

@ -150,11 +150,11 @@ class WebEngineCaret(browsertab.AbstractCaret):
@pyqtSlot(usertypes.KeyMode)
def _on_mode_entered(self, mode):
log.stub()
pass
@pyqtSlot(usertypes.KeyMode)
def _on_mode_left(self):
log.stub()
pass
def move_to_next_line(self, count=1):
log.stub()

View File

@ -109,6 +109,10 @@ class TabWidget(QTabWidget):
bar.refresh()
def tab_indicator_color(self, idx):
"""Get the tab indicator color for the given index."""
return self.tabBar().tab_indicator_color(idx)
def set_page_title(self, idx, title):
"""Set the tab title user data."""
self.tabBar().set_tab_data(idx, 'page-title', title)
@ -361,6 +365,13 @@ class TabBar(QTabBar):
data = {}
return data[key]
def tab_indicator_color(self, idx):
"""Get the tab indicator color for the given index."""
try:
return self.tab_data(idx, 'indicator-color')
except KeyError:
return QColor()
def page_title(self, idx):
"""Get the tab title user data.
@ -529,10 +540,7 @@ class TabBar(QTabBar):
tab.palette.setColor(QPalette.Window, bg_color)
tab.palette.setColor(QPalette.WindowText, fg_color)
try:
indicator_color = self.tab_data(idx, 'indicator-color')
except KeyError:
indicator_color = QColor()
indicator_color = self.tab_indicator_color(idx)
tab.palette.setColor(QPalette.Base, indicator_color)
if tab.rect.right() < 0 or tab.rect.left() > self.width():
# Don't bother drawing a tab if the entire tab is outside of

View File

@ -38,10 +38,6 @@ class FakeTypingMeta(type):
**_kwds):
pass
def __subclasscheck__(self, cls):
"""We implement this for qutebrowser.commands.command to work."""
return isinstance(cls, FakeTypingMeta)
class FakeUnionMeta(FakeTypingMeta):

View File

@ -32,13 +32,23 @@ def pytyping():
class TestUnion:
def test_python_subclass(self, pytyping):
assert issubclass(pytyping.Union[str, int], pytyping.Union)
assert (type(pytyping.Union[str, int]) is # flake8: disable=E721
type(pytyping.Union))
def test_qute_subclass(self):
assert issubclass(typing.FakeUnion[str, int], typing.FakeUnion)
assert (type(typing.FakeUnion[str, int]) is # flake8: disable=E721
type(typing.FakeUnion))
def test_python_params(self, pytyping):
assert pytyping.Union[str, int].__union_params__ == (str, int)
union = pytyping.Union[str, int]
try:
assert union.__union_params__ == (str, int)
except AttributeError:
assert union.__args__ == (str, int)
def test_qute_params(self):
assert typing.FakeUnion[str, int].__union_params__ == (str, int)
union = typing.FakeUnion[str, int]
try:
assert union.__union_params__ == (str, int)
except AttributeError:
assert union.__args__ == (str, int)