Skip to content

Commit 49dd4e8

Browse files
authored
Merge 5f02b2a into 52bf1ed
2 parents 52bf1ed + 5f02b2a commit 49dd4e8

7 files changed

Lines changed: 49 additions & 50 deletions

File tree

source/braille.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
import bdDetect
4040
import queueHandler
4141
import brailleViewer
42+
from autoSettingsUtils.driverSetting import BooleanDriverSetting, NumericDriverSetting
43+
4244

4345
roleLabels = {
4446
# Translators: Displayed in braille for an object which is a
@@ -2233,19 +2235,23 @@ def terminate():
22332235

22342236
class BrailleDisplayDriver(driverHandler.Driver):
22352237
"""Abstract base braille display driver.
2236-
Each braille display driver should be a separate Python module in the root brailleDisplayDrivers directory containing a BrailleDisplayDriver class which inherits from this base class.
2238+
Each braille display driver should be a separate Python module in the root brailleDisplayDrivers directory
2239+
containing a BrailleDisplayDriver class which inherits from this base class.
22372240
22382241
At a minimum, drivers must set L{name} and L{description} and override the L{check} method.
22392242
To display braille, L{numCells} and L{display} must be implemented.
22402243
2241-
Drivers should dispatch input such as presses of buttons, wheels or other controls using the L{inputCore} framework.
2242-
They should subclass L{BrailleDisplayGesture} and execute instances of those gestures using L{inputCore.manager.executeGesture}.
2244+
Drivers should dispatch input such as presses of buttons, wheels or other controls
2245+
using the L{inputCore} framework.
2246+
They should subclass L{BrailleDisplayGesture}
2247+
and execute instances of those gestures using L{inputCore.manager.executeGesture}.
22432248
These gestures can be mapped in L{gestureMap}.
22442249
A driver can also inherit L{baseObject.ScriptableObject} to provide display specific scripts.
22452250
22462251
@see: L{hwIo} for raw serial and HID I/O.
22472252
2248-
There are factory functions to create L{driverHandler.DriverSetting} instances for common display specific settings; e.g. L{DotFirmnessSetting}.
2253+
There are factory functions to create L{autoSettingsUtils.driverSetting.DriverSetting} instances
2254+
for common display specific settings; e.g. L{DotFirmnessSetting}.
22492255
"""
22502256
_configSection = "braille"
22512257
# Most braille display drivers don't have settings yet.
@@ -2463,7 +2469,7 @@ def _handleAck(self):
24632469
@classmethod
24642470
def DotFirmnessSetting(cls,defaultVal,minVal,maxVal,useConfig=False):
24652471
"""Factory function for creating dot firmness setting."""
2466-
return driverHandler.NumericDriverSetting(
2472+
return NumericDriverSetting(
24672473
"dotFirmness",
24682474
# Translators: Label for a setting in braille settings dialog.
24692475
_("Dot firm&ness"),
@@ -2476,7 +2482,7 @@ def DotFirmnessSetting(cls,defaultVal,minVal,maxVal,useConfig=False):
24762482
@classmethod
24772483
def BrailleInputSetting(cls, useConfig=True):
24782484
"""Factory function for creating braille input setting."""
2479-
return driverHandler.BooleanDriverSetting(
2485+
return BooleanDriverSetting(
24802486
"brailleInput",
24812487
# Translators: Label for a setting in braille settings dialog.
24822488
_("Braille inp&ut"),
@@ -2486,7 +2492,7 @@ def BrailleInputSetting(cls, useConfig=True):
24862492
@classmethod
24872493
def HIDInputSetting(cls, useConfig):
24882494
"""Factory function for creating HID input setting."""
2489-
return driverHandler.BooleanDriverSetting(
2495+
return BooleanDriverSetting(
24902496
"hidKeyboardInput",
24912497
# Translators: Label for a setting in braille settings dialog.
24922498
_("&HID keyboard input simulation"),

source/driverHandler.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,6 @@
77
"""Handler for driver functionality that is global to synthesizers and braille displays."""
88
from autoSettingsUtils.autoSettings import AutoSettings
99

10-
# F401: the following imports, while unused in this file, are provided for backwards compatibility.
11-
from autoSettingsUtils.driverSetting import ( # noqa: F401
12-
DriverSetting,
13-
BooleanDriverSetting,
14-
NumericDriverSetting,
15-
AutoPropertyObject,
16-
)
17-
from autoSettingsUtils.utils import ( # noqa: F401
18-
UnsupportedConfigParameterError,
19-
StringParameterInfo,
20-
)
21-
2210

2311
class Driver(AutoSettings):
2412
"""

source/synthDriverHandler.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,12 @@
2323
import extensionPoints
2424
import synthDrivers
2525
import driverHandler
26-
from driverHandler import StringParameterInfo # noqa: F401 # Backwards compatibility
26+
from autoSettingsUtils.driverSetting import BooleanDriverSetting, DriverSetting, NumericDriverSetting
27+
from autoSettingsUtils.utils import StringParameterInfo
2728
from abc import abstractmethod
2829

2930

30-
class LanguageInfo(driverHandler.StringParameterInfo):
31+
class LanguageInfo(StringParameterInfo):
3132
"""Holds information for a particular language"""
3233

3334
def __init__(self, id):
@@ -36,7 +37,7 @@ def __init__(self, id):
3637
super(LanguageInfo, self).__init__(id, displayName)
3738

3839

39-
class VoiceInfo(driverHandler.StringParameterInfo):
40+
class VoiceInfo(StringParameterInfo):
4041
"""Provides information about a single synthesizer voice.
4142
"""
4243

@@ -51,13 +52,18 @@ def __init__(self, id, displayName, language=None):
5152

5253

5354
class SynthDriver(driverHandler.Driver):
54-
"""Abstract base synthesizer driver.
55-
Each synthesizer driver should be a separate Python module in the root synthDrivers directory containing a SynthDriver class which inherits from this base class.
55+
"""
56+
Abstract base synthesizer driver.
57+
Each synthesizer driver should be a separate Python module in the root synthDrivers directory
58+
containing a SynthDriver class
59+
which inherits from this base class.
5660
5761
At a minimum, synth drivers must set L{name} and L{description} and override the L{check} method.
5862
The methods L{speak}, L{cancel} and L{pause} should be overridden as appropriate.
5963
L{supportedSettings} should be set as appropriate for the settings supported by the synthesiser.
60-
There are factory functions to create L{driverHandler.DriverSetting} instances for common settings; e.g. L{VoiceSetting} and L{RateSetting}.
64+
There are factory functions to create L{autoSettingsUtils.driverSetting.DriverSetting} instances
65+
for common settings;
66+
e.g. L{VoiceSetting} and L{RateSetting}.
6167
Each setting is retrieved and set using attributes named after the setting;
6268
e.g. the L{voice} attribute is used for the L{voice} setting.
6369
These will usually be properties.
@@ -103,7 +109,7 @@ class SynthDriver(driverHandler.Driver):
103109
@classmethod
104110
def LanguageSetting(cls):
105111
"""Factory function for creating a language setting."""
106-
return driverHandler.DriverSetting(
112+
return DriverSetting(
107113
"language",
108114
# Translators: Label for a setting in voice settings dialog.
109115
_("&Language"),
@@ -115,7 +121,7 @@ def LanguageSetting(cls):
115121
@classmethod
116122
def VoiceSetting(cls):
117123
"""Factory function for creating voice setting."""
118-
return driverHandler.DriverSetting(
124+
return DriverSetting(
119125
"voice",
120126
# Translators: Label for a setting in voice settings dialog.
121127
_("&Voice"),
@@ -127,7 +133,7 @@ def VoiceSetting(cls):
127133
@classmethod
128134
def VariantSetting(cls):
129135
"""Factory function for creating variant setting."""
130-
return driverHandler.DriverSetting(
136+
return DriverSetting(
131137
"variant",
132138
# Translators: Label for a setting in voice settings dialog.
133139
_("V&ariant"),
@@ -139,7 +145,7 @@ def VariantSetting(cls):
139145
@classmethod
140146
def RateSetting(cls, minStep=1):
141147
"""Factory function for creating rate setting."""
142-
return driverHandler.NumericDriverSetting(
148+
return NumericDriverSetting(
143149
"rate",
144150
# Translators: Label for a setting in voice settings dialog.
145151
_("&Rate"),
@@ -152,7 +158,7 @@ def RateSetting(cls, minStep=1):
152158
@classmethod
153159
def RateBoostSetting(cls):
154160
"""Factory function for creating rate boost setting."""
155-
return driverHandler.BooleanDriverSetting(
161+
return BooleanDriverSetting(
156162
"rateBoost",
157163
# Translators: This is the name of the rate boost voice toggle
158164
# which further increases the speaking rate when enabled.
@@ -165,7 +171,7 @@ def RateBoostSetting(cls):
165171
@classmethod
166172
def VolumeSetting(cls, minStep=1):
167173
"""Factory function for creating volume setting."""
168-
return driverHandler.NumericDriverSetting(
174+
return NumericDriverSetting(
169175
"volume",
170176
# Translators: Label for a setting in voice settings dialog.
171177
_("V&olume"),
@@ -179,7 +185,7 @@ def VolumeSetting(cls, minStep=1):
179185
@classmethod
180186
def PitchSetting(cls, minStep=1):
181187
"""Factory function for creating pitch setting."""
182-
return driverHandler.NumericDriverSetting(
188+
return NumericDriverSetting(
183189
"pitch",
184190
# Translators: Label for a setting in voice settings dialog.
185191
_("&Pitch"),
@@ -192,7 +198,7 @@ def PitchSetting(cls, minStep=1):
192198
@classmethod
193199
def InflectionSetting(cls, minStep=1):
194200
"""Factory function for creating inflection setting."""
195-
return driverHandler.NumericDriverSetting(
201+
return NumericDriverSetting(
196202
"inflection",
197203
# Translators: Label for a setting in voice settings dialog.
198204
_("&Inflection"),

source/synthDrivers/espeak.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from synthDriverHandler import SynthDriver, VoiceInfo, synthIndexReached, synthDoneSpeaking
1414
import speech
1515
from logHandler import log
16-
from driverHandler import BooleanDriverSetting
1716

1817
from speech.commands import (
1918
IndexCommand,

source/synthSettingsRing.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@
22
import config
33
import synthDriverHandler
44
import queueHandler
5-
import driverHandler
5+
from autoSettingsUtils.driverSetting import BooleanDriverSetting, NumericDriverSetting
6+
67

78
class SynthSetting(baseObject.AutoPropertyObject):
89
"""a numeric synth setting. Has functions to set, get, increase and decrease its value """
910
def __init__(self,synth,setting,min=0,max=100):
1011
self.synth = synth
1112
self.setting = setting
12-
self.min = setting.minVal if isinstance(setting,driverHandler.NumericDriverSetting) else min
13-
self.max = setting.maxVal if isinstance(setting,driverHandler.NumericDriverSetting) else max
14-
self.step = setting.normalStep if isinstance(setting,driverHandler.NumericDriverSetting) else 1
13+
self.min = setting.minVal if isinstance(setting, NumericDriverSetting) else min
14+
self.max = setting.maxVal if isinstance(setting, NumericDriverSetting) else max
15+
self.step = setting.normalStep if isinstance(setting, NumericDriverSetting) else 1
1516

1617
def increase(self):
1718
val = min(self.max,self.value+self.step)
@@ -139,9 +140,9 @@ def updateSupportedSettings(self,synth):
139140
if not s.availableInSettingsRing: continue
140141
if prevID == s.id: #restore the last setting
141142
self._current=len(list)
142-
if isinstance(s,driverHandler.NumericDriverSetting):
143+
if isinstance(s, NumericDriverSetting):
143144
cls=SynthSetting
144-
elif isinstance(s,driverHandler.BooleanDriverSetting):
145+
elif isinstance(s, BooleanDriverSetting):
145146
cls=BooleanSynthSetting
146147
else:
147148
cls=StringSynthSetting

source/visionEnhancementProviders/NVDAHighlighter.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# visionEnhancementProviders/NVDAHighlighter.py
21
# A part of NonVisual Desktop Access (NVDA)
32
# This file is covered by the GNU General Public License.
43
# See the file COPYING for more details.
@@ -8,6 +7,7 @@
87
from typing import Optional, Tuple
98

109
from autoSettingsUtils.autoSettings import SupportedSettingType
10+
from autoSettingsUtils.driverSetting import BooleanDriverSetting
1111
import vision
1212
from vision.constants import Context
1313
from vision.util import getContextRect
@@ -29,7 +29,6 @@
2929
import weakref
3030
from colors import RGB
3131
import core
32-
import driverHandler
3332

3433

3534
class HighlightStyle(
@@ -229,7 +228,7 @@ def getDisplayName(cls) -> str:
229228

230229
def _get_supportedSettings(self) -> SupportedSettingType:
231230
return [
232-
driverHandler.BooleanDriverSetting(
231+
BooleanDriverSetting(
233232
'highlight%s' % (context[0].upper() + context[1:]),
234233
_contextOptionLabelsWithAccelerators[context],
235234
defaultVal=True

source/visionEnhancementProviders/_exampleProvider_autoGui.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Copyright (C) 2019 NV Access Limited
55

66
from vision import providerBase
7-
import driverHandler
7+
from autoSettingsUtils.driverSetting import BooleanDriverSetting, DriverSetting, NumericDriverSetting
88
import gui
99
from autoSettingsUtils.utils import StringParameterInfo
1010
from autoSettingsUtils.autoSettings import SupportedSettingType
@@ -58,22 +58,22 @@ def getPreInitSettings(cls) -> SupportedSettingType:
5858
This is a class method because it does not rely on any instance state in this class.
5959
"""
6060
return [
61-
driverHandler.BooleanDriverSetting(
61+
BooleanDriverSetting(
6262
"shouldDoX", # value stored in matching property name on class
6363
"Should Do X",
6464
defaultVal=True
6565
),
66-
driverHandler.BooleanDriverSetting(
66+
BooleanDriverSetting(
6767
"shouldDoY", # value stored in matching property name on class
6868
"Should Do Y",
6969
defaultVal=False
7070
),
71-
driverHandler.NumericDriverSetting(
71+
NumericDriverSetting(
7272
"amountOfZ", # value stored in matching property name on class
7373
"Amount of Z",
7474
defaultVal=11
7575
),
76-
driverHandler.DriverSetting(
76+
DriverSetting(
7777
# options for this come from a property with name generated by
7878
# f"available{settingID.capitalize()}s"
7979
# Note:
@@ -100,15 +100,15 @@ def _getAvailableRuntimeSettings(self) -> SupportedSettingType:
100100
settings = []
101101
if self._hasFeature("runtimeOnlySetting_externalValueLoad"):
102102
settings.extend([
103-
driverHandler.NumericDriverSetting(
103+
NumericDriverSetting(
104104
"runtimeOnlySetting_externalValueLoad", # value stored in matching property name on class
105105
"Runtime Only amount, external value load",
106106
# no GUI default
107107
),
108108
])
109109
if self._hasFeature("runtimeOnlySetting_localDefault"):
110110
settings.extend([
111-
driverHandler.NumericDriverSetting(
111+
NumericDriverSetting(
112112
"runtimeOnlySetting_localDefault", # value stored in matching property name on class
113113
"Runtime Only amount, local default",
114114
defaultVal=50,

0 commit comments

Comments
 (0)