From 44e4ff53ddfd26798727ef1748f96daa45effa0b Mon Sep 17 00:00:00 2001 From: Taka Date: Sat, 11 Dec 2021 03:54:59 +1100 Subject: [PATCH] Got accelerator underlines to show properly on Windows. --- vasl_templates/main.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/vasl_templates/main.py b/vasl_templates/main.py index 2d33545..8124b41 100755 --- a/vasl_templates/main.py +++ b/vasl_templates/main.py @@ -22,7 +22,7 @@ from PyQt5.QtCore import Qt, QSettings, QDir import PyQt5.QtCore import click -from vasl_templates.webapp.utils import SimpleError +from vasl_templates.webapp.utils import SimpleError, is_windows # NOTE: We're supposed to do the following to support HiDPI, but it causes the main window # to become extremely large when the Windows zoom level is high (and it doesn't really fix @@ -213,6 +213,16 @@ def _do_main( template_pack, default_scenario, remote_debugging, debug ): #pylin opengl_type = getattr( Qt, opengl_type ) QApplication.setAttribute( opengl_type ) + #pylint: disable=line-too-long + # FUDGE! This works around a weird problem on Windows, if it has been configured to *not* show + # accelerator underlines by default. Pressing ALT is supposed to show them, but doesn't :-/ + # The odd thing is, the default theme is "windowsvista", but we need to set it anyway (probably + # a timing issue during startup). It might also have something to do with virtualenv's: + # https://stackoverflow.com/questions/69032767/show-hide-menu-underline-accelerators-with-pyqt-according-to-platform-integratio#comment122036986_69032767 + #pylint: enable=line-too-long + if is_windows(): + QApplication.setStyle( "windowsvista" ) + # check if we should disable the embedded browser disable_browser = webapp.config.get( "DISABLE_WEBENGINEVIEW" )