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/misc | |
parent | ba30ac2af0860a8c92503179f6867ab0b46e3d31 (diff) | |
download | qutebrowser-ac9d67cce0dbecdde14c474db855243e9746ba04.tar.gz qutebrowser-ac9d67cce0dbecdde14c474db855243e9746ba04.zip |
Automatically rewrite enums
See #5904
Diffstat (limited to 'qutebrowser/misc')
-rw-r--r-- | qutebrowser/misc/backendproblem.py | 16 | ||||
-rw-r--r-- | qutebrowser/misc/consolewidget.py | 10 | ||||
-rw-r--r-- | qutebrowser/misc/crashdialog.py | 20 | ||||
-rw-r--r-- | qutebrowser/misc/crashsignal.py | 4 | ||||
-rw-r--r-- | qutebrowser/misc/earlyinit.py | 4 | ||||
-rw-r--r-- | qutebrowser/misc/editor.py | 2 | ||||
-rw-r--r-- | qutebrowser/misc/elf.py | 2 | ||||
-rw-r--r-- | qutebrowser/misc/guiprocess.py | 22 | ||||
-rw-r--r-- | qutebrowser/misc/httpclient.py | 8 | ||||
-rw-r--r-- | qutebrowser/misc/ipc.py | 22 | ||||
-rw-r--r-- | qutebrowser/misc/keyhintwidget.py | 4 | ||||
-rw-r--r-- | qutebrowser/misc/miscwidgets.py | 22 | ||||
-rw-r--r-- | qutebrowser/misc/msgbox.py | 10 | ||||
-rw-r--r-- | qutebrowser/misc/sessions.py | 4 |
14 files changed, 75 insertions, 75 deletions
diff --git a/qutebrowser/misc/backendproblem.py b/qutebrowser/misc/backendproblem.py index 9a490aac9..467930b02 100644 --- a/qutebrowser/misc/backendproblem.py +++ b/qutebrowser/misc/backendproblem.py @@ -44,10 +44,10 @@ class _Result(enum.IntEnum): """The result code returned by the backend problem dialog.""" - quit = QDialog.Accepted + 1 - restart = QDialog.Accepted + 2 - restart_webkit = QDialog.Accepted + 3 - restart_webengine = QDialog.Accepted + 4 + quit = QDialog.DialogCode.Accepted + 1 + restart = QDialog.DialogCode.Accepted + 2 + restart_webkit = QDialog.DialogCode.Accepted + 3 + restart_webengine = QDialog.DialogCode.Accepted + 4 @dataclasses.dataclass @@ -111,7 +111,7 @@ class _Dialog(QDialog): label = QLabel(text) label.setWordWrap(True) - label.setTextFormat(Qt.RichText) + label.setTextFormat(Qt.TextFormat.RichText) vbox.addWidget(label) hbox = QHBoxLayout() @@ -181,7 +181,7 @@ class _BackendProblemChecker: status = dialog.exec() self._save_manager.save_all(is_exit=True) - if status in [_Result.quit, QDialog.Rejected]: + if status in [_Result.quit, QDialog.DialogCode.Rejected]: pass elif status == _Result.restart_webkit: quitter.instance.restart(override_args={'backend': 'webkit'}) @@ -312,7 +312,7 @@ class _BackendProblemChecker: errbox = msgbox.msgbox(parent=None, title="SSL error", text="Could not initialize SSL support.", - icon=QMessageBox.Critical, + icon=QMessageBox.Icon.Critical, plain_text=False) errbox.exec() sys.exit(usertypes.Exit.err_init) @@ -338,7 +338,7 @@ class _BackendProblemChecker: errbox = msgbox.msgbox(parent=None, title="No backend library found!", text=text, - icon=QMessageBox.Critical, + icon=QMessageBox.Icon.Critical, plain_text=False) errbox.exec() sys.exit(usertypes.Exit.err_init) diff --git a/qutebrowser/misc/consolewidget.py b/qutebrowser/misc/consolewidget.py index ad78037b1..e40133c51 100644 --- a/qutebrowser/misc/consolewidget.py +++ b/qutebrowser/misc/consolewidget.py @@ -92,13 +92,13 @@ class ConsoleLineEdit(miscwidgets.CommandLineEdit): def keyPressEvent(self, e): """Override keyPressEvent to handle special keypresses.""" - if e.key() == Qt.Key_Up: + if e.key() == Qt.Key.Key_Up: self.history_prev() e.accept() - elif e.key() == Qt.Key_Down: + elif e.key() == Qt.Key.Key_Down: self.history_next() e.accept() - elif e.modifiers() & Qt.ControlModifier and e.key() == Qt.Key_C: + elif e.modifiers() & Qt.KeyboardModifier.ControlModifier and e.key() == Qt.Key.Key_C: self.setText('') e.accept() else: @@ -113,7 +113,7 @@ class ConsoleTextEdit(QTextEdit): super().__init__(parent) self.setAcceptRichText(False) self.setReadOnly(True) - self.setFocusPolicy(Qt.ClickFocus) + self.setFocusPolicy(Qt.FocusPolicy.ClickFocus) def __repr__(self): return utils.get_repr(self) @@ -124,7 +124,7 @@ class ConsoleTextEdit(QTextEdit): We can't use Qt's way to append stuff because that inserts weird newlines. """ - self.moveCursor(QTextCursor.End) + self.moveCursor(QTextCursor.MoveOperation.End) self.insertPlainText(text) scrollbar = self.verticalScrollBar() scrollbar.setValue(scrollbar.maximum()) diff --git a/qutebrowser/misc/crashdialog.py b/qutebrowser/misc/crashdialog.py index c04220747..b337466d8 100644 --- a/qutebrowser/misc/crashdialog.py +++ b/qutebrowser/misc/crashdialog.py @@ -47,8 +47,8 @@ class Result(enum.IntEnum): """The result code returned by the crash dialog.""" - restore = QDialog.Accepted + 1 - no_restore = QDialog.Accepted + 2 + restore = QDialog.DialogCode.Accepted + 1 + no_restore = QDialog.DialogCode.Accepted + 2 def parse_fatal_stacktrace(text): @@ -149,7 +149,7 @@ class _CrashDialog(QDialog): self._debug_log = QTextEdit() self._debug_log.setTabChangesFocus(True) self._debug_log.setAcceptRichText(False) - self._debug_log.setLineWrapMode(QTextEdit.NoWrap) + self._debug_log.setLineWrapMode(QTextEdit.LineWrapMode.NoWrap) self._debug_log.hide() self._fold = miscwidgets.DetailFold("Show log", self) self._fold.toggled.connect(self._debug_log.setVisible) @@ -165,7 +165,7 @@ class _CrashDialog(QDialog): def keyPressEvent(self, e): """Prevent closing :report dialogs when pressing <Escape>.""" - if config.val.input.escape_quits_reporter or e.key() != Qt.Key_Escape: + if config.val.input.escape_quits_reporter or e.key() != Qt.Key.Key_Escape: super().keyPressEvent(e) def __repr__(self): @@ -201,7 +201,7 @@ class _CrashDialog(QDialog): self._lbl = QLabel() self._lbl.setWordWrap(True) self._lbl.setOpenExternalLinks(True) - self._lbl.setTextInteractionFlags(Qt.LinksAccessibleByMouse) + self._lbl.setTextInteractionFlags(Qt.TextInteractionFlag.LinksAccessibleByMouse) self._vbox.addWidget(self._lbl) def _init_checkboxes(self): @@ -215,12 +215,12 @@ class _CrashDialog(QDialog): self._btn_report = QPushButton("Report") self._btn_report.setDefault(True) self._btn_report.clicked.connect(self.on_report_clicked) - self._btn_box.addButton(self._btn_report, QDialogButtonBox.AcceptRole) + self._btn_box.addButton(self._btn_report, QDialogButtonBox.ButtonRole.AcceptRole) self._btn_cancel = QPushButton("Don't report") self._btn_cancel.setAutoDefault(False) self._btn_cancel.clicked.connect(self.finish) - self._btn_box.addButton(self._btn_cancel, QDialogButtonBox.RejectRole) + self._btn_box.addButton(self._btn_cancel, QDialogButtonBox.ButtonRole.RejectRole) def _init_info_text(self): """Add an info text encouraging the user to report crashes.""" @@ -492,7 +492,7 @@ class FatalCrashDialog(_CrashDialog): def __init__(self, debug, text, parent=None): super().__init__(debug, parent) self._log = text - self.setAttribute(Qt.WA_DeleteOnClose) + self.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose) self._set_crash_info() self._type, self._func = parse_fatal_stacktrace(self._log) @@ -557,7 +557,7 @@ class FatalCrashDialog(_CrashDialog): "spend on developing qutebrowser instead.\n\nPlease " "help making qutebrowser better by providing more " "information, or don't report this.", - icon=QMessageBox.Critical) + icon=QMessageBox.Icon.Critical) else: super().on_report_clicked() @@ -574,7 +574,7 @@ class ReportDialog(_CrashDialog): def __init__(self, pages, cmdhist, qobjects, parent=None): super().__init__(False, parent) - self.setAttribute(Qt.WA_DeleteOnClose) + self.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose) self._pages = pages self._cmdhist = cmdhist self._qobjects = qobjects diff --git a/qutebrowser/misc/crashsignal.py b/qutebrowser/misc/crashsignal.py index 6b7cdf984..6c7bce395 100644 --- a/qutebrowser/misc/crashsignal.py +++ b/qutebrowser/misc/crashsignal.py @@ -135,7 +135,7 @@ class CrashHandler(QObject): for tab in tabbed_browser.widgets(): try: urlstr = tab.url().toString( - QUrl.RemovePassword | QUrl.FullyEncoded) + QUrl.UrlFormattingOption.RemovePassword | QUrl.ComponentFormattingOption.FullyEncoded) if urlstr: win_pages.append(urlstr) except Exception: @@ -358,7 +358,7 @@ class SignalHandler(QObject): flags = fcntl.fcntl(fd, fcntl.F_GETFL) fcntl.fcntl(fd, fcntl.F_SETFL, flags | os.O_NONBLOCK) self._notifier = QSocketNotifier(cast(sip.voidptr, read_fd), - QSocketNotifier.Read, + QSocketNotifier.Type.Read, self) self._notifier.activated.connect( # type: ignore[attr-defined] self.handle_signal_wakeup) diff --git a/qutebrowser/misc/earlyinit.py b/qutebrowser/misc/earlyinit.py index 20f9c189b..0d3e2e9b0 100644 --- a/qutebrowser/misc/earlyinit.py +++ b/qutebrowser/misc/earlyinit.py @@ -91,9 +91,9 @@ def _die(message, exception=None): else: if exception is not None: message = message.replace('%ERROR%', str(exception)) - msgbox = QMessageBox(QMessageBox.Critical, "qutebrowser: Fatal error!", + msgbox = QMessageBox(QMessageBox.Icon.Critical, "qutebrowser: Fatal error!", message) - msgbox.setTextFormat(Qt.RichText) + msgbox.setTextFormat(Qt.TextFormat.RichText) msgbox.resize(msgbox.sizeHint()) msgbox.exec() app.quit() diff --git a/qutebrowser/misc/editor.py b/qutebrowser/misc/editor.py index 5d61afd57..1c6c15f1e 100644 --- a/qutebrowser/misc/editor.py +++ b/qutebrowser/misc/editor.py @@ -105,7 +105,7 @@ class ExternalEditor(QObject): return log.procs.debug("Editor closed") - if exitstatus != QProcess.NormalExit: + if exitstatus != QProcess.ExitStatus.NormalExit: # No error/cleanup here, since we already handle this in # on_proc_error. return diff --git a/qutebrowser/misc/elf.py b/qutebrowser/misc/elf.py index ddda87972..e1c4ace29 100644 --- a/qutebrowser/misc/elf.py +++ b/qutebrowser/misc/elf.py @@ -314,7 +314,7 @@ def parse_webenginecore() -> Optional[Versions]: # Flatpak has Qt in /usr/lib/x86_64-linux-gnu, but QtWebEngine in /app/lib. library_path = pathlib.Path("/app/lib") else: - library_path = pathlib.Path(QLibraryInfo.location(QLibraryInfo.LibrariesPath)) + library_path = pathlib.Path(QLibraryInfo.location(QLibraryInfo.LibraryLocation.LibrariesPath)) library_name = sorted(library_path.glob('libQt5WebEngineCore.so*')) if not library_name: diff --git a/qutebrowser/misc/guiprocess.py b/qutebrowser/misc/guiprocess.py index 640d7f1e6..7b04cbdac 100644 --- a/qutebrowser/misc/guiprocess.py +++ b/qutebrowser/misc/guiprocess.py @@ -93,7 +93,7 @@ class ProcessOutcome: """ assert self.status is not None, "Process didn't finish yet" assert self.code is not None - return self.status == QProcess.NormalExit and self.code == 0 + return self.status == QProcess.ExitStatus.NormalExit and self.code == 0 def __str__(self) -> str: if self.running: @@ -104,12 +104,12 @@ class ProcessOutcome: assert self.status is not None assert self.code is not None - if self.status == QProcess.CrashExit: + if self.status == QProcess.ExitStatus.CrashExit: return f"{self.what.capitalize()} crashed." elif self.was_successful(): return f"{self.what.capitalize()} exited successfully." - assert self.status == QProcess.NormalExit + assert self.status == QProcess.ExitStatus.NormalExit # We call this 'status' here as it makes more sense to the user - # it's actually 'code'. return f"{self.what.capitalize()} exited with status {self.code}." @@ -123,7 +123,7 @@ class ProcessOutcome: return 'running' elif self.status is None: return 'not started' - elif self.status == QProcess.CrashExit: + elif self.status == QProcess.ExitStatus.CrashExit: return 'crashed' elif self.was_successful(): return 'successful' @@ -175,7 +175,7 @@ class GUIProcess(QObject): self.stderr: str = "" self._cleanup_timer = usertypes.Timer(self, 'process-cleanup') - self._cleanup_timer.setTimerType(Qt.VeryCoarseTimer) + self._cleanup_timer.setTimerType(Qt.TimerType.VeryCoarseTimer) self._cleanup_timer.setInterval(3600 * 1000) # 1h self._cleanup_timer.timeout.connect(self._on_cleanup_timer) self._cleanup_timer.setSingleShot(True) @@ -252,17 +252,17 @@ class GUIProcess(QObject): @pyqtSlot(QProcess.ProcessError) def _on_error(self, error: QProcess.ProcessError) -> None: """Show a message if there was an error while spawning.""" - if error == QProcess.Crashed and not utils.is_windows: + if error == QProcess.ProcessError.Crashed and not utils.is_windows: # Already handled via ExitStatus in _on_finished return what = f"{self.what} {self.cmd!r}" error_descriptions = { - QProcess.FailedToStart: f"{what.capitalize()} failed to start", - QProcess.Crashed: f"{what.capitalize()} crashed", - QProcess.Timedout: f"{what.capitalize()} timed out", - QProcess.WriteError: f"Write error for {what}", - QProcess.WriteError: f"Read error for {what}", + QProcess.ProcessError.FailedToStart: f"{what.capitalize()} failed to start", + QProcess.ProcessError.Crashed: f"{what.capitalize()} crashed", + QProcess.ProcessError.Timedout: f"{what.capitalize()} timed out", + QProcess.ProcessError.WriteError: f"Write error for {what}", + QProcess.ProcessError.WriteError: f"Read error for {what}", } error_string = self._proc.errorString() msg = ': '.join([error_descriptions[error], error_string]) diff --git a/qutebrowser/misc/httpclient.py b/qutebrowser/misc/httpclient.py index 4cd825814..7d34ba425 100644 --- a/qutebrowser/misc/httpclient.py +++ b/qutebrowser/misc/httpclient.py @@ -35,8 +35,8 @@ class HTTPRequest(QNetworkRequest): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - self.setAttribute(QNetworkRequest.RedirectPolicyAttribute, - QNetworkRequest.NoLessSafeRedirectPolicy) + self.setAttribute(QNetworkRequest.Attribute.RedirectPolicyAttribute, + QNetworkRequest.RedirectPolicy.NoLessSafeRedirectPolicy) class HTTPClient(QObject): @@ -78,7 +78,7 @@ class HTTPClient(QObject): data = {} encoded_data = urllib.parse.urlencode(data).encode('utf-8') request = HTTPRequest(url) - request.setHeader(QNetworkRequest.ContentTypeHeader, + request.setHeader(QNetworkRequest.KnownHeaders.ContentTypeHeader, 'application/x-www-form-urlencoded;charset=utf-8') reply = self._nam.post(request, encoded_data) self._handle_reply(reply) @@ -118,7 +118,7 @@ class HTTPClient(QObject): if timer is not None: timer.stop() timer.deleteLater() - if reply.error() != QNetworkReply.NoError: + if reply.error() != QNetworkReply.NetworkError.NoError: self.error.emit(reply.errorString()) return try: diff --git a/qutebrowser/misc/ipc.py b/qutebrowser/misc/ipc.py index 06daf2d7f..b6d510823 100644 --- a/qutebrowser/misc/ipc.py +++ b/qutebrowser/misc/ipc.py @@ -188,7 +188,7 @@ class IPCServer(QObject): self._atime_timer = usertypes.Timer(self, 'ipc-atime') self._atime_timer.setInterval(ATIME_INTERVAL) self._atime_timer.timeout.connect(self.update_atime) - self._atime_timer.setTimerType(Qt.VeryCoarseTimer) + self._atime_timer.setTimerType(Qt.TimerType.VeryCoarseTimer) self._server = QLocalServer(self) self._server.newConnection.connect( # type: ignore[attr-defined] @@ -205,7 +205,7 @@ class IPCServer(QObject): # Thus, we only do so on Windows, and handle permissions manually in # listen() on Linux. log.ipc.debug("Calling setSocketOptions") - self._server.setSocketOptions(QLocalServer.UserAccessOption) + self._server.setSocketOptions(QLocalServer.SocketOption.UserAccessOption) else: # pragma: no cover log.ipc.debug("Not calling setSocketOptions") @@ -224,7 +224,7 @@ class IPCServer(QObject): self._remove_server() ok = self._server.listen(self._socketname) if not ok: - if self._server.serverError() == QAbstractSocket.AddressInUseError: + if self._server.serverError() == QAbstractSocket.SocketError.AddressInUseError: raise AddressInUseError(self._server) raise ListenError(self._server) @@ -249,7 +249,7 @@ class IPCServer(QObject): log.ipc.debug("Socket 0x{:x}: error {}: {}".format( id(self._socket), self._socket.error(), self._socket.errorString())) - if err != QLocalSocket.PeerClosedError: + if err != QLocalSocket.LocalSocketError.PeerClosedError: raise SocketError("handling IPC connection", self._socket) @pyqtSlot() @@ -276,13 +276,13 @@ class IPCServer(QObject): log.ipc.debug("We can read a line immediately.") self.on_ready_read() socket.error.connect(self.on_error) # type: ignore[attr-defined] - if socket.error() not in [QLocalSocket.UnknownSocketError, - QLocalSocket.PeerClosedError]: + if socket.error() not in [QLocalSocket.LocalSocketError.UnknownSocketError, + QLocalSocket.LocalSocketError.PeerClosedError]: log.ipc.debug("We got an error immediately.") self.on_error(socket.error()) socket.disconnected.connect( # type: ignore[attr-defined] self.on_disconnected) - if socket.state() == QLocalSocket.UnconnectedState: + if socket.state() == QLocalSocket.LocalSocketState.UnconnectedState: log.ipc.debug("Socket was disconnected immediately.") self.on_disconnected() @@ -493,15 +493,15 @@ def send_to_running_instance(socketname, command, target_arg, *, socket=None): log.ipc.debug("Writing: {!r}".format(data)) socket.writeData(data) socket.waitForBytesWritten(WRITE_TIMEOUT) - if socket.error() != QLocalSocket.UnknownSocketError: + if socket.error() != QLocalSocket.LocalSocketError.UnknownSocketError: raise SocketError("writing to running instance", socket) socket.disconnectFromServer() - if socket.state() != QLocalSocket.UnconnectedState: + if socket.state() != QLocalSocket.LocalSocketState.UnconnectedState: socket.waitForDisconnected(CONNECT_TIMEOUT) return True else: - if socket.error() not in [QLocalSocket.ConnectionRefusedError, - QLocalSocket.ServerNotFoundError]: + if socket.error() not in [QLocalSocket.LocalSocketError.ConnectionRefusedError, + QLocalSocket.LocalSocketError.ServerNotFoundError]: raise SocketError("connecting to running instance", socket) log.ipc.debug("No existing instance present (error {})".format( socket.error())) diff --git a/qutebrowser/misc/keyhintwidget.py b/qutebrowser/misc/keyhintwidget.py index 392b03ae4..9de6518f7 100644 --- a/qutebrowser/misc/keyhintwidget.py +++ b/qutebrowser/misc/keyhintwidget.py @@ -65,9 +65,9 @@ class KeyHintView(QLabel): def __init__(self, win_id, parent=None): super().__init__(parent) - self.setTextFormat(Qt.RichText) + self.setTextFormat(Qt.TextFormat.RichText) self._win_id = win_id - self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Minimum) + self.setSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Minimum) self.hide() self._show_timer = usertypes.Timer(self, 'keyhint_show') self._show_timer.timeout.connect(self.show) diff --git a/qutebrowser/misc/miscwidgets.py b/qutebrowser/misc/miscwidgets.py index 1dfbdff6a..aaf7d07de 100644 --- a/qutebrowser/misc/miscwidgets.py +++ b/qutebrowser/misc/miscwidgets.py @@ -49,11 +49,11 @@ class MinimalLineEditMixin: """ ) self.setAttribute( # type: ignore[attr-defined] - Qt.WA_MacShowFocusRect, False) + 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: @@ -137,9 +137,9 @@ class _CommandValidator(QValidator): A tuple (status, string, pos) as a QValidator should. """ if self.prompt is None or string.startswith(self.prompt): - return (QValidator.Acceptable, string, pos) + return (QValidator.State.Acceptable, string, pos) else: - return (QValidator.Invalid, string, pos) + return (QValidator.State.Invalid, string, pos) class DetailFold(QWidget): @@ -181,7 +181,7 @@ class DetailFold(QWidget): Args: e: The QMouseEvent. """ - if e.button() == Qt.LeftButton: + if e.button() == Qt.MouseButton.LeftButton: e.accept() self.toggle() else: @@ -219,9 +219,9 @@ class _FoldArrow(QWidget): opt.initFrom(self) painter = QPainter(self) if self._folded: - elem = QStyle.PE_IndicatorArrowRight + elem = QStyle.PrimitiveElement.PE_IndicatorArrowRight else: - elem = QStyle.PE_IndicatorArrowDown + elem = QStyle.PrimitiveElement.PE_IndicatorArrowDown self.style().drawPrimitive(elem, opt, painter, self) def minimumSizeHint(self): @@ -387,10 +387,10 @@ class InspectorSplitter(QSplitter): self._inspector_idx = 0 self._main_idx = 1 - self.setOrientation(Qt.Horizontal + self.setOrientation(Qt.Orientation.Horizontal if position in [inspector.Position.left, inspector.Position.right] - else Qt.Vertical) + else Qt.Orientation.Vertical) self.insertWidget(self._inspector_idx, inspector_widget) self._position = position self._load_preferred_size() @@ -405,7 +405,7 @@ class InspectorSplitter(QSplitter): def _load_preferred_size(self) -> None: """Load the preferred size of the inspector widget.""" assert self._position is not None - full = (self.width() if self.orientation() == Qt.Horizontal + full = (self.width() if self.orientation() == Qt.Orientation.Horizontal else self.height()) # If we first open the inspector with a window size of < 300px @@ -489,7 +489,7 @@ class KeyTesterWidget(QWidget): def __init__(self, parent=None): super().__init__(parent) - self.setAttribute(Qt.WA_DeleteOnClose) + self.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose) self._layout = QHBoxLayout(self) self._label = QLabel(text="Waiting for keypress...") self._layout.addWidget(self._label) diff --git a/qutebrowser/misc/msgbox.py b/qutebrowser/misc/msgbox.py index e75f0af87..5defc252a 100644 --- a/qutebrowser/misc/msgbox.py +++ b/qutebrowser/misc/msgbox.py @@ -34,7 +34,7 @@ class DummyBox: pass -def msgbox(parent, title, text, *, icon, buttons=QMessageBox.Ok, +def msgbox(parent, title, text, *, icon, buttons=QMessageBox.StandardButton.Ok, on_finished=None, plain_text=None): """Display a QMessageBox with the given icon. @@ -55,15 +55,15 @@ def msgbox(parent, title, text, *, icon, buttons=QMessageBox.Ok, return DummyBox() box = QMessageBox(parent) - box.setAttribute(Qt.WA_DeleteOnClose) + box.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose) box.setIcon(icon) box.setStandardButtons(buttons) if on_finished is not None: box.finished.connect(on_finished) if plain_text: - box.setTextFormat(Qt.PlainText) + box.setTextFormat(Qt.TextFormat.PlainText) elif plain_text is not None: - box.setTextFormat(Qt.RichText) + box.setTextFormat(Qt.TextFormat.RichText) box.setWindowTitle(title) box.setText(text) box.show() @@ -80,4 +80,4 @@ def information(*args, **kwargs): Return: A new QMessageBox. """ - return msgbox(*args, icon=QMessageBox.Information, **kwargs) + return msgbox(*args, icon=QMessageBox.Icon.Information, **kwargs) diff --git a/qutebrowser/misc/sessions.py b/qutebrowser/misc/sessions.py index d791cc1a0..668eb3779 100644 --- a/qutebrowser/misc/sessions.py +++ b/qutebrowser/misc/sessions.py @@ -226,7 +226,7 @@ class SessionManager(QObject): # QtWebEngine user_data = None - data['last_visited'] = item.lastVisited().toString(Qt.ISODate) + data['last_visited'] = item.lastVisited().toString(Qt.DateFormat.ISODate) if tab.history.current_idx() == idx: pos = tab.scroller.pos_px() @@ -444,7 +444,7 @@ class SessionManager(QObject): if histentry.get("last_visited"): last_visited: Optional[QDateTime] = QDateTime.fromString( histentry.get("last_visited"), - Qt.ISODate, + Qt.DateFormat.ISODate, ) else: last_visited = None |