This diff is the minimum required to make Electrum ABC successfully start and stop without raising any errors. There are likely more runtime errors that we will discover with more testing.
To the best of my effort I picked solutions that work with both Qt5 and Qt6. In the case of the QtMultimedia related code, it would have been too messy to do so, so I duplicated some code and made it specific to Qt5 or Qt6.
Summary of changes:
- the QtMultimedia API is very different between Qt5 and Qt6 and it seems qtpy makes no effort at trying to offer any compatibility layer
- in camera_dialog.py we remove a method that is only used to provide a custor error message for old versions of PyQt5 that we haven't used for releases in a long while. This removes a PYQT_VERSION usages that would not work with PySide
- the QtWidgets.qApp does not exist in Qt6. The QApplication.instance().quit()method, available both in Qt5 and Qt6, is calling the static method QApplication.quit(), so use this directly
- QRegExp is deprecated in Qt5 and not available by default in Qt6, we can use the newer and better QRegularExpression instead (see D18178)
- QWidget.setFocus(bool) is undocumented even in Qt5, probably a leftover from Qt4. Remove the unneeded arg.
- The QMenu.addAction(...) call that takes a keyboard shortcut has changed in Qt6. Let's use a signature that works in both Qt5 and Qt6, and set the shortcut on the returned QAction (which is already done in main_window.py for other actions, so this makes the code more consistent)
- QCompleter.setCaseSensitivity(...) takes an enum. In Qt5 it seems like it was possible to pass the 0 value as a bool or int, but this errors now in Qt6. Use the explicit enum instead.
- the QSvgWidget class is now part of a new QtSvgWidgets library (a sub-part of QtSvg)
- qtpy tries to offer a compat layer for most of the enum/flags changes in Qt6, but is is not perfect, so QPalette.Background does not work in Qt6
The new QtMultimedia related code is backported from:
https://github.com/spesmilo/electrum/pull/9189/commits/cfe8502f9677266cb50d9b2e450ced4611f37e25