summaryrefslogtreecommitdiff
path: root/qutebrowser/qt/webkit.py
blob: bb37e1dc9eac488aacac0a3482c8b29f30509688 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:
# pylint: disable=wildcard-import

"""Wrapped Qt imports for Qt WebKit.

All code in qutebrowser should use this module instead of importing from
PyQt/PySide directly. This allows supporting both Qt 5 and Qt 6
(though WebKit is only supported with Qt 5).

See machinery.py for details on how Qt wrapper selection works.

Any API exported from this module is based on the QtWebKit 5.212 API:
https://qtwebkit.github.io/doc/qtwebkit/qtwebkit-index.html
"""

import typing
from qutebrowser.qt import machinery

machinery.init_implicit()


if machinery.USE_PYSIDE6:  # pylint: disable=no-else-raise
    raise machinery.Unavailable()
elif machinery.USE_PYQT5 or typing.TYPE_CHECKING:
    # If we use mypy (even on Qt 6), we pretend to have WebKit available.
    # This avoids central API (like BrowserTab) being Any because the webkit part of
    # the unions there is missing.
    # This causes various issues inside browser/webkit/, but we ignore those in
    # .mypy.ini because we don't really care much about QtWebKit anymore.
    from PyQt5.QtWebKit import *
elif machinery.USE_PYQT6:
    raise machinery.Unavailable()
else:
    raise machinery.UnknownWrapper()