Skip to content

Commit

Permalink
Global commands: convert tools scripts to use script decorator. Re nv…
Browse files Browse the repository at this point in the history
…access#11964.

Convert tools scripts to script decorator, including app module info, UWP OCR, speech viewer, and others, some of them with gestures unassigned.
  • Loading branch information
josephsl committed Dec 24, 2020
1 parent 9e2f252 commit 512eb24
Showing 1 changed file with 54 additions and 27 deletions.
81 changes: 54 additions & 27 deletions source/globalCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -1920,30 +1920,38 @@ def script_speakForeground(self,gesture):
if obj:
sayAllHandler.readObjects(obj)

@script(
gesture="kb(desktop):NVDA+control+f2"
)
def script_test_navigatorDisplayModelText(self,gesture):
obj=api.getNavigatorObject()
text=obj.displayText
speech.speakMessage(text)
log.info(text)

@script(
description=_(
# Translators: GUI development tool, to get information about the components used in the NVDA GUI
"Opens the WX GUI inspection tool. Used to get more information about the state of GUI components."
),
category=SCRCAT_TOOLS
)
def script_startWxInspectionTool(self, gesture):
import wx.lib.inspection
wx.lib.inspection.InspectionTool().Show()
script_startWxInspectionTool.__doc__ = _(
# Translators: GUI development tool, to get information about the components used in the NVDA GUI
"Opens the WX GUI inspection tool. Used to get more information about the state of GUI components."
)
script_startWxInspectionTool.category = SCRCAT_TOOLS

@script(
# Translators: Input help mode message for developer info for current navigator object command, used by developers to examine technical info on navigator object. This command also serves as a shortcut to open NVDA log viewer.
description=_("Logs information about the current navigator object which is useful to developers and activates the log viewer so the information can be examined."),
category=SCRCAT_TOOLS,
gesture="kb:NVDA+f1"
)
def script_navigatorObject_devInfo(self,gesture):
obj=api.getNavigatorObject()
if hasattr(obj, "devInfo"):
log.info("Developer info for navigator object:\n%s" % "\n".join(obj.devInfo), activateLogViewer=True)
else:
log.info("No developer info for navigator object", activateLogViewer=True)
# Translators: Input help mode message for developer info for current navigator object command, used by developers to examine technical info on navigator object. This command also serves as a shortcut to open NVDA log viewer.
script_navigatorObject_devInfo.__doc__ = _("Logs information about the current navigator object which is useful to developers and activates the log viewer so the information can be examined.")
script_navigatorObject_devInfo.category=SCRCAT_TOOLS

@script(
description=_(
Expand Down Expand Up @@ -2125,6 +2133,12 @@ def script_passNextKeyThrough(self,gesture):
# Translators: Spoken to indicate that the next key press will be sent straight to the current program as though NVDA is not running.
ui.message(_("Pass next key through"))

@script(
# Translators: Input help mode message for report current program name and app module name command.
description=_("Speaks the filename of the active application along with the name of the currently loaded appModule"),
category=SCRCAT_TOOLS,
gesture="kb:NVDA+control+f1"
)
def script_reportAppModuleInfo(self,gesture):
focus=api.getFocusObject()
message = ''
Expand All @@ -2139,9 +2153,6 @@ def script_reportAppModuleInfo(self,gesture):
# For example, the complete message for Windows explorer is: "explorer module is loaded. Explorer.exe is currenty running."
message +=_(" %s is currently running.") % appName
ui.message(message)
# Translators: Input help mode message for report current program name and app module name command.
script_reportAppModuleInfo.__doc__ = _("Speaks the filename of the active application along with the name of the currently loaded appModule")
script_reportAppModuleInfo.category=SCRCAT_TOOLS

@script(
# Translators: Input help mode message for go to general settings command.
Expand Down Expand Up @@ -2333,6 +2344,12 @@ def script_revertConfiguration(self,gesture):
elif scriptCount==2:
gui.mainFrame.onRevertToDefaultConfigurationCommand(None)

@script(
# Translators: Input help mode message for activate python console command.
description=_("Activates the NVDA Python Console, primarily useful for development"),
category=SCRCAT_TOOLS,
gesture="kb:NVDA+control+z"
)
def script_activatePythonConsole(self,gesture):
if globalVars.appArgs.secure or config.isAppX:
return
Expand All @@ -2341,16 +2358,20 @@ def script_activatePythonConsole(self,gesture):
pythonConsole.initialize()
pythonConsole.consoleUI.console.updateNamespaceSnapshotVars()
pythonConsole.activate()
# Translators: Input help mode message for activate python console command.
script_activatePythonConsole.__doc__ = _("Activates the NVDA Python Console, primarily useful for development")
script_activatePythonConsole.category=SCRCAT_TOOLS

@script(
# Translators: Input help mode message for activate manage add-ons command.
description=_("Activates the NVDA Add-ons Manager to install and uninstall add-on packages for NVDA"),
category=SCRCAT_TOOLS
)
def script_activateAddonsManager(self,gesture):
wx.CallAfter(gui.mainFrame.onAddonsManagerCommand, None)
# Translators: Input help mode message for activate manage add-ons command.
script_activateAddonsManager.__doc__ = _("Activates the NVDA Add-ons Manager to install and uninstall add-on packages for NVDA")
script_activateAddonsManager.category=SCRCAT_TOOLS

@script(
# Translators: Input help mode message for toggle speech viewer command.
description=_("Toggles the NVDA Speech viewer, a floating window that allows you to view all the text that NVDA is currently speaking"),
category=SCRCAT_TOOLS
)
def script_toggleSpeechViewer(self,gesture):
if gui.speechViewer.isActive:
# Translators: The message announced when disabling speech viewer.
Expand All @@ -2363,9 +2384,6 @@ def script_toggleSpeechViewer(self,gesture):
gui.speechViewer.activate()
gui.mainFrame.sysTrayIcon.menu_tools_toggleSpeechViewer.Check(True)
ui.message(state)
# Translators: Input help mode message for toggle speech viewer command.
script_toggleSpeechViewer.__doc__ = _("Toggles the NVDA Speech viewer, a floating window that allows you to view all the text that NVDA is currently speaking")
script_toggleSpeechViewer.category=SCRCAT_TOOLS

@script(
# Translators: Input help mode message for toggle braille tether to command (tethered means connected to or follows).
Expand Down Expand Up @@ -2712,16 +2730,19 @@ def script_braille_toggleNVDAKey(self, gesture):
script_braille_toggleNVDAKey.category=inputCore.SCRCAT_KBEMU
script_braille_toggleNVDAKey.bypassInputHelp = True

@script(
# Translators: Input help mode message for reload plugins command.
description=_("Reloads app modules and global plugins without restarting NVDA, which can be Useful for developers"),
category=SCRCAT_TOOLS,
gesture="kb:NVDA+control+f3"
)
def script_reloadPlugins(self, gesture):
import globalPluginHandler
appModuleHandler.reloadAppModules()
globalPluginHandler.reloadGlobalPlugins()
NVDAObject.clearDynamicClassCache()
# Translators: Presented when plugins (app modules and global plugins) are reloaded.
ui.message(_("Plugins reloaded"))
# Translators: Input help mode message for reload plugins command.
script_reloadPlugins.__doc__=_("Reloads app modules and global plugins without restarting NVDA, which can be Useful for developers")
script_reloadPlugins.category=SCRCAT_TOOLS

@script(
# Translators: Input help mode message for a touchscreen gesture.
Expand Down Expand Up @@ -2892,6 +2913,11 @@ def script_toggleConfigProfileTriggers(self,gesture):
state = _("Configuration profile triggers enabled")
ui.message(state)

@script(
# Translators: Describes a command.
description=_("Begins interaction with math content"),
gesture="kb:NVDA+alt+m"
)
def script_interactWithMath(self, gesture):
import mathPres
mathMl = mathPres.getMathMlFromTextInfo(api.getReviewPosition())
Expand All @@ -2908,9 +2934,12 @@ def script_interactWithMath(self, gesture):
ui.message(_("Not math"))
return
mathPres.interactWithMathMl(mathMl)
# Translators: Describes a command.
script_interactWithMath.__doc__ = _("Begins interaction with math content")

@script(
# Translators: Describes a command.
description=_("Recognizes the content of the current navigator object with Windows 10 OCR"),
gesture="kb:NVDA+r"
)
def script_recognizeWithUwpOcr(self, gesture):
if not winVersion.isUwpOcrAvailable():
# Translators: Reported when Windows 10 OCR is not available.
Expand All @@ -2919,8 +2948,6 @@ def script_recognizeWithUwpOcr(self, gesture):
from contentRecog import uwpOcr, recogUi
recog = uwpOcr.UwpOcr()
recogUi.recognizeNavigatorObject(recog)
# Translators: Describes a command.
script_recognizeWithUwpOcr.__doc__ = _("Recognizes the content of the current navigator object with Windows 10 OCR")

_tempEnableScreenCurtain = True
_waitingOnScreenCurtainWarningDialog: Optional[wx.Dialog] = None
Expand Down

0 comments on commit 512eb24

Please sign in to comment.