diff --git a/qt/aqt/__init__.py b/qt/aqt/__init__.py index ad39bbb90..596cc2359 100644 --- a/qt/aqt/__init__.py +++ b/qt/aqt/__init__.py @@ -361,9 +361,6 @@ def parseArgs(argv: list[str]) -> tuple[argparse.Namespace, list[str]]: def setupGL(pm: aqt.profiles.ProfileManager) -> None: - if is_mac: - return - driver = pm.video_driver() # work around pyqt loading wrong GL library @@ -413,19 +410,23 @@ def setupGL(pm: aqt.profiles.ProfileManager) -> None: qInstallMessageHandler(msgHandler) - # ignore set graphics driver on Qt6 for now - if qtmajor > 5: - return - if driver == VideoDriver.OpenGL: + # Leaving QT_OPENGL unset appears to sometimes produce different results + # to explicitly setting it to 'auto'; the former seems to be more compatible. pass else: if is_win: + # on Windows, this appears to be sufficient on Qt5/Qt6. + # On Qt6, ANGLE is excluded by the enum. os.environ["QT_OPENGL"] = driver.value elif is_mac: QCoreApplication.setAttribute(Qt.ApplicationAttribute.AA_UseSoftwareOpenGL) elif is_lin: + # Qt5 only os.environ["QT_XCB_FORCE_SOFTWARE_OPENGL"] = "1" + # Required on Qt6 + if "QTWEBENGINE_CHROMIUM_FLAGS" not in os.environ: + os.environ["QTWEBENGINE_CHROMIUM_FLAGS"] = "--disable-gpu" PROFILE_CODE = os.environ.get("ANKI_PROFILE_CODE") diff --git a/qt/aqt/preferences.py b/qt/aqt/preferences.py index 5489e8707..8a0c51be5 100644 --- a/qt/aqt/preferences.py +++ b/qt/aqt/preferences.py @@ -290,7 +290,6 @@ 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 8f09c3253..0c163741f 100644 --- a/qt/aqt/profiles.py +++ b/qt/aqt/profiles.py @@ -44,22 +44,26 @@ class VideoDriver(Enum): return VideoDriver.Software def constrained_to_platform(self) -> VideoDriver: - if self == VideoDriver.ANGLE and not is_win: + if self == VideoDriver.ANGLE and not VideoDriver.supports_angle(): return VideoDriver.Software return self def next(self) -> VideoDriver: if self == VideoDriver.Software: return VideoDriver.OpenGL - elif self == VideoDriver.OpenGL and is_win: + elif self == VideoDriver.OpenGL and VideoDriver.supports_angle(): return VideoDriver.ANGLE else: return VideoDriver.Software + @staticmethod + def supports_angle() -> bool: + return is_win and qtmajor < 6 + @staticmethod def all_for_platform() -> list[VideoDriver]: all = [VideoDriver.OpenGL] - if is_win: + if VideoDriver.supports_angle(): all.append(VideoDriver.ANGLE) all.append(VideoDriver.Software) return all