From fdbf75d014336cdebb82a7cb9f89989bfb087b9c Mon Sep 17 00:00:00 2001 From: Rui Batista Date: Mon, 24 Aug 2026 18:56:01 +0100 Subject: [PATCH 1/3] Add a setting to toggle the UWP review alert beeps Reviewing a UWP window walks the element tree, which can take a moment, so a beep plays before and after as progress feedback. On faster machines the walk finishes near-instantly and the double beep on every press is just noise. Adds a Virtual Revision category to NVDA's settings with a checkbox to turn it off; the default is unchanged. Ported from ruifontes/virtualReview#17. Co-Authored-By: serrebidev Co-Authored-By: Claude Opus 5 (1M context) --- addon/globalPlugins/virtualRevision.py | 45 ++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/addon/globalPlugins/virtualRevision.py b/addon/globalPlugins/virtualRevision.py index 994bbe8..9beaec0 100644 --- a/addon/globalPlugins/virtualRevision.py +++ b/addon/globalPlugins/virtualRevision.py @@ -11,6 +11,10 @@ import ui import scriptHandler import addonHandler +import config +import gui +import wx +from gui import guiHelper, settingsDialogs addonHandler.initTranslation() @@ -76,6 +80,27 @@ def _cleanTerminalText(text): return "\n".join(lines) +config.conf.spec["virtualRevision"] = { + "playBeep": "boolean(default=True)", +} + + +class VirtualRevisionSettingsPanel(settingsDialogs.SettingsPanel): + # Translators: Title of the Virtual Revision settings panel. + title = _("Virtual Revision") + + def makeSettings(self, settingsSizer): + sHelper = guiHelper.BoxSizerHelper(self, sizer=settingsSizer) + # Translators: Label for the checkbox that toggles the alert beeps for UWP windows. + self.playBeepCheckBox = sHelper.addItem( + wx.CheckBox(self, label=_("Play alert &beeps when reviewing UWP windows")) + ) + self.playBeepCheckBox.SetValue(config.conf["virtualRevision"]["playBeep"]) + + def onSave(self): + config.conf["virtualRevision"]["playBeep"] = self.playBeepCheckBox.GetValue() + + def obtainUWPWindowText(): foreground = api.getForegroundObject() desktop = api.getDesktopObject() @@ -119,6 +144,17 @@ def obtainUWPWindowText(): class GlobalPlugin(globalPluginHandler.GlobalPlugin): scriptCategory = SCRCAT_TEXTREVIEW + def __init__(self): + super().__init__() + if not globalVars.appArgs.secure: + gui.settingsDialogs.NVDASettingsDialog.categoryClasses.append(VirtualRevisionSettingsPanel) + + def terminate(self): + try: + gui.settingsDialogs.NVDASettingsDialog.categoryClasses.remove(VirtualRevisionSettingsPanel) + except ValueError: + pass + @scriptHandler.script( # Translators: Message presented in input help mode. description=_("Opens a window containing the text of the currently focused window for easy review."), @@ -143,11 +179,14 @@ def script_virtualWindowReview(self, gesture): text = _cleanTerminalText(info.clipboardText) # Because it may take a while to iterate through elements, play abeep to alert users of this fact and the fact it's a UWP screen. elif obj.windowClassName.startswith(("Windows.UI.Core", "Windows.UI.Input.InputSite")): - import tones + playBeep = config.conf["virtualRevision"]["playBeep"] + if playBeep: + import tones - tones.beep(400, 300) + tones.beep(400, 300) text = "\n".join(obtainUWPWindowText()) - tones.beep(400, 50) + if playBeep: + tones.beep(400, 50) else: root = None for ancestor in api.getFocusAncestors(): From aa804a1bf2d699b60a10c6708be484f6ac89b9bd Mon Sep 17 00:00:00 2001 From: Rui Batista Date: Mon, 24 Aug 2026 18:57:34 +0100 Subject: [PATCH 2/3] Add trailing comma required by the add-trailing-comma hook Co-Authored-By: Claude Opus 5 (1M context) --- addon/globalPlugins/virtualRevision.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addon/globalPlugins/virtualRevision.py b/addon/globalPlugins/virtualRevision.py index 9beaec0..bff9e48 100644 --- a/addon/globalPlugins/virtualRevision.py +++ b/addon/globalPlugins/virtualRevision.py @@ -93,7 +93,7 @@ def makeSettings(self, settingsSizer): sHelper = guiHelper.BoxSizerHelper(self, sizer=settingsSizer) # Translators: Label for the checkbox that toggles the alert beeps for UWP windows. self.playBeepCheckBox = sHelper.addItem( - wx.CheckBox(self, label=_("Play alert &beeps when reviewing UWP windows")) + wx.CheckBox(self, label=_("Play alert &beeps when reviewing UWP windows")), ) self.playBeepCheckBox.SetValue(config.conf["virtualRevision"]["playBeep"]) From b204993e921dd2a5f111f29314b0ea409126b21e Mon Sep 17 00:00:00 2001 From: Rui Batista Date: Mon, 24 Aug 2026 19:02:25 +0100 Subject: [PATCH 3/3] Call super().terminate() when unregistering the settings panel Co-Authored-By: Claude Opus 5 (1M context) --- addon/globalPlugins/virtualRevision.py | 1 + 1 file changed, 1 insertion(+) diff --git a/addon/globalPlugins/virtualRevision.py b/addon/globalPlugins/virtualRevision.py index bff9e48..db3d9f1 100644 --- a/addon/globalPlugins/virtualRevision.py +++ b/addon/globalPlugins/virtualRevision.py @@ -150,6 +150,7 @@ def __init__(self): gui.settingsDialogs.NVDASettingsDialog.categoryClasses.append(VirtualRevisionSettingsPanel) def terminate(self): + super().terminate() try: gui.settingsDialogs.NVDASettingsDialog.categoryClasses.remove(VirtualRevisionSettingsPanel) except ValueError: