Skip to content

Commit d49a6f5

Browse files
authored
Merge f6d69eb into 6d97c5a
2 parents 6d97c5a + f6d69eb commit d49a6f5

4 files changed

Lines changed: 130 additions & 6 deletions

File tree

source/globalCommands.py

Lines changed: 62 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@
114114
# Translators: The name of a category of NVDA commands.
115115
SCRCAT_DOCUMENTFORMATTING = _("Document formatting")
116116

117+
# Translators: Reported when there are no settings to configure in synth settings ring
118+
# (example: when there is no setting for language).
119+
NO_SETTINGS_MSG = _("No settings")
120+
117121
class GlobalCommands(ScriptableObject):
118122
"""Commands that are available at all times, regardless of the current focus.
119123
"""
@@ -312,6 +316,32 @@ def script_dateTime(self,gesture):
312316
text=winKernel.GetDateFormatEx(winKernel.LOCALE_NAME_USER_DEFAULT, winKernel.DATE_LONGDATE, None, None)
313317
ui.message(text)
314318

319+
@script(
320+
# Translators: Input help mode message for set the first value in the synth ring setting.
321+
description=_("Set the first value of the current setting in the synth settings ring"),
322+
category=SCRCAT_SPEECH
323+
)
324+
def script_firstValueSynthRing(self, gesture: inputCore.InputGesture):
325+
settingName = globalVars.settingsRing.currentSettingName
326+
if not settingName:
327+
ui.message(NO_SETTINGS_MSG)
328+
return
329+
settingValue = globalVars.settingsRing.first()
330+
ui.message("%s %s" % (settingName, settingValue))
331+
332+
@script(
333+
# Translators: Input help mode message for set the last value in the synth ring settings.
334+
description=_("Set the last value of the current setting in the synth settings ring"),
335+
category=SCRCAT_SPEECH
336+
)
337+
def script_lastValueSynthRing(self, gesture: inputCore.InputGesture):
338+
settingName = globalVars.settingsRing.currentSettingName
339+
if not settingName:
340+
ui.message(NO_SETTINGS_MSG)
341+
return
342+
settingValue = globalVars.settingsRing.last()
343+
ui.message("%s %s" % (settingName, settingValue))
344+
315345
@script(
316346
# Translators: Input help mode message for increase synth setting value command.
317347
description=_("Increases the currently active setting in the synth settings ring"),
@@ -321,12 +351,25 @@ def script_dateTime(self,gesture):
321351
def script_increaseSynthSetting(self,gesture):
322352
settingName=globalVars.settingsRing.currentSettingName
323353
if not settingName:
324-
# Translators: Reported when there are no settings to configure in synth settings ring (example: when there is no setting for language).
325-
ui.message(_("No settings"))
354+
ui.message(NO_SETTINGS_MSG)
326355
return
327356
settingValue=globalVars.settingsRing.increase()
328357
ui.message("%s %s" % (settingName,settingValue))
329358

359+
@script(
360+
# Translators: Input help mode message for increasing synth setting value command in larger steps.
361+
description=_("Increases the currently active setting in the synth settings ring in a larger step"),
362+
category=SCRCAT_SPEECH,
363+
gestures=("kb(desktop):NVDA+control+pageUp", "kb(laptop):NVDA+shift+control+pageUp")
364+
)
365+
def script_increaseLargeSynthSetting(self, gesture: inputCore.InputGesture):
366+
settingName = globalVars.settingsRing.currentSettingName
367+
if not settingName:
368+
ui.message(NO_SETTINGS_MSG)
369+
return
370+
settingValue = globalVars.settingsRing.increaseLarge()
371+
ui.message("%s %s" % (settingName, settingValue))
372+
330373
@script(
331374
# Translators: Input help mode message for decrease synth setting value command.
332375
description=_("Decreases the currently active setting in the synth settings ring"),
@@ -336,11 +379,25 @@ def script_increaseSynthSetting(self,gesture):
336379
def script_decreaseSynthSetting(self,gesture):
337380
settingName=globalVars.settingsRing.currentSettingName
338381
if not settingName:
339-
ui.message(_("No settings"))
382+
ui.message(NO_SETTINGS_MSG)
340383
return
341384
settingValue=globalVars.settingsRing.decrease()
342385
ui.message("%s %s" % (settingName,settingValue))
343386

387+
@script(
388+
# Translators: Input help mode message for decreasing synth setting value command in larger steps.
389+
description=_("Decreases the currently active setting in the synth settings ring in a larger step"),
390+
category=SCRCAT_SPEECH,
391+
gestures=("kb(desktop):NVDA+control+pageDown", "kb(laptop):NVDA+control+shift+pageDown")
392+
)
393+
def script_decreaseLargeSynthSetting(self, gesture: inputCore.InputGesture):
394+
settingName = globalVars.settingsRing.currentSettingName
395+
if not settingName:
396+
ui.message(NO_SETTINGS_MSG)
397+
return
398+
settingValue = globalVars.settingsRing.decreaseLarge()
399+
ui.message("%s %s" % (settingName, settingValue))
400+
344401
@script(
345402
# Translators: Input help mode message for next synth setting command.
346403
description=_("Moves to the next available setting in the synth settings ring"),
@@ -350,7 +407,7 @@ def script_decreaseSynthSetting(self,gesture):
350407
def script_nextSynthSetting(self,gesture):
351408
nextSettingName=globalVars.settingsRing.next()
352409
if not nextSettingName:
353-
ui.message(_("No settings"))
410+
ui.message(NO_SETTINGS_MSG)
354411
return
355412
nextSettingValue=globalVars.settingsRing.currentSettingValue
356413
ui.message("%s %s"%(nextSettingName,nextSettingValue))
@@ -364,7 +421,7 @@ def script_nextSynthSetting(self,gesture):
364421
def script_previousSynthSetting(self,gesture):
365422
previousSettingName=globalVars.settingsRing.previous()
366423
if not previousSettingName:
367-
ui.message(_("No settings"))
424+
ui.message(NO_SETTINGS_MSG)
368425
return
369426
previousSettingValue=globalVars.settingsRing.currentSettingValue
370427
ui.message("%s %s"%(previousSettingName,previousSettingValue))

source/synthSettingsRing.py

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import synthDriverHandler
44
import queueHandler
55
from autoSettingsUtils.driverSetting import BooleanDriverSetting, NumericDriverSetting
6-
6+
from typing import Any
77

88
class SynthSetting(baseObject.AutoPropertyObject):
99
"""a numeric synth setting. Has functions to set, get, increase and decrease its value """
@@ -13,17 +13,42 @@ def __init__(self,synth,setting,min=0,max=100):
1313
self.min = setting.minVal if isinstance(setting, NumericDriverSetting) else min
1414
self.max = setting.maxVal if isinstance(setting, NumericDriverSetting) else max
1515
self.step = setting.normalStep if isinstance(setting, NumericDriverSetting) else 1
16+
self.largeStep = self.setting.largeStep if isinstance(setting, NumericDriverSetting) else 10
17+
18+
def first(self) -> Any:
19+
"""Sets the value of the current synth setting to the first value."""
20+
val = self.min
21+
self.value = val
22+
return self._getReportValue(val)
23+
24+
def last(self) -> Any:
25+
"""Sets the value of the current synth setting to the last value."""
26+
val = self.max
27+
self.value = val
28+
return self._getReportValue(val)
1629

1730
def increase(self):
1831
val = min(self.max,self.value+self.step)
1932
self.value = val
2033
return self._getReportValue(val)
2134

35+
def increaseLarge(self) -> Any:
36+
"""Increases the value of the current synth setting by a larger step."""
37+
val = min(self.max, self.value + self.largeStep * 2)
38+
self.value = val
39+
return self._getReportValue(val)
40+
2241
def decrease(self):
2342
val = max(self.min,self.value-self.step)
2443
self.value = val
2544
return self._getReportValue(val)
2645

46+
def decreaseLarge(self) -> Any:
47+
"""Decreases the value of the current synth setting by a larger step."""
48+
val = max(self.min, self.value - self.largeStep * 2)
49+
self.value = val
50+
return self._getReportValue(val)
51+
2752
def _get_value(self):
2853
return getattr(self.synth,self.setting.id)
2954

@@ -124,18 +149,42 @@ def previous(self):
124149
return self.currentSettingName
125150
return None
126151

152+
def first(self) -> Any:
153+
""" set the current setting to the first value """
154+
if self._current is not None:
155+
return self.settings[self._current].first()
156+
return None
157+
158+
def last(self) -> Any:
159+
""" set the current setting to the last value """
160+
if self._current is not None:
161+
return self.settings[self._current].last()
162+
return None
163+
127164
def increase(self):
128165
""" increases the currentSetting and returns its new value """
129166
if self._current is not None:
130167
return self.settings[self._current].increase()
131168
return None
132169

170+
def increaseLarge(self) -> Any:
171+
""" increases the currentSetting in a larger step, (20 items, 20%) and returns its new value """
172+
if self._current is not None:
173+
return self.settings[self._current].increaseLarge()
174+
return None
175+
133176
def decrease(self):
134177
""" decreases the currentSetting and returns its new value """
135178
if self._current is not None:
136179
return self.settings[self._current].decrease()
137180
return None
138181

182+
def decreaseLarge(self) -> Any:
183+
""" Decreases the currentSetting in a larger step, (20 items, 20%) and returns its new value """
184+
if self._current is not None:
185+
return self.settings[self._current].decreaseLarge()
186+
return None
187+
139188
def updateSupportedSettings(self,synth):
140189
import ui
141190
from scriptHandler import _isScriptRunning

user_docs/en/changes.t2t

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ What's New in NVDA
77

88
== New Features ==
99
- In Windows 11, NVDA will announce alerts from voice typing and suggested actions including the top suggestion when copying data such as phone numbers to the clipboard (Windows 11 2022 Update and later). (#16009, @josephsl)
10+
- New input gestures:
11+
- Added commands to jump first, last, forward and backward through the synth settings ring. (#13768, #16095, @rmcpantoja)
12+
- Setting the first/last setting in the synth settings ring has no assigned gesture
13+
- Decrease and increase the current setting of the synth settings ring in a larger step:
14+
- Desktop: ``NVDA+control+pageUp`` or ``NVDA+control+pageDown``.
15+
- Laptop: ``NVDA+control+shift+pageUp`` or ``NVDA+control+shift+pageDown``.
16+
-
17+
-
18+
-
1019
- Added support for the BrailleEdgeS2 braille device. (#16033)
1120
-
1221

user_docs/en/userGuide.t2t

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,14 @@ The actual commands will not execute while in input help mode.
237237
| Move to next synth setting | ``NVDA+control+rightArrow`` | ``NVDA+shift+control+rightArrow`` | Moves to the next available speech setting after the current, wrapping around to the first setting again after the last |
238238
| Move to previous synth setting | ``NVDA+control+leftArrow`` | ``NVDA+shift+control+leftArrow`` | Moves to the next available speech setting before the current, wrapping around to the last setting after the first |
239239
| Increment current synth setting | ``NVDA+control+upArrow`` | ``NVDA+shift+control+upArrow`` | increases the current speech setting you are on. E.g. increases the rate, chooses the next voice, increases the volume |
240+
| Increment the current synth setting in a larger step | ``NVDA+control+pageUp`` | ``NVDA+shift+control+pageUp`` | Increases the value of the current speech setting you're on in larger steps. e.g. when you're on a voice setting, it will jump forward every 20 voices; when you're on slider settings (rate, pitch, etc) it will jump forward the value up to 20% |
241+
240242
| Decrement current synth setting | ``NVDA+control+downArrow`` | ``NVDA+shift+control+downArrow`` | decreases the current speech setting you are on. E.g. decreases the rate, chooses the previous voice, decreases the volume |
243+
| Decrement the current synth setting in a larger step | ``NVDA+control+pageDown`` | ``NVDA+shift+control+pageDown`` | Decreases the value of the current speech setting you're on in larger steps. e.g. when you're on a voice setting, it will jump backward every 20 voices; when you're on a slider setting, it will jump backward the value up to 20%. |
244+
245+
It is also possible to set the first or last value of the current synth setting by assign custom gestures in [Input Gestures dialog #InputGestures], under the speech category.
246+
This means, for example, when you're on a rate setting, it will set the rate to 0 or 100.
247+
When you're on a voice setting, it will set the first or last voice.
241248

242249
+++ Web navigation +++[WebNavigation]
243250
The full list of Single Letter Navigation keys is in the [Browse Mode #BrowseMode] section of the user guide.
@@ -1658,7 +1665,9 @@ If you wish to quickly change speech settings without going to the Speech catego
16581665
| Move to next synth setting | NVDA+control+rightArrow | NVDA+shift+control+rightArrow | Moves to the next available speech setting after the current, wrapping around to the first setting again after the last |
16591666
| Move to previous synth setting | NVDA+control+leftArrow | NVDA+shift+control+leftArrow | Moves to the next available speech setting before the current, wrapping around to the last setting after the first |
16601667
| Increment current synth setting | NVDA+control+upArrow | NVDA+shift+control+upArrow | increases the current speech setting you are on. E.g. increases the rate, chooses the next voice, increases the volume |
1668+
| Increment the current synth setting in a larger step | ``NVDA+control+pageUp`` | ``NVDA+shift+control+pageUp`` | Increases the value of the current speech setting you're on in larger steps. e.g. when you're on a voice setting, it will jump forward every 20 voices; when you're on slider settings (rate, pitch, etc) it will jump forward the value up to 20% |
16611669
| Decrement current synth setting | NVDA+control+downArrow | NVDA+shift+control+downArrow | decreases the current speech setting you are on. E.g. decreases the rate, chooses the previous voice, decreases the volume |
1670+
| Decrement the current synth setting in a larger step | ``NVDA+control+pageDown`` | ``NVDA+shift+control+pageDown`` | Decreases the value of the current speech setting you're on in larger steps. e.g. when you're on a voice setting, it will jump backward every 20 voices; when you're on a slider setting, it will jump backward the value up to 20% |
16621671
%kc:endInclude
16631672

16641673
+++ Braille +++[BrailleSettings]

0 commit comments

Comments
 (0)