diff options
author | Florian Bruhin <me@the-compiler.org> | 2021-08-26 16:47:12 +0200 |
---|---|---|
committer | Florian Bruhin <me@the-compiler.org> | 2021-08-26 16:47:12 +0200 |
commit | ac9d67cce0dbecdde14c474db855243e9746ba04 (patch) | |
tree | b564440308dc40b8ae40209a33cb1c47c95e17c6 /qutebrowser/mainwindow | |
parent | ba30ac2af0860a8c92503179f6867ab0b46e3d31 (diff) | |
download | qutebrowser-ac9d67cce0dbecdde14c474db855243e9746ba04.tar.gz qutebrowser-ac9d67cce0dbecdde14c474db855243e9746ba04.zip |
Automatically rewrite enums
See #5904
Diffstat (limited to 'qutebrowser/mainwindow')
-rw-r--r-- | qutebrowser/mainwindow/mainwindow.py | 20 | ||||
-rw-r--r-- | qutebrowser/mainwindow/messageview.py | 6 | ||||
-rw-r--r-- | qutebrowser/mainwindow/prompt.py | 24 | ||||
-rw-r--r-- | qutebrowser/mainwindow/statusbar/bar.py | 4 | ||||
-rw-r--r-- | qutebrowser/mainwindow/statusbar/command.py | 6 | ||||
-rw-r--r-- | qutebrowser/mainwindow/statusbar/percentage.py | 2 | ||||
-rw-r--r-- | qutebrowser/mainwindow/statusbar/progress.py | 2 | ||||
-rw-r--r-- | qutebrowser/mainwindow/statusbar/textbase.py | 10 | ||||
-rw-r--r-- | qutebrowser/mainwindow/tabbedbrowser.py | 6 | ||||
-rw-r--r-- | qutebrowser/mainwindow/tabwidget.py | 82 |
10 files changed, 81 insertions, 81 deletions
diff --git a/qutebrowser/mainwindow/mainwindow.py b/qutebrowser/mainwindow/mainwindow.py index 067c5b8c0..a3e6722af 100644 --- a/qutebrowser/mainwindow/mainwindow.py +++ b/qutebrowser/mainwindow/mainwindow.py @@ -88,12 +88,12 @@ def get_window(*, via_ipc: bool, def raise_window(window, alert=True): """Raise the given MainWindow object.""" - window.setWindowState(window.windowState() & ~Qt.WindowMinimized) - window.setWindowState(window.windowState() | Qt.WindowActive) + window.setWindowState(window.windowState() & ~Qt.WindowState.WindowMinimized) + window.setWindowState(window.windowState() | Qt.WindowState.WindowActive) window.raise_() # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-69568 QCoreApplication.processEvents( # type: ignore[call-overload] - QEventLoop.ExcludeUserInputEvents | QEventLoop.ExcludeSocketNotifiers) + QEventLoop.ProcessEventsFlag.ExcludeUserInputEvents | QEventLoop.ProcessEventsFlag.ExcludeSocketNotifiers) if not sip.isdeleted(window): # Could be deleted by the events run above @@ -202,10 +202,10 @@ class MainWindow(QWidget): from qutebrowser.mainwindow import tabbedbrowser from qutebrowser.mainwindow.statusbar import bar - self.setAttribute(Qt.WA_DeleteOnClose) + self.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose) if config.val.window.transparent: - self.setAttribute(Qt.WA_TranslucentBackground) - self.palette().setColor(QPalette.Window, Qt.transparent) + self.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground) + self.palette().setColor(QPalette.ColorRole.Window, Qt.GlobalColor.transparent) self._overlays: MutableSequence[_OverlayInfoType] = [] self.win_id = next(win_id_gen) @@ -305,7 +305,7 @@ class MainWindow(QWidget): if not widget.isVisible(): return - if widget.sizePolicy().horizontalPolicy() == QSizePolicy.Expanding: + if widget.sizePolicy().horizontalPolicy() == QSizePolicy.Policy.Expanding: width = self.width() - 2 * padding if widget.hasHeightForWidth(): height = widget.heightForWidth(width) @@ -561,10 +561,10 @@ class MainWindow(QWidget): def _set_decoration(self, hidden): """Set the visibility of the window decoration via Qt.""" - window_flags: int = Qt.Window + window_flags: int = Qt.WindowType.Window refresh_window = self.isVisible() if hidden: - window_flags |= Qt.CustomizeWindowHint | Qt.NoDropShadowWindowHint + window_flags |= Qt.WindowType.CustomizeWindowHint | Qt.WindowType.NoDropShadowWindowHint self.setWindowFlags(cast(Qt.WindowFlags, window_flags)) if refresh_window: self.show() @@ -575,7 +575,7 @@ class MainWindow(QWidget): if on: self.state_before_fullscreen = self.windowState() self.setWindowState( - Qt.WindowFullScreen | # type: ignore[arg-type] + Qt.WindowState.WindowFullScreen | # type: ignore[arg-type] self.state_before_fullscreen) # type: ignore[operator] elif self.isFullScreen(): self.setWindowState(self.state_before_fullscreen) diff --git a/qutebrowser/mainwindow/messageview.py b/qutebrowser/mainwindow/messageview.py index e4906badd..908a0c7bf 100644 --- a/qutebrowser/mainwindow/messageview.py +++ b/qutebrowser/mainwindow/messageview.py @@ -42,7 +42,7 @@ class Message(QLabel): super().__init__(text, parent) self.replace = replace self.level = level - self.setAttribute(Qt.WA_StyledBackground, True) + self.setAttribute(Qt.WidgetAttribute.WA_StyledBackground, True) self.setWordWrap(True) qss = """ padding-top: 2px; @@ -87,7 +87,7 @@ class MessageView(QWidget): self._vbox = QVBoxLayout(self) self._vbox.setContentsMargins(0, 0, 0, 0) self._vbox.setSpacing(0) - self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) + self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed) self._clear_timer = QTimer() self._clear_timer.timeout.connect(self.clear_messages) @@ -152,5 +152,5 @@ class MessageView(QWidget): def mousePressEvent(self, e): """Clear messages when they are clicked on.""" - if e.button() in [Qt.LeftButton, Qt.MiddleButton, Qt.RightButton]: + if e.button() in [Qt.MouseButton.LeftButton, Qt.MouseButton.MiddleButton, Qt.MouseButton.RightButton]: self.clear_messages() diff --git a/qutebrowser/mainwindow/prompt.py b/qutebrowser/mainwindow/prompt.py index 9ba02b93e..4653c64b4 100644 --- a/qutebrowser/mainwindow/prompt.py +++ b/qutebrowser/mainwindow/prompt.py @@ -196,7 +196,7 @@ class PromptQueue(QObject): question.completed.connect(loop.deleteLater) log.prompt.debug("Starting loop.exec() for {}".format(question)) flags = cast(QEventLoop.ProcessEventsFlags, - QEventLoop.ExcludeSocketNotifiers) + QEventLoop.ProcessEventsFlag.ExcludeSocketNotifiers) loop.exec(flags) log.prompt.debug("Ending loop.exec() for {}".format(question)) @@ -293,7 +293,7 @@ class PromptContainer(QWidget): self._prompt: Optional[_BasePrompt] = None self.setObjectName('PromptContainer') - self.setAttribute(Qt.WA_StyledBackground, True) + self.setAttribute(Qt.WidgetAttribute.WA_StyledBackground, True) stylesheet.set_register(self) message.global_bridge.prompt_done.connect(self._on_prompt_done) @@ -479,11 +479,11 @@ class LineEdit(QLineEdit): background-color: transparent; } """) - self.setAttribute(Qt.WA_MacShowFocusRect, False) + self.setAttribute(Qt.WidgetAttribute.WA_MacShowFocusRect, False) def keyPressEvent(self, e): """Override keyPressEvent to paste primary selection on Shift + Ins.""" - if e.key() == Qt.Key_Insert and e.modifiers() == Qt.ShiftModifier: + if e.key() == Qt.Key.Key_Insert and e.modifiers() == Qt.KeyboardModifier.ShiftModifier: try: text = utils.get_clipboard(selection=True, fallback=True) except utils.ClipboardError: # pragma: no cover @@ -524,7 +524,7 @@ class _BasePrompt(QWidget): # Not doing any HTML escaping here as the text can be formatted text_label = QLabel(question.text) text_label.setWordWrap(True) - text_label.setTextInteractionFlags(Qt.TextSelectableByMouse) + text_label.setTextInteractionFlags(Qt.TextInteractionFlag.TextSelectableByMouse) self._vbox.addWidget(text_label) def _init_key_label(self): @@ -554,7 +554,7 @@ class _BasePrompt(QWidget): self._key_grid.addWidget(key_label, i, 0) self._key_grid.addWidget(text_label, i, 1) - spacer = QSpacerItem(0, 0, QSizePolicy.Expanding) + spacer = QSpacerItem(0, 0, QSizePolicy.Policy.Expanding) self._key_grid.addItem(spacer, 0, 2) self._vbox.addLayout(self._key_grid) @@ -628,7 +628,7 @@ class FilenamePrompt(_BasePrompt): self._set_fileview_root(question.default) if config.val.prompt.filebrowser: - self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) + self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Preferred) self._to_complete = '' self._root_index = QModelIndex() @@ -771,8 +771,8 @@ class FilenamePrompt(_BasePrompt): selmodel.setCurrentIndex( idx, - QItemSelectionModel.ClearAndSelect | # type: ignore[arg-type] - QItemSelectionModel.Rows) + QItemSelectionModel.SelectionFlag.ClearAndSelect | # type: ignore[arg-type] + QItemSelectionModel.SelectionFlag.Rows) self._insert_path(idx, clicked=False) def _do_completion(self, idx, which): @@ -795,7 +795,7 @@ class DownloadFilenamePrompt(FilenamePrompt): def __init__(self, question, parent=None): super().__init__(question, parent) self._file_model.setFilter( - QDir.AllDirs | QDir.Drives | QDir.NoDot) # type: ignore[arg-type] + QDir.Filter.AllDirs | QDir.Filter.Drives | QDir.Filter.NoDot) # type: ignore[arg-type] def accept(self, value=None, save=False): done = super().accept(value, save) @@ -838,7 +838,7 @@ class AuthenticationPrompt(_BasePrompt): password_label = QLabel("Password:", self) self._password_lineedit = LineEdit(self) - self._password_lineedit.setEchoMode(QLineEdit.Password) + self._password_lineedit.setEchoMode(QLineEdit.EchoMode.Password) grid = QGridLayout() grid.addWidget(user_label, 1, 0) @@ -973,4 +973,4 @@ def init(): global prompt_queue prompt_queue = PromptQueue() message.global_bridge.ask_question.connect( # type: ignore[call-arg] - prompt_queue.ask_question, Qt.DirectConnection) + prompt_queue.ask_question, Qt.ConnectionType.DirectConnection) diff --git a/qutebrowser/mainwindow/statusbar/bar.py b/qutebrowser/mainwindow/statusbar/bar.py index 3f881a3d2..0c40b2840 100644 --- a/qutebrowser/mainwindow/statusbar/bar.py +++ b/qutebrowser/mainwindow/statusbar/bar.py @@ -165,10 +165,10 @@ class StatusBar(QWidget): def __init__(self, *, win_id, private, parent=None): super().__init__(parent) self.setObjectName(self.__class__.__name__) - self.setAttribute(Qt.WA_StyledBackground) + self.setAttribute(Qt.WidgetAttribute.WA_StyledBackground) stylesheet.set_register(self) - self.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Fixed) + self.setSizePolicy(QSizePolicy.Policy.Ignored, QSizePolicy.Policy.Fixed) self._win_id = win_id self._color_flags = ColorFlags() diff --git a/qutebrowser/mainwindow/statusbar/command.py b/qutebrowser/mainwindow/statusbar/command.py index fe90c216d..dbb4a4626 100644 --- a/qutebrowser/mainwindow/statusbar/command.py +++ b/qutebrowser/mainwindow/statusbar/command.py @@ -69,7 +69,7 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit): command_history = objreg.get('command-history') self.history.history = command_history.data self.history.changed.connect(command_history.changed) - self.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Ignored) + self.setSizePolicy(QSizePolicy.Policy.MinimumExpanding, QSizePolicy.Policy.Ignored) self.cursorPositionChanged.connect(self.update_completion) self.textChanged.connect(self.update_completion) @@ -259,12 +259,12 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit): without command_accept to be called. """ text = self.text() - if text in modeparsers.STARTCHARS and e.key() == Qt.Key_Backspace: + if text in modeparsers.STARTCHARS and e.key() == Qt.Key.Key_Backspace: e.accept() modeman.leave(self._win_id, usertypes.KeyMode.command, 'prefix deleted') return - if e.key() == Qt.Key_Return: + if e.key() == Qt.Key.Key_Return: e.ignore() return else: diff --git a/qutebrowser/mainwindow/statusbar/percentage.py b/qutebrowser/mainwindow/statusbar/percentage.py index b16112e7e..19dd63b34 100644 --- a/qutebrowser/mainwindow/statusbar/percentage.py +++ b/qutebrowser/mainwindow/statusbar/percentage.py @@ -32,7 +32,7 @@ class Percentage(textbase.TextBase): def __init__(self, parent=None): """Constructor. Set percentage to 0%.""" - super().__init__(parent, elidemode=Qt.ElideNone) + super().__init__(parent, elidemode=Qt.TextElideMode.ElideNone) self._strings = self._calc_strings() self._set_text = throttle.Throttle(self.setText, 100, parent=self) self.set_perc(0, 0) diff --git a/qutebrowser/mainwindow/statusbar/progress.py b/qutebrowser/mainwindow/statusbar/progress.py index 0fad084a0..123e2ad60 100644 --- a/qutebrowser/mainwindow/statusbar/progress.py +++ b/qutebrowser/mainwindow/statusbar/progress.py @@ -47,7 +47,7 @@ class Progress(QProgressBar): super().__init__(parent) stylesheet.set_register(self) self.enabled = False - self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) + self.setSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed) self.setTextVisible(False) self.hide() diff --git a/qutebrowser/mainwindow/statusbar/textbase.py b/qutebrowser/mainwindow/statusbar/textbase.py index 3bce38782..6d310c75e 100644 --- a/qutebrowser/mainwindow/statusbar/textbase.py +++ b/qutebrowser/mainwindow/statusbar/textbase.py @@ -40,9 +40,9 @@ class TextBase(QLabel): _elided_text: The current elided text. """ - def __init__(self, parent=None, elidemode=Qt.ElideRight): + def __init__(self, parent=None, elidemode=Qt.TextElideMode.ElideRight): super().__init__(parent) - self.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Minimum) + self.setSizePolicy(QSizePolicy.Policy.Preferred, QSizePolicy.Policy.Minimum) self._elidemode = elidemode self._elided_text = '' @@ -57,7 +57,7 @@ class TextBase(QLabel): """ if self.text(): self._elided_text = self.fontMetrics().elidedText( - self.text(), self._elidemode, width, Qt.TextShowMnemonic) + self.text(), self._elidemode, width, Qt.TextFlag.TextShowMnemonic) else: self._elided_text = '' @@ -68,7 +68,7 @@ class TextBase(QLabel): txt: The text to set (string). """ super().setText(txt) - if self._elidemode != Qt.ElideNone: + if self._elidemode != Qt.TextElideMode.ElideNone: self._update_elided_text(self.geometry().width()) def resizeEvent(self, e): @@ -80,7 +80,7 @@ class TextBase(QLabel): def paintEvent(self, e): """Override QLabel::paintEvent to draw elided text.""" - if self._elidemode == Qt.ElideNone: + if self._elidemode == Qt.TextElideMode.ElideNone: super().paintEvent(e) else: e.accept() diff --git a/qutebrowser/mainwindow/tabbedbrowser.py b/qutebrowser/mainwindow/tabbedbrowser.py index c9017f548..fe9a69c8b 100644 --- a/qutebrowser/mainwindow/tabbedbrowser.py +++ b/qutebrowser/mainwindow/tabbedbrowser.py @@ -217,7 +217,7 @@ class TabbedBrowser(QWidget): self.widget.new_tab_requested.connect(self.tabopen) self.widget.currentChanged.connect(self._on_current_changed) self.cur_fullscreen_requested.connect(self.widget.tabBar().maybe_hide) - self.widget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) + self.widget.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding) # load_finished instead of load_started as WORKAROUND for # https://bugreports.qt.io/browse/QTBUG-65223 @@ -996,7 +996,7 @@ class TabbedBrowser(QWidget): """ # strip the fragment as it may interfere with scrolling try: - url = self.current_url().adjusted(QUrl.RemoveFragment) + url = self.current_url().adjusted(QUrl.UrlFormattingOption.RemoveFragment) except qtutils.QtValueError: # show an error only if the mark is not automatically set if key != "'": @@ -1019,7 +1019,7 @@ class TabbedBrowser(QWidget): """ try: # consider urls that differ only in fragment to be identical - urlkey = self.current_url().adjusted(QUrl.RemoveFragment) + urlkey = self.current_url().adjusted(QUrl.UrlFormattingOption.RemoveFragment) except qtutils.QtValueError: urlkey = None 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: |