From 8e2126087b5e5622c2e33b67956fbe3b4ca5af46 Mon Sep 17 00:00:00 2001 From: Luke Davis Date: Mon, 10 Jul 2023 20:33:40 -0400 Subject: [PATCH] Added an unassigned command (undocumented) to open the add-on settings. --- addon/globalPlugins/speechLogger/__init__.py | 29 ++++++++++++++++++-- buildVars.py | 2 +- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/addon/globalPlugins/speechLogger/__init__.py b/addon/globalPlugins/speechLogger/__init__.py index e734b9a..8f5bc42 100644 --- a/addon/globalPlugins/speechLogger/__init__.py +++ b/addon/globalPlugins/speechLogger/__init__.py @@ -26,7 +26,7 @@ """ import os -import types +import wx from time import strftime from typing import Optional, Dict from functools import wraps @@ -38,6 +38,7 @@ import globalVars import ui import gui +from gui.settingsDialogs import SettingsDialog, MultiCategorySettingsDialog import config import speech from speech.speechWithoutPauses import SpeechWithoutPauses @@ -45,7 +46,7 @@ from speech.priorities import Spri from scriptHandler import script from logHandler import log -from globalCommands import SCRCAT_TOOLS +from globalCommands import SCRCAT_TOOLS, SCRCAT_CONFIG from .configUI import SpeechLoggerSettings, getConf from .immutableKeyObj import ImmutableKeyObj @@ -414,6 +415,30 @@ def script_toggleRemoteSpeechLogging(self, gesture): # Translators: a message to tell the user that we can't start this kind of logging ui.message(_("Remote speech logging has been disabled by an error or your NVDA configuration.")) + @script( + # Translators: Input help mode message for open Speech Logger settings command. + description=_("Opens the Speech Logger add-on's settings"), + category=SCRCAT_CONFIG + ) + @gui.blockAction.when(gui.blockAction.Context.MODAL_DIALOG_OPEN) + def script_activateSpeechLoggerSettingsDialog(self, gesture): + wx.CallAfter(self.onSpeechLoggerSettingsCommand, None) + + def onSpeechLoggerSettingsCommand(self, evt, *args, **kwargs): + gui.mainFrame.prePopup() + try: + SpeechLoggerSettings(gui.mainFrame, *args, **kwargs).Show() + except SettingsDialog.MultiInstanceErrorWithDialog as errorWithDialog: + errorWithDialog.dialog.SetFocus() + except MultiCategorySettingsDialog.CategoryUnavailableError: + # Translators: Message shown when trying to open an unavailable category of a multi category settings dialog + # (example: when trying to open touch interaction settings on an unsupported system). + gui.messageBox( + _("The settings panel you tried to open is unavailable on this system."), + _("Error"),style=wx.OK | wx.ICON_ERROR + ) + gui.mainFrame.postPopup() + def logToFile(self, file: str, sequence: Optional[SpeechSequence], initialText: Optional[str]) -> None: """Append text of the given speech sequence to the given file. If an initialText is given, it appears on its own line before the logged text. diff --git a/buildVars.py b/buildVars.py index d2b3257..89e8d74 100644 --- a/buildVars.py +++ b/buildVars.py @@ -25,7 +25,7 @@ def _(arg): # Translators: Long description to be shown for this add-on on add-on information from add-ons manager "addon_description": _("""Logs speech utterances to a file. Can also log NVDA remote session speech from the NVDA Remote add-on, to the same or another file."""), # version - "addon_version": "23.2.03", + "addon_version": "23.2.021", # Author(s) "addon_author": "Luke Davis , James Scholes", # URL for the add-on documentation support