Skip to content

Commit

Permalink
Fix script and function to toggle boolean values
Browse files Browse the repository at this point in the history
  • Loading branch information
nvdaes committed Sep 3, 2024
1 parent 8fb71ca commit d6d59f8
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions source/globalCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@


def toggleBooleanValue(
configSection: str,
configKey: str,
# Translators: The message announced when toggling the configKey setting.
enabledMsg: str,
Expand All @@ -134,14 +135,15 @@ def toggleBooleanValue(
"""
Toggles a boolean value in the configuration and returns the appropriate message.
:param configSection: The configuration section containing the boolean key.
:param configKey: The configuration key associated with the boolean value.
:param enabledMsg: The message for the enabled state.
:param disabledMsg: The message for the disabled state.
:return: The translatable message to be displayed to the user.
"""
currentValue = config.conf[configKey]
currentValue = config.conf[configSection][configKey]
newValue = not currentValue
config.conf[configKey] = newValue
config.conf[configSection][configKey] = newValue

return _(enabledMsg) if newValue else _(disabledMsg)

Expand Down Expand Up @@ -930,7 +932,8 @@ def script_toggleReportLinks(self, gesture):
)
def script_toggleReportLinkType(self, gesture: inputCore.InputGesture):
msg = toggleBooleanValue(
configKey="documentFormatting.reportLinkType",
configSection="documentFormatting",
configKey="reportLinkType",
enabledMsg="Report link type on",
disabledMsg="Report link type off",
)
Expand Down

0 comments on commit d6d59f8

Please sign in to comment.