Browse Source

qt gui: qt6 migration follow-ups

master
SomberNight 1 year ago
parent
commit
1ee6361c7e
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
  1. 2
      README.md
  2. 2
      contrib/requirements/requirements.txt
  3. 12
      electrum/gui/common_qt/__init__.py
  4. 9
      electrum/gui/common_qt/plugins.py
  5. 1
      electrum/gui/qml/__init__.py
  6. 3
      electrum/gui/qt/__init__.py
  7. 2
      electrum/gui/qt/qrreader/__init__.py
  8. 9
      electrum/plugins/trustedcoin/common_qt.py
  9. 2
      setup.py

2
README.md

@ -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,

2
contrib/requirements/requirements.txt

@ -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

12
electrum/gui/common_qt/__init__.py

@ -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=}")

9
electrum/gui/common_qt/plugins.py

@ -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

1
electrum/gui/qml/__init__.py

@ -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

3
electrum/gui/qt/__init__.py

@ -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)}')

2
electrum/gui/qt/qrreader/__init__.py

@ -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

9
electrum/plugins/trustedcoin/common_qt.py

@ -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

2
setup.py

@ -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']

Loading…
Cancel
Save