mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
Expose video driver settings on Qt6, sans ANGLE
This commit is contained in:
parent
0db921dd39
commit
e4f46463f2
3 changed files with 15 additions and 11 deletions
|
@ -361,9 +361,6 @@ def parseArgs(argv: list[str]) -> tuple[argparse.Namespace, list[str]]:
|
||||||
|
|
||||||
|
|
||||||
def setupGL(pm: aqt.profiles.ProfileManager) -> None:
|
def setupGL(pm: aqt.profiles.ProfileManager) -> None:
|
||||||
if is_mac:
|
|
||||||
return
|
|
||||||
|
|
||||||
driver = pm.video_driver()
|
driver = pm.video_driver()
|
||||||
|
|
||||||
# work around pyqt loading wrong GL library
|
# work around pyqt loading wrong GL library
|
||||||
|
@ -413,19 +410,23 @@ def setupGL(pm: aqt.profiles.ProfileManager) -> None:
|
||||||
|
|
||||||
qInstallMessageHandler(msgHandler)
|
qInstallMessageHandler(msgHandler)
|
||||||
|
|
||||||
# ignore set graphics driver on Qt6 for now
|
|
||||||
if qtmajor > 5:
|
|
||||||
return
|
|
||||||
|
|
||||||
if driver == VideoDriver.OpenGL:
|
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
|
pass
|
||||||
else:
|
else:
|
||||||
if is_win:
|
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
|
os.environ["QT_OPENGL"] = driver.value
|
||||||
elif is_mac:
|
elif is_mac:
|
||||||
QCoreApplication.setAttribute(Qt.ApplicationAttribute.AA_UseSoftwareOpenGL)
|
QCoreApplication.setAttribute(Qt.ApplicationAttribute.AA_UseSoftwareOpenGL)
|
||||||
elif is_lin:
|
elif is_lin:
|
||||||
|
# Qt5 only
|
||||||
os.environ["QT_XCB_FORCE_SOFTWARE_OPENGL"] = "1"
|
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")
|
PROFILE_CODE = os.environ.get("ANKI_PROFILE_CODE")
|
||||||
|
|
|
@ -290,7 +290,6 @@ class Preferences(QDialog):
|
||||||
self.form.video_driver.setCurrentIndex(
|
self.form.video_driver.setCurrentIndex(
|
||||||
self.video_drivers.index(self.mw.pm.video_driver())
|
self.video_drivers.index(self.mw.pm.video_driver())
|
||||||
)
|
)
|
||||||
self.form.video_driver.setVisible(qtmajor == 5)
|
|
||||||
|
|
||||||
def update_video_driver(self) -> None:
|
def update_video_driver(self) -> None:
|
||||||
new_driver = self.video_drivers[self.form.video_driver.currentIndex()]
|
new_driver = self.video_drivers[self.form.video_driver.currentIndex()]
|
||||||
|
|
|
@ -44,22 +44,26 @@ class VideoDriver(Enum):
|
||||||
return VideoDriver.Software
|
return VideoDriver.Software
|
||||||
|
|
||||||
def constrained_to_platform(self) -> VideoDriver:
|
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 VideoDriver.Software
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def next(self) -> VideoDriver:
|
def next(self) -> VideoDriver:
|
||||||
if self == VideoDriver.Software:
|
if self == VideoDriver.Software:
|
||||||
return VideoDriver.OpenGL
|
return VideoDriver.OpenGL
|
||||||
elif self == VideoDriver.OpenGL and is_win:
|
elif self == VideoDriver.OpenGL and VideoDriver.supports_angle():
|
||||||
return VideoDriver.ANGLE
|
return VideoDriver.ANGLE
|
||||||
else:
|
else:
|
||||||
return VideoDriver.Software
|
return VideoDriver.Software
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def supports_angle() -> bool:
|
||||||
|
return is_win and qtmajor < 6
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def all_for_platform() -> list[VideoDriver]:
|
def all_for_platform() -> list[VideoDriver]:
|
||||||
all = [VideoDriver.OpenGL]
|
all = [VideoDriver.OpenGL]
|
||||||
if is_win:
|
if VideoDriver.supports_angle():
|
||||||
all.append(VideoDriver.ANGLE)
|
all.append(VideoDriver.ANGLE)
|
||||||
all.append(VideoDriver.Software)
|
all.append(VideoDriver.Software)
|
||||||
return all
|
return all
|
||||||
|
|
Loading…
Reference in a new issue