5
5
# Released under GPL 2
6
6
#globalPlugins/synthRingSettingsSelector.py
7
7
8
- import config , globalPluginHandler , globalVars , gui , synthDriverHandler , wx , addonHandler
8
+ import buildVersion , config , globalPluginHandler , globalVars , gui , synthDriverHandler , wx , addonHandler
9
9
10
10
addonHandler .initTranslation ()
11
11
12
+ SETTINGS_ID = 'id'
13
+ SETTINGS_AVAILABLE = 'availableInSettingsRing'
14
+
12
15
confspec = {
13
16
"availableSettings" : "string_list(default=list('language', 'voice', 'variant', 'rate', 'rateBoost', 'volume', 'pitch', 'inflection'))"
14
17
}
@@ -27,10 +30,11 @@ def setSynth(name,isFallback=False):
27
30
return r
28
31
29
32
def setAvailableSettings ():
30
- if synthDriverHandler ._curSynth :
33
+ if synthDriverHandler ._curSynth and globalVars . settingsRing :
31
34
for s in synthDriverHandler ._curSynth .supportedSettings :
32
- s .availableInSettingsRing = True if s .id in config .conf ['synthRingSettingsSelector' ]['availableSettings' ] else False
33
- if globalVars .settingsRing : globalVars .settingsRing .updateSupportedSettings (synthDriverHandler ._curSynth )
35
+ setattr (s , SETTINGS_AVAILABLE , True if getattr (s , SETTINGS_ID ) in config .conf ['synthRingSettingsSelector' ]['availableSettings' ] else False )
36
+ globalVars .settingsRing .updateSupportedSettings (synthDriverHandler ._curSynth )
37
+
34
38
35
39
class SynthRingSettingsSelectorSettingsPanel (gui .SettingsPanel ):
36
40
# Translators: This is the label for the Synth ring settings selector settings category in NVDA Settings screen.
@@ -46,8 +50,8 @@ def makeSettings(self, settingsSizer):
46
50
sHelper .addItem (settingsGroup )
47
51
self .settingsCheckbox = {}
48
52
for k in synthDriverHandler ._curSynth .supportedSettings :
49
- self .settingsCheckbox [k . id ] = settingsGroup .addItem (wx .CheckBox (self , label = k .displayNameWithAccelerator ))
50
- self .settingsCheckbox [k . id ].SetValue (k . id in self .curSettings )
53
+ self .settingsCheckbox [getattr ( k , SETTINGS_ID ) ] = settingsGroup .addItem (wx .CheckBox (self , label = k .displayNameWithAccelerator ))
54
+ self .settingsCheckbox [getattr ( k , SETTINGS_ID ) ].SetValue (getattr ( k , SETTINGS_ID ) in self .curSettings )
51
55
52
56
def onSave (self ):
53
57
newSettings = []
@@ -59,9 +63,14 @@ def onSave(self):
59
63
config .post_configProfileSwitch .notify ()
60
64
61
65
66
+
62
67
class GlobalPlugin (globalPluginHandler .GlobalPlugin ):
63
68
def __init__ (self ):
69
+ global SETTINGS_AVAILABLE , SETTINGS_ID
64
70
super (globalPluginHandler .GlobalPlugin , self ).__init__ ()
71
+ if int (buildVersion .formatBuildVersionString ()[:6 ].replace ("." , "" )) < 20192 :
72
+ SETTINGS_ID = 'name'
73
+ SETTINGS_AVAILABLE = 'availableInSynthSettingsRing'
65
74
self .handleConfigProfileSwitch ()
66
75
config .post_configProfileSwitch .register (self .handleConfigProfileSwitch )
67
76
synthDriverHandler .setSynth = setSynth
@@ -77,4 +86,4 @@ def terminate(self):
77
86
synthDriverHandler .setSynth = origSetSynth
78
87
gui .settingsDialogs .setSynth = origSetSynth
79
88
gui .settingsDialogs .NVDASettingsDialog .categoryClasses .remove (SynthRingSettingsSelectorSettingsPanel )
80
- config .post_configProfileSwitch .unregister (self .handleConfigProfileSwitch )
89
+ config .post_configProfileSwitch .unregister (self .handleConfigProfileSwitch )
0 commit comments