mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 23:12:21 -04:00
Automatically disable sandbox on Qt5 PyPi/packaged builds
This commit is contained in:
parent
469052700f
commit
0754a50b5b
2 changed files with 10 additions and 3 deletions
|
@ -592,23 +592,29 @@ def _run(argv: Optional[list[str]] = None, exec: bool = True) -> Optional[AnkiAp
|
|||
# apply user-provided scale factor
|
||||
os.environ["QT_SCALE_FACTOR"] = str(pm.uiScale())
|
||||
|
||||
# opt in to full hidpi support?
|
||||
# Opt-in to full HiDPI support?
|
||||
if not os.environ.get("ANKI_NOHIGHDPI") and qtmajor == 5:
|
||||
QCoreApplication.setAttribute(Qt.ApplicationAttribute.AA_EnableHighDpiScaling) # type: ignore
|
||||
QCoreApplication.setAttribute(Qt.ApplicationAttribute.AA_UseHighDpiPixmaps) # type: ignore
|
||||
os.environ["QT_ENABLE_HIGHDPI_SCALING"] = "1"
|
||||
os.environ["QT_SCALE_FACTOR_ROUNDING_POLICY"] = "PassThrough"
|
||||
|
||||
# Opt into software rendering. Useful for buggy systems.
|
||||
# Opt-in to software rendering?
|
||||
if os.environ.get("ANKI_SOFTWAREOPENGL"):
|
||||
QCoreApplication.setAttribute(Qt.ApplicationAttribute.AA_UseSoftwareOpenGL)
|
||||
|
||||
# fix an issue on Windows, where Ctrl+Alt shortcuts are triggered by AltGr,
|
||||
# Fix an issue on Windows, where Ctrl+Alt shortcuts are triggered by AltGr,
|
||||
# preventing users from typing things like "@" through AltGr+Q on a German
|
||||
# keyboard.
|
||||
if is_win and "QT_QPA_PLATFORM" not in os.environ:
|
||||
os.environ["QT_QPA_PLATFORM"] = "windows:altgr"
|
||||
|
||||
# Disable sandbox on Qt5 PyPi/packaged builds, as it causes blank screens on modern
|
||||
# glibc versions. We check for specific patch versions, because distros may have
|
||||
# fixed the issue in their own Qt builds.
|
||||
if is_lin and qtfullversion in ([5, 15, 2], [5, 14, 1]):
|
||||
os.environ["QTWEBENGINE_DISABLE_SANDBOX"] = "1"
|
||||
|
||||
# create the app
|
||||
QCoreApplication.setApplicationName("Anki")
|
||||
QGuiApplication.setDesktopFileName("anki.desktop")
|
||||
|
|
|
@ -48,6 +48,7 @@ _version = QLibraryInfo.version()
|
|||
qtmajor = _version.majorVersion()
|
||||
qtminor = _version.minorVersion()
|
||||
qtpoint = _version.microVersion()
|
||||
qtfullversion = _version.segments()
|
||||
|
||||
if qtmajor < 5 or (qtmajor == 5 and qtminor < 14):
|
||||
raise Exception("Anki does not support your Qt version.")
|
||||
|
|
Loading…
Reference in a new issue