diff --git a/qt/aqt/__init__.py b/qt/aqt/__init__.py index 596cc2359..e62f2afd2 100644 --- a/qt/aqt/__init__.py +++ b/qt/aqt/__init__.py @@ -34,7 +34,7 @@ import locale import os import tempfile import traceback -from typing import Any, Callable, Optional, cast +from typing import TYPE_CHECKING, Any, Callable, Optional, cast import anki.lang from anki._backend import RustBackend @@ -46,6 +46,9 @@ from aqt import gui_hooks from aqt.qt import * from aqt.utils import TR, tr +if TYPE_CHECKING: + import aqt.profiles + # compat aliases anki.version = _version # type: ignore anki.Collection = Collection # type: ignore @@ -394,7 +397,12 @@ def setupGL(pm: aqt.profiles.ProfileManager) -> None: context += f"{ctx.function}" if context: context = f"'{context}'" - if "Failed to create OpenGL context" in msg: + if ( + "Failed to create OpenGL context" in msg + # Based on the message Qt6 shows to the user; have not tested whether + # we can actually capture this or not. + or "Failed to initialize graphics backend" in msg + ): QMessageBox.critical( None, tr.qt_misc_error(), diff --git a/qt/aqt/preferences.py b/qt/aqt/preferences.py index 8a0c51be5..5489e8707 100644 --- a/qt/aqt/preferences.py +++ b/qt/aqt/preferences.py @@ -290,6 +290,7 @@ class Preferences(QDialog): self.form.video_driver.setCurrentIndex( self.video_drivers.index(self.mw.pm.video_driver()) ) + self.form.video_driver.setVisible(qtmajor == 5) def update_video_driver(self) -> None: new_driver = self.video_drivers[self.form.video_driver.currentIndex()] diff --git a/qt/aqt/profiles.py b/qt/aqt/profiles.py index 0c163741f..1d8ce51f5 100644 --- a/qt/aqt/profiles.py +++ b/qt/aqt/profiles.py @@ -38,7 +38,7 @@ class VideoDriver(Enum): @staticmethod def default_for_platform() -> VideoDriver: - if is_mac: + if is_mac or qtmajor > 5: return VideoDriver.OpenGL else: return VideoDriver.Software @@ -479,7 +479,11 @@ create table if not exists profiles ###################################################################### def _gldriver_path(self) -> str: - return os.path.join(self.base, "gldriver") + if qtmajor < 6: + fname = "gldriver" + else: + fname = "gldriver6" + return os.path.join(self.base, fname) def video_driver(self) -> VideoDriver: path = self._gldriver_path()