Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 41 additions & 3 deletions addon/globalPlugins/virtualRevision.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,37 @@
import ui
import scriptHandler
import addonHandler
import config
import gui
import wx
from gui import guiHelper, settingsDialogs
addonHandler.initTranslation()

try:
from globalCommands import SCRCAT_TEXTREVIEW
except:
SCRCAT_TEXTREVIEW = None

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()
Expand Down Expand Up @@ -60,6 +84,17 @@ 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."),
Expand All @@ -73,10 +108,13 @@ def script_virtualWindowReview(self, gesture):
obj = api.getFocusObject()
# 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.
if obj.windowClassName.startswith(("Windows.UI.Core", "Windows.UI.Input.InputSite")):
import tones
tones.beep(400, 300)
playBeep = config.conf["virtualRevision"]["playBeep"]
if playBeep:
import tones
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():
Expand Down