plover
plover copied to clipboard
beyond PyQt5
Summary of changes
With the Qt5 LTS support moved to commercial only, the only maintained version seems to be the KDE version, which is shipped by some distributions.
The first Q6 LTS release is also available, and there are now alternatives to PyQt5 / PyQt6: the official PySide2 / PySide6 bindings.
The 4 sets of bindings are mostly compatible.
By switching to QtPy, an abstraction layer for PyQt5/PyQt4/PySide2/PySide, and with a few compatibility fixes, we can target PyQt5, PySide2, PyQt6 and PySide6, making the transition to another set of bindings easier (and transparent for plugins).
Main changes:
- import from
qtpy
- don't use
QVariant
when declaring signals (just useobject
). - use scoped enums accesses: e.g.
QDialogButtonBox.StandardButton.Ok
instead ofQDialogButtonBox.Ok
. Necessary for Qt6 compatibility, increases our minimum supported version of PyQt5 to 5.11 (released in 2018). - ~switch to the official
uic
andrcc
helpers (provided by qt5-applications) for generating UI files, including resources, as PyQt6 drops support forpyrcc
.~ - load resources directly from filesystem (no need for
pyrcc5
anymore). - use the
QComboBox
textActivated(QString)
signal instead ofactivated(QString)
. Necessary for Qt6 compatibility, increases our minimum supported version of PyQt5 to 5.14 (released in 2019). - a few other minor compatibility fixes for supporting PySide2 / PySide6 / PyQt6 / Qt6.
Known issues:
- ~the
qt5-applications
Windows' wheels are missing thercc
executable (reported here).~ - ~the official
uic
Python generator may generate invalid strings for some Unicode characters (like for this one in theplover_wpm_meter
plugin).~ - ~the dictionaries widget checkboxes don't work correctly with PyQt6 / PySide6~
Pull Request Checklist
- [x] Changes have tests
- [ ] News fragment added in news.d. See documentation for details
Note: QtPy's current master need to be used for PySide6 / PyQt6 support, set the QT_API
environment variable force the use of a specific set of bindings.
OK, so I took another stab at this: by loading resources directly from the filesystem, we avoid the need for mucking around with pyrcc5
and the like. This in turn mean we can keep using pyuic5
for generating UI files (avoiding any issues with qt5-applications
).
I noticed a new issue with PySide6, however: for some reason the dictionaries widget checkboxes don't work correctly (no check-mark for enabled dictionaries)...
OK, the issue with the checkboxes is fixed, and I enabled / fixed the GUI tests for each supported variant (PyQt5, PyQt6, PySide2, and PySide6). Note that I had to update the platform to ubuntu-20.04
for PyQt6 / PySide6, which means we'd have to do the same for the Linux build (and loose support for some older distributions) if we do switch to Qt6.