From 7fa6018a8d7e019140189fcbe523a6bee7429dfb Mon Sep 17 00:00:00 2001 From: zefr0x Date: Thu, 2 Nov 2023 22:38:06 +0300 Subject: [PATCH] Migrate code from PyQt5 to PySide6 --- setup.py | 2 +- torbrowser_launcher/__init__.py | 9 ++++----- torbrowser_launcher/launcher.py | 16 ++++++++-------- torbrowser_launcher/settings.py | 2 +- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/setup.py b/setup.py index 8d8fa7dd..ada31791 100644 --- a/setup.py +++ b/setup.py @@ -121,7 +121,7 @@ def create_mo_files(): install_requires=[ "gpg", "packaging", - "PyQt5", + "PySide6", "requests", "PySocks", ], diff --git a/torbrowser_launcher/__init__.py b/torbrowser_launcher/__init__.py index 115fd4fd..a20dae6a 100644 --- a/torbrowser_launcher/__init__.py +++ b/torbrowser_launcher/__init__.py @@ -31,7 +31,7 @@ import argparse import signal -from PyQt5 import QtCore, QtWidgets +from PySide6 import QtWidgets from .common import Common, SHARE from .settings import Settings @@ -44,7 +44,6 @@ class Application(QtWidgets.QApplication): """ def __init__(self): - self.setAttribute(QtCore.Qt.AA_X11InitThreads, True) QtWidgets.QApplication.__init__(self, sys.argv) self.installEventFilter(self) @@ -87,11 +86,11 @@ def main(): gui = Launcher(common, app, url_list) # Center the window - desktop = app.desktop() + screen_size = app.primaryScreen().size() window_size = gui.size() gui.move( - (desktop.width() - window_size.width()) // 2, - (desktop.height() - window_size.height()) // 2, + (screen_size.width() - window_size.width()) // 2, + (screen_size.height() - window_size.height()) // 2, ) gui.show() diff --git a/torbrowser_launcher/launcher.py b/torbrowser_launcher/launcher.py index 286b521d..831709bb 100644 --- a/torbrowser_launcher/launcher.py +++ b/torbrowser_launcher/launcher.py @@ -39,7 +39,7 @@ import xml.etree.ElementTree as ET from packaging import version -from PyQt5 import QtCore, QtWidgets, QtGui +from PySide6 import QtCore, QtWidgets, QtGui class TryStableException(Exception): @@ -531,9 +531,9 @@ class DownloadThread(QtCore.QThread): Download a file in a separate thread. """ - progress_update = QtCore.pyqtSignal(int, int) - download_complete = QtCore.pyqtSignal() - download_error = QtCore.pyqtSignal(str, str) + progress_update = QtCore.Signal(int, int) + download_complete = QtCore.Signal() + download_error = QtCore.Signal(str, str) def __init__(self, common, url, path): super(DownloadThread, self).__init__() @@ -614,8 +614,8 @@ class VerifyThread(QtCore.QThread): Verify the signature in a separate thread """ - success = QtCore.pyqtSignal() - error = QtCore.pyqtSignal(str) + success = QtCore.Signal() + error = QtCore.Signal(str) def __init__(self, common): super(VerifyThread, self).__init__() @@ -656,8 +656,8 @@ class ExtractThread(QtCore.QThread): Extract the tarball in a separate thread """ - success = QtCore.pyqtSignal() - error = QtCore.pyqtSignal() + success = QtCore.Signal() + error = QtCore.Signal() def __init__(self, common): super(ExtractThread, self).__init__() diff --git a/torbrowser_launcher/settings.py b/torbrowser_launcher/settings.py index cef18e03..b9125ea4 100644 --- a/torbrowser_launcher/settings.py +++ b/torbrowser_launcher/settings.py @@ -29,7 +29,7 @@ import subprocess import shutil -from PyQt5 import QtCore, QtWidgets, QtGui +from PySide6 import QtCore, QtWidgets, QtGui class Settings(QtWidgets.QMainWindow):