autoSettingsUtils package

Submodules

autoSettingsUtils.autoSettings module

autoSettings for add-ons

class autoSettingsUtils.autoSettings.AutoSettings(*args, **kwargs)

Bases: AutoPropertyObject

An AutoSettings instance is used to simplify the load/save of user config for NVDA extensions (Synth drivers, braille drivers, vision providers) and make it possible to automatically provide a standard GUI for these settings. Derived classes must implement: - getId - getDisplayName - _get_supportedSettings

Perform any initialisation @note: registers with the config save action extension point

_registerConfigSaveAction()

Overrideable pre_configSave registration

_unregisterConfigSaveAction()

Overrideable pre_configSave de-registration

abstract classmethod getId() str

@return: Application friendly name, should be globally unique, however since this is used in the config file human readable is also beneficial.

abstract classmethod getDisplayName() str

@return: The translated name for this collection of settings. This is for use in the GUI to represent the group of these settings.

abstract classmethod _getConfigSection() str

@return: The section of the config that these settings belong in.

classmethod _initSpecificSettings(clsOrInst: Any, settings: Iterable[DriverSetting]) None
initSettings()

Initializes the configuration for this AutoSettings instance. This method is called when initializing the AutoSettings instance.

supportedSettings: Iterable[DriverSetting]

Typing for auto property L{_get_supportedSettings}

_abstract_supportedSettings = True
_get_supportedSettings() Iterable[DriverSetting]

The settings supported by the AutoSettings instance. Abstract.

isSupported(settingID) bool

Checks whether given setting is supported by the AutoSettings instance.

classmethod _getConfigSpecForSettings(settings: Iterable[DriverSetting]) Dict
getConfigSpec()
classmethod _saveSpecificSettings(clsOrInst: Any, settings: Iterable[DriverSetting]) None

Save values for settings to config. The values from the attributes of clsOrInst that match the id of each setting are saved to config. @param clsOrInst: Destination for the values. @param settings: The settings to load.

saveSettings()

Saves the current settings for the AutoSettings instance to the configuration. This method is also executed when the AutoSettings instance is loaded for the first time, in order to populate the configuration with the initial settings..

classmethod _loadSpecificSettings(clsOrInst: Any, settings: Iterable[DriverSetting], onlyChanged: bool = False) None

Load settings from config, set them on clsOrInst. @param clsOrInst: Destination for the values. @param settings: The settings to load. @param onlyChanged: When True, only settings that no longer match the config are set. @note: attributes are set on clsOrInst using setattr.

The id of each setting in settings is used as the attribute name.

loadSettings(onlyChanged: bool = False)

Loads settings for this AutoSettings instance from the configuration. This method assumes that the instance has attributes o/properties corresponding with the name of every setting in L{supportedSettings}. @param onlyChanged: When loading settings, only apply those for which

the value in the configuration differs from the current value.

classmethod _paramToPercent(current: int, min: int, max: int) int

Convert a raw parameter value to a percentage given the current, minimum and maximum raw values. @param current: The current value. @param min: The minimum value. @param max: The maximum value.

classmethod _percentToParam(percent: int, min: int, max: int) int

Convert a percentage to a raw parameter value given the current percentage and the minimum and maximum raw parameter values. @param percent: The current percentage. @param min: The minimum raw parameter value. @param max: The maximum raw parameter value.

_abc_impl = <_abc._abc_data object>

autoSettingsUtils.driverSetting module

Classes used to represent settings for Drivers and other AutoSettings instances

Naming of these classes is historical, kept for backwards compatibility purposes.

class autoSettingsUtils.driverSetting.DriverSetting(*args, **kwargs)

Bases: AutoPropertyObject

As a base class, represents a setting to be shown in GUI and saved to config.

GUI representation is a string selection GUI control, a wx.Choice control.

Used for synthesizer or braille display setting such as voice, variant or dot firmness as well as for settings in Vision Providers

@param id: internal identifier of the setting @param displayNameWithAccelerator: the localized string shown in voice or braille settings dialog @param availableInSettingsRing: Will this option be available in a settings ring? @param defaultVal: Specifies the default value for a driver setting. @param displayName: the localized string used in synth settings ring or

None to use displayNameWithAccelerator

@param useConfig: Whether the value of this option is loaded from and saved to NVDA’s configuration.

Set this to C{False} if the driver deals with loading and saving.

configSpec: str

Type information for _get_configSpec

_get_configSpec()

Returns the configuration specification of this particular setting for config file validator. @rtype: str

id: str
displayNameWithAccelerator: str
displayName: str
availableInSettingsRing: bool
defaultVal: object
useConfig: bool
_abc_impl = <_abc._abc_data object>
class autoSettingsUtils.driverSetting.NumericDriverSetting(*args, **kwargs)

Bases: DriverSetting

Represents a numeric driver setting such as rate, volume, pitch or dot firmness. GUI representation is a slider control.

@param defaultVal: Specifies the default value for a numeric driver setting. @param minVal: Specifies the minimum valid value for a numeric driver setting. @param maxVal: Specifies the maximum valid value for a numeric driver setting. @param minStep: Specifies the minimum step between valid values for each numeric setting.

For example, if L{minStep} is set to 10, setting values can only be multiples of 10; 10, 20, 30, etc.

@param normalStep: Specifies the step between values that a user will normally prefer.

This is used in the settings ring.

@param largeStep: Specifies the step between values if a large adjustment is desired.

This is used for pageUp/pageDown on sliders in the Voice Settings dialog.

@note: If necessary, the step values will be normalised so that L{minStep} <= L{normalStep} <= L{largeStep}.

defaultVal: int
_get_configSpec()

Returns the configuration specification of this particular setting for config file validator. @rtype: str

_abc_impl = <_abc._abc_data object>
configSpec: str

Type information for _get_configSpec

class autoSettingsUtils.driverSetting.BooleanDriverSetting(*args, **kwargs)

Bases: DriverSetting

Represents a boolean driver setting such as rate boost or automatic time sync. GUI representation is a wx.Checkbox

@param defaultVal: Specifies the default value for a boolean driver setting.

_abc_impl = <_abc._abc_data object>
configSpec: str

Type information for _get_configSpec

defaultVal: bool
_get_configSpec()

Returns the configuration specification of this particular setting for config file validator. @rtype: str

autoSettingsUtils.utils module

Utility methods for Driver and AutoSettings instances

autoSettingsUtils.utils.paramToPercent(current: int, min: int, max: int) int

Convert a raw parameter value to a percentage given the current, minimum and maximum raw values. @param current: The current value. @type current: int @param min: The minimum value. @type current: int @param max: The maximum value. @type max: int

autoSettingsUtils.utils.percentToParam(percent: int, min: int, max: int) int

Convert a percentage to a raw parameter value given the current percentage and the minimum and maximum raw parameter values. @param percent: The current percentage. @type percent: int @param min: The minimum raw parameter value. @type min: int @param max: The maximum raw parameter value. @type max: int

exception autoSettingsUtils.utils.UnsupportedConfigParameterError

Bases: NotImplementedError

Raised when changing or retrieving a driver setting that is unsupported for the connected device.

class autoSettingsUtils.utils.StringParameterInfo(id: str, displayName: str)

Bases: object

Used to represent a value of a DriverSetting instance.

@param id: The unique identifier of the value. @param displayName: The name of the value, visible to the user.

id: str
displayName: str