Make sure the tab indicator color is always available
This commit is contained in:
parent
6d72bce4b6
commit
94e2a4dccc
@ -1041,8 +1041,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)
|
||||
|
@ -91,6 +91,10 @@ class TabWidget(QTabWidget):
|
||||
bar.set_tab_data(idx, 'indicator-color', color)
|
||||
bar.update(bar.tabRect(idx))
|
||||
|
||||
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)
|
||||
@ -329,6 +333,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.
|
||||
|
||||
@ -478,10 +489,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
|
||||
|
Loading…
Reference in New Issue
Block a user