Skip to content
Merged
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
46 changes: 43 additions & 3 deletions addon/globalPlugins/virtualRevision.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
import ui
import scriptHandler
import addonHandler
import config
import gui
import wx
from gui import guiHelper, settingsDialogs

addonHandler.initTranslation()

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -119,6 +144,18 @@ 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):
super().terminate()
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 @@ -143,11 +180,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():
Expand Down