Anki/qt/aqt
Aristotelis 2d1c058106
Maintain compatibility with PyQt5 add-ons in PyQt6 builds (#1440)
* Alias PyQt5 to PyQt6 on PyQt6 builds

Restores basic compatibility with PyQt5 add-ons

* Register QtCore early to work around sip error

* Monkey-patch unscoped enums that are in use by add-ons back in

Enums whose namespace moved with PyQt6 were determined using the tooling in https://github.com/qutebrowser/qutebrowser/issues/5904

Relevant enums for the Anki add-on ecosystem were found by grepping through all AnkiWeb add-ons and a selection of GitHub-released add-ons.

* Add full Qt.Key namespace

Maintains compatibility with add-ons that allow specifying key bindings via Qt.Key enums

* Reintroduce PyQt6.Qt as an alias for QtCore.Qt

* Alias classes shifted from QtWidgets to QtGui

* Add missing enums

Adds ≈200 enums that were missed during the initial grep

* Map exec_ calls to exec

* Tweak section headers

* Fix QtWebEngineWidgets imports failing due to delayed import

Addesses: "QtWebEngineWidgets must be imported before a QCoreApplication instance is created"

* Register additional aliases for top-level Qt modules

Given how we have had to deal with side-effects when not registering other aliased imports ahead of time, it seems safer to also register the remaining few with sys.modules.

* Handle calls to deprecated PyQt resource API graciously

* Create QtWebEngineWidgets aliases for classes moved to QtWebEngineCore

* Alias QShortcut

* Restore QWebEnginePage.view()

* Alias sip to PyQt6.sip

* Alias QtCore.QRegExp to QtCore.QRegularExpression

* Restructure aqt.qt into package

Pre-requirement for aliasing the PyQt5.Qt namespace correctly.

Should hopefully also make it easier to keep an overview as Qt-compat-related modules were proliferating.

* Properly alias PyQt5.Qt

PyQt5.Qt used to serve as a common namespace for all Qt classes, not just QtCore.Qt.*

While this changes does not make all classes accessible via PyQt5.Qt, it does so for the most important Qt submodules, which should cover most add-on breakages.

* Simplify Qt resource system legacy handling

* Also alias PyQt6.Qt

Covers imports of the form `from PyQt5 import import Qt` (due to previous aliasing of PyQt5 to PyQt6)

* Add missing enums

Better approach to grepping through add-ons yielded additional hits

* Run formatters

* Satisfy pylint
2021-10-28 19:57:42 +10:00
..
browser Flip sidebar position for RTL languages (#1453) 2021-10-25 13:27:19 +10:00
data add missing wheel/helper for darwin-arm64 2021-10-28 18:29:18 +10:00
forms remove a few unnecessary PyQt workarounds 2021-10-24 14:24:35 +10:00
operations switch to new-style PyQt scoped enums and Qt6 2021-10-15 12:57:19 +10:00
qt Maintain compatibility with PyQt5 add-ons in PyQt6 builds (#1440) 2021-10-28 19:57:42 +10:00
__init__.py updated package scripts 2021-10-28 18:46:45 +10:00
about.py PEP8 for rest of pylib (#1451) 2021-10-25 14:50:13 +10:00
addcards.py PEP8 for rest of pylib (#1451) 2021-10-25 14:50:13 +10:00
addons.py PEP8 for rest of pylib (#1451) 2021-10-25 14:50:13 +10:00
BUILD.bazel improve PyQt install 2021-10-23 10:56:17 +10:00
changenotetype.py switch to new-style PyQt scoped enums and Qt6 2021-10-15 12:57:19 +10:00
clayout.py switch to new-style PyQt scoped enums and Qt6 2021-10-15 12:57:19 +10:00
colors.py move remaining Filter button items into sidebar 2021-02-05 18:58:22 +10:00
customstudy.py PEP8 pylib (#1443) 2021-10-22 20:39:49 +10:00
dbcheck.py PEP8 collection.py 2021-06-27 15:12:22 +10:00
deckbrowser.py .exec_() -> .exec() 2021-10-12 16:17:37 +10:00
deckchooser.py Fix chooser label not being updated when current notetype/deck renamed (#1452) 2021-10-25 13:23:06 +10:00
deckconf.py PEP8 pylib (#1443) 2021-10-22 20:39:49 +10:00
deckdescription.py switch to new-style PyQt scoped enums and Qt6 2021-10-15 12:57:19 +10:00
deckoptions.py switch to new-style PyQt scoped enums and Qt6 2021-10-15 12:57:19 +10:00
editcurrent.py switch to new-style PyQt scoped enums and Qt6 2021-10-15 12:57:19 +10:00
editor.py PEP8 for rest of pylib (#1451) 2021-10-25 14:50:13 +10:00
emptycards.py switch to new-style PyQt scoped enums and Qt6 2021-10-15 12:57:19 +10:00
errors.py catch all recording errors; mention permission 2021-06-02 12:20:40 +10:00
exporting.py switch to new-style PyQt scoped enums and Qt6 2021-10-15 12:57:19 +10:00
fields.py switch to new-style PyQt scoped enums and Qt6 2021-10-15 12:57:19 +10:00
filtered_deck.py switch to new-style PyQt scoped enums and Qt6 2021-10-15 12:57:19 +10:00
flags.py use Qt search path instead of resource system 2021-10-12 16:17:08 +10:00
gui_hooks.py fix qt/ pylints 2021-01-07 16:21:50 +10:00
hooks_gen.py symlink generated .py/.pyi into tree to fix Python code completion 2020-12-16 11:36:42 +10:00
importing.py switch to new-style PyQt scoped enums and Qt6 2021-10-15 12:57:19 +10:00
legacy.py run pyupgrade over codebase [python upgrade required] 2021-10-04 15:05:48 +10:00
main.py PEP8 for rest of pylib (#1451) 2021-10-25 14:50:13 +10:00
mediacheck.py switch to new-style PyQt scoped enums and Qt6 2021-10-15 12:57:19 +10:00
mediasrv.py updated package scripts 2021-10-28 18:46:45 +10:00
mediasync.py PEP8 for rest of pylib (#1451) 2021-10-25 14:50:13 +10:00
modelchooser.py run pyupgrade over codebase [python upgrade required] 2021-10-04 15:05:48 +10:00
models.py switch to new-style PyQt scoped enums and Qt6 2021-10-15 12:57:19 +10:00
mpv.py run pyupgrade over codebase [python upgrade required] 2021-10-04 15:05:48 +10:00
notetypechooser.py Fix chooser label not being updated when current notetype/deck renamed (#1452) 2021-10-25 13:23:06 +10:00
overview.py PEP8 pylib (#1443) 2021-10-22 20:39:49 +10:00
package.py ignore a spurious mypy error 2021-10-28 19:19:37 +10:00
pinnedmodules.py drop PyAudio support 2021-10-15 13:15:16 +10:00
platform.py updated package scripts 2021-10-28 18:46:45 +10:00
preferences.py PEP8 for rest of pylib (#1451) 2021-10-25 14:50:13 +10:00
profiles.py PEP8 for rest of pylib (#1451) 2021-10-25 14:50:13 +10:00
progress.py switch to new-style PyQt scoped enums and Qt6 2021-10-15 12:57:19 +10:00
py.typed mark anki and aqt modules as having typing info 2020-01-13 13:03:37 +10:00
reviewer.py PEP8 for rest of pylib (#1451) 2021-10-25 14:50:13 +10:00
schema_change_tracker.py add a bunch of return types 2021-02-01 23:53:23 +10:00
sound.py Maintain compatibility with PyQt5 add-ons in PyQt6 builds (#1440) 2021-10-28 19:57:42 +10:00
stats.py switch to new-style PyQt scoped enums and Qt6 2021-10-15 12:57:19 +10:00
studydeck.py switch to new-style PyQt scoped enums and Qt6 2021-10-15 12:57:19 +10:00
switch.py switch to new-style PyQt scoped enums and Qt6 2021-10-15 12:57:19 +10:00
sync.py PEP8 for rest of pylib (#1451) 2021-10-25 14:50:13 +10:00
tagedit.py switch to new-style PyQt scoped enums and Qt6 2021-10-15 12:57:19 +10:00
taglimit.py PEP8 for rest of pylib (#1451) 2021-10-25 14:50:13 +10:00
taskman.py avoid importing directly from PyQt5 where possible 2021-10-15 10:47:53 +10:00
theme.py fix placeholder text color on win/lin 2021-10-15 12:57:19 +10:00
toolbar.py run pyupgrade over codebase [python upgrade required] 2021-10-04 15:05:48 +10:00
tts.py run pyupgrade over codebase [python upgrade required] 2021-10-04 15:05:48 +10:00
undo.py fix redo menu item showing undo text 2021-08-04 10:28:45 +10:00
update.py PEP8 for rest of pylib (#1451) 2021-10-25 14:50:13 +10:00
utils.py updated package scripts 2021-10-28 18:46:45 +10:00
webview.py PEP8 for rest of pylib (#1451) 2021-10-25 14:50:13 +10:00
wheel_description.txt move aqt_data into source folder; implement wheel building 2020-11-04 12:14:03 +10:00
winpaths.py run pyupgrade over codebase [python upgrade required] 2021-10-04 15:05:48 +10:00