Disable full screen on Windows with OpenGL (#1715)

This commit is contained in:
RumovZ 2022-03-09 05:21:54 +01:00 committed by GitHub
parent e6028cd9a4
commit c21e6e2b97
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 32 additions and 2 deletions

View file

@ -53,6 +53,7 @@ actions-previous-card-info = Previous Card Info
# By convention, the name of a menu action is suffixed with "..." if additional
# input is required before it can be performed. E.g. "Export..." vs. "Delete".
actions-with-ellipsis = { $action }...
actions-currently-unsupported = This action is currently not supported on your system.
## Flags

View file

@ -30,6 +30,7 @@ message HelpPageLinkRequest {
CUSTOMIZING_FIELDS = 14;
DECK_OPTIONS = 15;
EDITING_FEATURES = 16;
FULL_SCREEN_ISSUE = 17;
}
HelpPage page = 1;
}

View file

@ -66,6 +66,7 @@ from aqt.utils import (
checkInvalidFilename,
current_window,
disable_help_button,
disallow_full_screen,
getFile,
getOnlyText,
openHelp,
@ -1273,8 +1274,17 @@ title="{}" {}>{}</button>""".format(
##########################################################################
def on_toggle_full_screen(self) -> None:
window = self.app.activeWindow()
window.setWindowState(window.windowState() ^ Qt.WindowState.WindowFullScreen)
if disallow_full_screen():
showWarning(
tr.actions_currently_unsupported(),
parent=self,
help=HelpPage.FULL_SCREEN_ISSUE,
)
else:
window = self.app.activeWindow()
window.setWindowState(
window.windowState() ^ Qt.WindowState.WindowFullScreen
)
# Auto update
##########################################################################

View file

@ -852,6 +852,23 @@ def qtMenuShortcutWorkaround(qmenu: QMenu) -> None:
######################################################################
def disallow_full_screen() -> bool:
"""Test for OpenGl on Windows, which is known to cause issues with full screen mode.
On Qt6, the driver is not detectable, so check if it has been set explicitly.
"""
from aqt import mw
from aqt.profiles import VideoDriver
return is_win and (
(qtmajor == 5 and mw.pm.video_driver() == VideoDriver.OpenGL)
or (
qtmajor == 6
and not os.environ.get("ANKI_SOFTWAREOPENGL")
and os.environ.get("QT_OPENGL") != "software"
)
)
def add_ellipsis_to_action_label(*actions: QAction) -> None:
"""Pass actions to add '...' to their labels, indicating that more input is
required before they can be performed.

View file

@ -29,6 +29,7 @@ impl HelpPage {
HelpPage::CustomizingFields => "editing.html#customizing-fields",
HelpPage::DeckOptions => "deck-options.html",
HelpPage::EditingFeatures => "editing.html#editing-features",
HelpPage::FullScreenIssue => "platform/windows/display-issues.html#full-screen",
}
}
}