Skip to content

Commit 77bc828

Browse files
committed
internal code changes.
updated way of using timers, now core.callLater is used.
1 parent b55f6a7 commit 77bc828

File tree

4 files changed

+34
-21
lines changed

4 files changed

+34
-21
lines changed

.github/workflows/upload-on-tag.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
with open("buildVars.py", 'r+', encoding='utf-8') as f:
2727
text = f.read()
2828
version = "${{ github.ref }}".split("/")[-1]
29-
text = re.sub("\"addon_version\" : ,", "\"addon_version\" : \"%s\",", text) % version
29+
text = re.sub('"addon_version" *:.*,', '"addon_version" : "%s",' % version, text)
3030
f.seek(0)
3131
f.write(text)
3232
f.truncate()

addon/globalPlugins/enhancedPhoneticReading.py

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Released under GPL 2.0
66
#globalPlugins/enhancedPhoneticReading.py
77

8-
import characterProcessing, config, controlTypes, globalPluginHandler, gui, addonHandler, six, speech, textInfos, threading, wx
8+
import characterProcessing, config, controlTypes, core, globalPluginHandler, gui, addonHandler, six, speech, textInfos, threading, wx
99
from globalCommands import SCRCAT_SPEECH
1010

1111
addonHandler.initTranslation()
@@ -43,9 +43,20 @@ def cancelSpeech():
4343
origCancelSpeech()
4444
cancelTimer()
4545

46+
class _FakeTextInfo():
47+
"""
48+
this class is used to preserve the information of the old object that contain the text. Its useful to use with delayed descriptions.
49+
"""
50+
51+
def __init__(self, origTextInfo: textInfos.TextInfo):
52+
self.text = origTextInfo.text
53+
self.fields = origTextInfo.getTextWithFields({})
54+
55+
def getTextWithFields(self, _ = None):
56+
return self.fields
57+
4658
#saves the original speakTextInfo function
4759
origSpeakTextInfo = speech.speakTextInfo
48-
4960
instantDescriptions = False
5061
# alternate function to speakTextInfo. We determine here if a delayed description is needed base on textInfos.UNIT_CHARACTER.
5162
def speakTextInfo(*args, **kwargs):
@@ -54,18 +65,22 @@ def speakTextInfo(*args, **kwargs):
5465
if instantDescriptions and kwargs.get('unit') == textInfos.UNIT_CHARACTER: return speech.spellTextInfo(info, True)
5566
tmp = origSpeakTextInfo(*args, **kwargs)
5667
if config.conf['enhancedPhoneticReading']['delayedDescriptions'] and kwargs.get('unit') == textInfos.UNIT_CHARACTER:
57-
characterDescriptionTimer = wx.CallLater(config.conf['enhancedPhoneticReading']['delay'], speakDescription, info.text, info.getTextWithFields({}))
68+
characterDescriptionTimer = core.callLater(config.conf['enhancedPhoneticReading']['delay'], speakDelayedDescription, _FakeTextInfo(info))
5869
return tmp
5970

60-
def speakDescription(text, fields):
61-
curLanguage=speech.getCurrentLanguage()
62-
if not config.conf['speech']['autoLanguageSwitching'] and characterProcessing.getCharacterDescription(curLanguage, text.lower()):
63-
return speakSpelling(text, curLanguage, useCharacterDescriptions=True)
64-
for field in fields:
65-
if isinstance(field, six.string_types) and characterProcessing.getCharacterDescription(curLanguage, field.lower()):
66-
speakSpelling(field,curLanguage,useCharacterDescriptions=True)
67-
elif isinstance(field,textInfos.FieldCommand) and field.command=="formatChange":
68-
curLanguage= field.field.get('language', curLanguage) or curLanguage
71+
def speakDelayedDescription(info: _FakeTextInfo):
72+
"""
73+
this function is used to announce the delayed descriptions, we can't call spellTextInfo directly because we need to check if the description is available first.
74+
"""
75+
if info.text.strip() == "": return
76+
curLang = speech.getCurrentLanguage()
77+
if config.conf['speech']['autoLanguageSwitching']:
78+
for k in info.fields:
79+
if isinstance(k, textInfos.FieldCommand) and k.command == "formatChange":
80+
curLang = k.field.get('language', curLang)
81+
_, description = speech.getCharDescListFromText(info.text, locale=curLang)[0]
82+
if description:
83+
speech.spellTextInfo(info, useCharacterDescriptions=True)
6984

7085
class EnhancedPhoneticReadingPanel(gui.SettingsPanel):
7186
# Translators: This is the label for the Enhanced phonetic reading settings category in NVDA Settings screen.

buildVars.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131
# Minimum NVDA version supported (e.g. "2018.3.0")
3232
"addon_minimumNVDAVersion" : "2018.3.0",
3333
# Last NVDA version supported/tested (e.g. "2018.4.0", ideally more recent than minimum version)
34-
"addon_lastTestedNVDAVersion" : "2021.3.1",
34+
"addon_lastTestedNVDAVersion" : "2022.1.1",
3535
# Add-on update channel (default is stable or None)
36-
"addon_updateChannel": "dev",
36+
"addon_updateChannel": "stable",
3737
}
3838

3939
from os import path

changelog.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
## Changes for 1.1-dev ##
2-
updated the way of using timers, now wx.CallLater is used instead. This should fix an incompatibility with bluetoothAudio add-on.
3-
updated now delay config is saved in ms.
1+
## Changes for 1.1.2-dev ##
42

5-
## Changes for 1.0 ##
6-
Updated manifest to add compatibility with NVDA 2021.3.1.
7-
Updated readme files.
3+
* Updated manifest to add compatibility with NVDA 2022.1.1.
4+
* now core.callLater is used instead of python threads. This solves issues with another add-ons like bluetooth-audio.
5+
* internal code changes.

0 commit comments

Comments
 (0)