1
0

qt gui: qt6 migration follow-ups

This commit is contained in:
SomberNight
2024-09-16 16:02:08 +00:00
parent d791e3a9c8
commit 1ee6361c7e
9 changed files with 7 additions and 35 deletions

View File

@@ -30,7 +30,7 @@ $ python3 -m pip install --user ".[gui,crypto]"
If you want to use the Qt interface, install the Qt dependencies:
```
$ sudo apt-get install python3-pyqt5
$ sudo apt-get install python3-pyqt6
```
For elliptic curve operations,

View File

@@ -1,6 +1,6 @@
qrcode
protobuf>=3.20,<4
qdarkstyle>=2.7
qdarkstyle>=3.2
aiorpcx>=0.22.0,<0.24
aiohttp>=3.3.0,<4.0.0
aiohttp_socks>=0.8.4

View File

@@ -2,15 +2,3 @@
# Distributed under the MIT software license, see the accompanying
# file LICENCE or http://www.opensource.org/licenses/mit-license.php
import sys
# FIXME: remove when both desktop and mobile are Qt6
def get_qt_major_version() -> int:
_GUI_QT_VERSION = getattr(sys, '_GUI_QT_VERSION', None)
if _GUI_QT_VERSION is None:
# used by pyinstaller when building (analysis phase)
_GUI_QT_VERSION = 6
if _GUI_QT_VERSION in (5, 6):
return _GUI_QT_VERSION
raise Exception(f"unexpected {_GUI_QT_VERSION=}")

View File

@@ -1,13 +1,6 @@
import sys
from . import get_qt_major_version
if (qt_ver := get_qt_major_version()) == 5:
from PyQt5.QtCore import pyqtSignal, pyqtProperty, QObject
elif qt_ver == 6:
from PyQt6.QtCore import pyqtSignal, pyqtProperty, QObject
else:
raise Exception(f"unexpected {qt_ver=}")
from PyQt6.QtCore import pyqtSignal, pyqtProperty, QObject
from electrum.logging import get_logger

View File

@@ -22,7 +22,6 @@ except Exception as e:
from PyQt6.QtCore import (Qt, QCoreApplication, QLocale, QTranslator, QTimer, QT_VERSION_STR, PYQT_VERSION_STR)
from PyQt6.QtGui import QGuiApplication
sys._GUI_QT_VERSION = 6 # used by gui/common_qt
from electrum.i18n import _
from electrum.plugin import run_hook

View File

@@ -42,7 +42,6 @@ from PyQt6.QtGui import QGuiApplication
from PyQt6.QtWidgets import QApplication, QSystemTrayIcon, QWidget, QMenu, QMessageBox, QDialog
from PyQt6.QtCore import QObject, pyqtSignal, QTimer, Qt
import PyQt6.QtCore as QtCore
sys._GUI_QT_VERSION = 6 # used by gui/common_qt
try:
# Preload QtMultimedia at app start, if available.
@@ -176,7 +175,7 @@ class ElectrumGui(BaseElectrumGui, Logger):
if use_dark_theme:
try:
import qdarkstyle
self.app.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5())
self.app.setStyleSheet(qdarkstyle.load_stylesheet_pyqt6())
except BaseException as e:
use_dark_theme = False
self.logger.warning(f'Error setting dark theme: {repr(e)}')

View File

@@ -12,7 +12,7 @@
# - zbar fails to access the camera on macOS
# - qtmultimedia seems to support more cameras on Windows than zbar
# - qtmultimedia is often not packaged with PyQt
# in particular, on debian, you need both "python3-pyqt5" and "python3-pyqt5.qtmultimedia"
# in particular, on debian, you need both "python3-pyqt6" and "python3-pyqt6.qtmultimedia"
# - older versions of qtmultimedia don't seem to work reliably
#
# Considering the above, we use QtMultimedia for Windows and macOS, as there

View File

@@ -4,14 +4,7 @@ import base64
import sys
from typing import TYPE_CHECKING
from electrum.gui.common_qt import get_qt_major_version
if (qt_ver := get_qt_major_version()) == 5:
from PyQt5.QtCore import pyqtSignal, pyqtProperty, pyqtSlot
elif qt_ver == 6:
from PyQt6.QtCore import pyqtSignal, pyqtProperty, pyqtSlot
else:
raise Exception(f"unexpected {qt_ver=}")
from PyQt6.QtCore import pyqtSignal, pyqtProperty, pyqtSlot
from electrum.i18n import _
from electrum.bip32 import BIP32Node

View File

@@ -42,7 +42,7 @@ if platform.system() in ['Linux', 'FreeBSD', 'DragonFly']:
extras_require = {
'hardware': requirements_hw,
'gui': ['pyqt5'],
'gui': ['pyqt6'],
'crypto': ['cryptography>=2.6'],
'tests': ['pycryptodomex>=3.7', 'cryptography>=2.6', 'pyaes>=0.1a1'],
'qml_gui': ['pyqt6', 'Pillow>=8.4.0']