plover icon indicating copy to clipboard operation
plover copied to clipboard

beyond PyQt5

Open benoit-pierre opened this issue 2 years ago • 3 comments

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 use object).
  • use scoped enums accesses: e.g. QDialogButtonBox.StandardButton.Ok instead of QDialogButtonBox.Ok. Necessary for Qt6 compatibility, increases our minimum supported version of PyQt5 to 5.11 (released in 2018).
  • ~switch to the official uic and rcc helpers (provided by qt5-applications) for generating UI files, including resources, as PyQt6 drops support for pyrcc.~
  • load resources directly from filesystem (no need for pyrcc5 anymore).
  • use the QComboBox textActivated(QString) signal instead of activated(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 the rcc executable (reported here).~
  • ~the official uic Python generator may generate invalid strings for some Unicode characters (like for this one in the plover_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

benoit-pierre avatar Oct 17 '21 16:10 benoit-pierre

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.

benoit-pierre avatar Oct 17 '21 17:10 benoit-pierre

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)...

benoit-pierre avatar Jun 25 '22 17:06 benoit-pierre

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.

benoit-pierre avatar Jun 26 '22 18:06 benoit-pierre