summaryrefslogtreecommitdiff
path: root/qutebrowser/mainwindow/tabwidget.py
diff options
context:
space:
mode:
Diffstat (limited to 'qutebrowser/mainwindow/tabwidget.py')
-rw-r--r--qutebrowser/mainwindow/tabwidget.py82
1 files changed, 41 insertions, 41 deletions
diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py
index 30cd39570..a7b4fff1b 100644
--- a/qutebrowser/mainwindow/tabwidget.py
+++ b/qutebrowser/mainwindow/tabwidget.py
@@ -65,9 +65,9 @@ class TabWidget(QTabWidget):
QTimer.singleShot, 0, self.update_tab_titles))
bar.currentChanged.connect(self._on_current_changed)
bar.new_tab_requested.connect(self._on_new_tab_requested)
- self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
+ self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed)
self.setDocumentMode(True)
- self.setElideMode(Qt.ElideRight)
+ self.setElideMode(Qt.TextElideMode.ElideRight)
self.setUsesScrollButtons(True)
bar.setDrawBase(False)
self._init_config()
@@ -83,7 +83,7 @@ class TabWidget(QTabWidget):
selection_behavior = config.val.tabs.select_on_remove
self.setTabPosition(position)
tabbar.vertical = position in [ # type: ignore[attr-defined]
- QTabWidget.West, QTabWidget.East]
+ QTabWidget.TabPosition.West, QTabWidget.TabPosition.East]
tabbar.setSelectionBehaviorOnRemove(selection_behavior)
tabbar.refresh()
@@ -345,7 +345,7 @@ class TabWidget(QTabWidget):
config.cache['tabs.pinned.shrink'] and
not self.tabBar().vertical and
tab is not None and tab.data.pinned):
- icon = self.style().standardIcon(QStyle.SP_FileIcon)
+ icon = self.style().standardIcon(QStyle.StandardPixmap.SP_FileIcon)
super().setTabIcon(idx, icon)
@@ -516,8 +516,8 @@ class TabBar(QTabBar):
Also keep track of if we are currently in a drag."""
self.drag_in_progress = True
button = config.val.tabs.close_mouse_button
- if (e.button() == Qt.RightButton and button == 'right' or
- e.button() == Qt.MiddleButton and button == 'middle'):
+ if (e.button() == Qt.MouseButton.RightButton and button == 'right' or
+ e.button() == Qt.MouseButton.MiddleButton and button == 'middle'):
e.accept()
idx = self.tabAt(e.pos())
if idx == -1:
@@ -577,7 +577,7 @@ class TabBar(QTabBar):
def _text_to_width(text):
# Calculate text width taking into account qt mnemonics
- return self.fontMetrics().size(Qt.TextShowMnemonic, text).width()
+ return self.fontMetrics().size(Qt.TextFlag.TextShowMnemonic, text).width()
text_width = min(_text_to_width(text),
_text_to_width(tab_text))
padding = config.cache['tabs.padding']
@@ -679,14 +679,14 @@ class TabBar(QTabBar):
setting += '.selected'
setting += '.odd' if (idx + 1) % 2 else '.even'
- tab.palette.setColor(QPalette.Window,
+ tab.palette.setColor(QPalette.ColorRole.Window,
config.cache[setting + '.bg'])
- tab.palette.setColor(QPalette.WindowText,
+ tab.palette.setColor(QPalette.ColorRole.WindowText,
config.cache[setting + '.fg'])
indicator_color = self.tab_indicator_color(idx)
- tab.palette.setColor(QPalette.Base, indicator_color)
- p.drawControl(QStyle.CE_TabBarTab, tab)
+ tab.palette.setColor(QPalette.ColorRole.Base, indicator_color)
+ p.drawControl(QStyle.ControlElement.CE_TabBarTab, tab)
def tabInserted(self, idx):
"""Update visibility when a tab was inserted."""
@@ -796,12 +796,12 @@ class TabBarStyle(QCommonStyle):
p: QPainter
"""
qtutils.ensure_valid(layouts.icon)
- icon_mode = (QIcon.Normal if opt.state & QStyle.State_Enabled
- else QIcon.Disabled)
- icon_state = (QIcon.On if opt.state & QStyle.State_Selected
- else QIcon.Off)
+ icon_mode = (QIcon.Mode.Normal if opt.state & QStyle.StateFlag.State_Enabled
+ else QIcon.Mode.Disabled)
+ icon_state = (QIcon.State.On if opt.state & QStyle.StateFlag.State_Selected
+ else QIcon.State.Off)
icon = opt.icon.pixmap(opt.iconSize, icon_mode, icon_state)
- self._style.drawItemPixmap(p, layouts.icon, Qt.AlignCenter, icon)
+ self._style.drawItemPixmap(p, layouts.icon, Qt.AlignmentFlag.AlignCenter, icon)
def drawControl(self, element, opt, p, widget=None):
"""Override drawControl to draw odd tabs in a different color.
@@ -815,8 +815,8 @@ class TabBarStyle(QCommonStyle):
p: QPainter
widget: QWidget
"""
- if element not in [QStyle.CE_TabBarTab, QStyle.CE_TabBarTabShape,
- QStyle.CE_TabBarTabLabel]:
+ if element not in [QStyle.ControlElement.CE_TabBarTab, QStyle.ControlElement.CE_TabBarTabShape,
+ QStyle.ControlElement.CE_TabBarTabLabel]:
# Let the real style draw it.
self._style.drawControl(element, opt, p, widget)
return
@@ -826,28 +826,28 @@ class TabBarStyle(QCommonStyle):
log.misc.warning("Could not get layouts for tab!")
return
- if element == QStyle.CE_TabBarTab:
+ if element == QStyle.ControlElement.CE_TabBarTab:
# We override this so we can control TabBarTabShape/TabBarTabLabel.
- self.drawControl(QStyle.CE_TabBarTabShape, opt, p, widget)
- self.drawControl(QStyle.CE_TabBarTabLabel, opt, p, widget)
- elif element == QStyle.CE_TabBarTabShape:
+ self.drawControl(QStyle.ControlElement.CE_TabBarTabShape, opt, p, widget)
+ self.drawControl(QStyle.ControlElement.CE_TabBarTabLabel, opt, p, widget)
+ elif element == QStyle.ControlElement.CE_TabBarTabShape:
p.fillRect(opt.rect, opt.palette.window())
self._draw_indicator(layouts, opt, p)
# We use super() rather than self._style here because we don't want
# any sophisticated drawing.
- super().drawControl(QStyle.CE_TabBarTabShape, opt, p, widget)
- elif element == QStyle.CE_TabBarTabLabel:
+ super().drawControl(QStyle.ControlElement.CE_TabBarTabShape, opt, p, widget)
+ elif element == QStyle.ControlElement.CE_TabBarTabLabel:
if not opt.icon.isNull() and layouts.icon.isValid():
self._draw_icon(layouts, opt, p)
alignment = (config.cache['tabs.title.alignment'] |
- Qt.AlignVCenter | Qt.TextHideMnemonic)
+ Qt.AlignmentFlag.AlignVCenter | Qt.TextFlag.TextHideMnemonic)
self._style.drawItemText(p,
layouts.text,
int(alignment),
opt.palette,
- bool(opt.state & QStyle.State_Enabled),
+ bool(opt.state & QStyle.StateFlag.State_Enabled),
opt.text,
- QPalette.WindowText)
+ QPalette.ColorRole.WindowText)
else:
raise ValueError("Invalid element {!r}".format(element))
@@ -862,11 +862,11 @@ class TabBarStyle(QCommonStyle):
Return:
An int.
"""
- if metric in [QStyle.PM_TabBarTabShiftHorizontal,
- QStyle.PM_TabBarTabShiftVertical,
- QStyle.PM_TabBarTabHSpace,
- QStyle.PM_TabBarTabVSpace,
- QStyle.PM_TabBarScrollButtonWidth]:
+ if metric in [QStyle.PixelMetric.PM_TabBarTabShiftHorizontal,
+ QStyle.PixelMetric.PM_TabBarTabShiftVertical,
+ QStyle.PixelMetric.PM_TabBarTabHSpace,
+ QStyle.PixelMetric.PM_TabBarTabVSpace,
+ QStyle.PixelMetric.PM_TabBarScrollButtonWidth]:
return 0
else:
return self._style.pixelMetric(metric, option, widget)
@@ -882,14 +882,14 @@ class TabBarStyle(QCommonStyle):
Return:
A QRect.
"""
- if sr == QStyle.SE_TabBarTabText:
+ if sr == QStyle.SubElement.SE_TabBarTabText:
layouts = self._tab_layout(opt)
if layouts is None:
log.misc.warning("Could not get layouts for tab!")
return QRect()
return layouts.text
- elif sr in [QStyle.SE_TabWidgetTabBar,
- QStyle.SE_TabBarScrollLeftButton]:
+ elif sr in [QStyle.SubElement.SE_TabWidgetTabBar,
+ QStyle.SubElement.SE_TabBarScrollLeftButton]:
# Handling SE_TabBarScrollLeftButton so the left scroll button is
# aligned properly. Otherwise, empty space will be shown after the
# last tab even though the button width is set to 0
@@ -962,15 +962,15 @@ class TabBarStyle(QCommonStyle):
"""
icon_size = opt.iconSize
if not icon_size.isValid():
- icon_extent = self.pixelMetric(QStyle.PM_SmallIconSize)
+ icon_extent = self.pixelMetric(QStyle.PixelMetric.PM_SmallIconSize)
icon_size = QSize(icon_extent, icon_extent)
- icon_mode = (QIcon.Normal if opt.state & QStyle.State_Enabled
- else QIcon.Disabled)
- icon_state = (QIcon.On if opt.state & QStyle.State_Selected
- else QIcon.Off)
+ icon_mode = (QIcon.Mode.Normal if opt.state & QStyle.StateFlag.State_Enabled
+ else QIcon.Mode.Disabled)
+ icon_state = (QIcon.State.On if opt.state & QStyle.StateFlag.State_Selected
+ else QIcon.State.Off)
# reserve space for favicon when tab bar is vertical (issue #1968)
position = config.cache['tabs.position']
- if (position in [QTabWidget.East, QTabWidget.West] and
+ if (position in [QTabWidget.TabPosition.East, QTabWidget.TabPosition.West] and
config.cache['tabs.favicons.show'] != 'never'):
tab_icon_size = icon_size
else: