|
125 | 125 | NO_SETTINGS_MSG = _("No settings") |
126 | 126 |
|
127 | 127 |
|
| 128 | +def toggleBooleanValue( |
| 129 | + configSection: str, |
| 130 | + configKey: str, |
| 131 | + enabledMsg: str, |
| 132 | + disabledMsg: str, |
| 133 | +) -> None: |
| 134 | + """ |
| 135 | + Toggles a boolean value in the configuration and returns the appropriate message. |
| 136 | +
|
| 137 | + :param configSection: The configuration section containing the boolean key. |
| 138 | + :param configKey: The configuration key associated with the boolean value. |
| 139 | + :param enabledMsg: The message for the enabled state. |
| 140 | + :param disabledMsg: The message for the disabled state. |
| 141 | + :return: None. |
| 142 | + """ |
| 143 | + currentValue = config.conf[configSection][configKey] |
| 144 | + newValue = not currentValue |
| 145 | + config.conf[configSection][configKey] = newValue |
| 146 | + |
| 147 | + msg = enabledMsg if newValue else disabledMsg |
| 148 | + ui.message(msg) |
| 149 | + |
| 150 | + |
128 | 151 | class GlobalCommands(ScriptableObject): |
129 | 152 | """Commands that are available at all times, regardless of the current focus.""" |
130 | 153 |
|
@@ -902,6 +925,21 @@ def script_toggleReportLinks(self, gesture): |
902 | 925 | config.conf["documentFormatting"]["reportLinks"] = True |
903 | 926 | ui.message(state) |
904 | 927 |
|
| 928 | + @script( |
| 929 | + # Translators: Input help mode message for toggle report link type command. |
| 930 | + description=_("Toggles on and off the reporting of link type"), |
| 931 | + category=SCRCAT_DOCUMENTFORMATTING, |
| 932 | + ) |
| 933 | + def script_toggleReportLinkType(self, gesture: inputCore.InputGesture): |
| 934 | + toggleBooleanValue( |
| 935 | + configSection="documentFormatting", |
| 936 | + configKey="reportLinkType", |
| 937 | + # Translators: The message announced when toggling the report link type document formatting setting. |
| 938 | + enabledMsg=_("Report link type on"), |
| 939 | + # Translators: The message announced when toggling the report link type document formatting setting. |
| 940 | + disabledMsg=_("Report link type off"), |
| 941 | + ) |
| 942 | + |
905 | 943 | @script( |
906 | 944 | # Translators: Input help mode message for toggle report graphics command. |
907 | 945 | description=_("Toggles on and off the reporting of graphics"), |
|
0 commit comments