Skip to content

Commit

Permalink
qt gui: qt6 migration follow-ups
Browse files Browse the repository at this point in the history
  • Loading branch information
SomberNight committed Sep 16, 2024
1 parent 08c61c1 commit dfcd010
Show file tree
Hide file tree
Showing 9 changed files with 7 additions and 35 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion contrib/requirements/requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
12 changes: 0 additions & 12 deletions electrum/gui/common_qt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 1 addition & 8 deletions electrum/gui/common_qt/plugins.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
1 change: 0 additions & 1 deletion electrum/gui/qml/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

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
Expand Down
3 changes: 1 addition & 2 deletions electrum/gui/qt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
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.
Expand Down Expand Up @@ -176,7 +175,7 @@ def reload_app_stylesheet(self):
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)}')
Expand Down
2 changes: 1 addition & 1 deletion electrum/gui/qt/qrreader/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 1 addition & 8 deletions electrum/plugins/trustedcoin/common_qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,7 @@
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
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

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']
Expand Down

0 comments on commit dfcd010

Please sign in to comment.