Skip to content

Commit

Permalink
Version 8.1-dev: Suggestions by Timothy
Browse files Browse the repository at this point in the history
https://nvda-addons.groups.io/g/nvda-addons/topic/23674936#4250

* Extend temp dictionary to improve speed in announcement activation (restored from version 5).
* Fix bug in installtasks.
  • Loading branch information
nvdaes committed Aug 27, 2018
1 parent 7823a78 commit dd5e877
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 49 deletions.
59 changes: 13 additions & 46 deletions addon/globalPlugins/emoticons/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
confspec = {
"announcement": "integer(default=0)",
"cleanDicts": "boolean(default=False)",
"onlyNormalConfiguration": "boolean(default=False)",
}

config.conf.spec["emoticons"] = confspec
Expand All @@ -46,7 +45,6 @@
def activateAnnouncement():
speechDictHandler.dictionaries["temp"].extend(sD)


def deactivateAnnouncement():
for entry in sD:
if entry in speechDictHandler.dictionaries["temp"]:
Expand All @@ -57,7 +55,7 @@ class GlobalPlugin(globalPluginHandler.GlobalPlugin):
scriptCategory = SCRCAT_SPEECH

def loadDic(self):
if (config.conf["emoticons"]["onlyNormalConfiguration"] or self.profileName is None):
if self.profileName is None:
self.dicFile = ADDON_DIC_DEFAULT_FILE
else:
self.dicFile = os.path.join(ADDON_DICTS_PATH, "profiles", "%s.dic" % self.profileName)
Expand All @@ -69,19 +67,10 @@ def handleConfigProfileSwitch(self):
self.profileName = config.conf.profiles[-1].name
if self.profileName == self.oldProfileName:
return
if not config.conf["emoticons"]["onlyNormalConfiguration"]:
deactivateAnnouncement()
self.loadDic()
if config.conf["emoticons"]["announcement"]:
activateAnnouncement()
else:
if AddonSettingsPanel not in NVDASettingsDialog.categoryClasses and self.profileName is None:
NVDASettingsDialog.categoryClasses.append(AddonSettingsPanel)
else:
try:
NVDASettingsDialog.categoryClasses.remove(AddonSettingsPanel)
except:
pass
deactivateAnnouncement()
self.loadDic()
if config.conf["emoticons"]["announcement"]:
activateAnnouncement()
self.oldProfileName = self.profileName

def __init__(self):
Expand Down Expand Up @@ -115,14 +104,10 @@ def __init__(self):
# Translators: the tooltip text for a menu item.
_("Shows a dictionary dialog to customize emoticons"))
gui.mainFrame.sysTrayIcon.Bind(wx.EVT_MENU, self.onEmDicDialog, self.dicItem)
if not config.conf["emoticons"]["onlyNormalConfiguration"] or self.profileName is None:
NVDASettingsDialog.categoryClasses.append(AddonSettingsPanel)
NVDASettingsDialog.categoryClasses.append(AddonSettingsPanel)

# Config
if not config.conf["emoticons"]["onlyNormalConfiguration"]:
announcement = config.conf["emoticons"]["announcement"]
else:
announcement = config.conf.profiles[0]["emoticons"]["announcement"]
announcement = config.conf["emoticons"]["announcement"]
if announcement:
activateAnnouncement()
config.post_configProfileSwitch.register(self.handleConfigProfileSwitch)
Expand Down Expand Up @@ -166,8 +151,7 @@ def onSettingsPanel(self, evt):
gesture="kb:NVDA+e"
)
def script_toggleSpeakingEmoticons(self, gesture):
if (not globalVars.speechDictionaryProcessing
or (config.conf["emoticons"]["onlyNormalConfiguration"] and self.profileName is not None)):
if not globalVars.speechDictionaryProcessing:
return
if config.conf["emoticons"]["announcement"]:
config.conf["emoticons"]["announcement"] = 0
Expand All @@ -180,7 +164,6 @@ def script_toggleSpeakingEmoticons(self, gesture):
# Translators: message presented when the dictionary for emoticons is loaded.
ui.message(_("Emoticons on."))


@script(
# Translators: Message presented in input help mode.
description=_("Shows a dialog to select a smiley you want to paste."),
Expand All @@ -204,8 +187,6 @@ def script_emDicDialog(self, gesture):
category=SCRCAT_CONFIG
)
def script_settings(self, gesture):
if config.conf["emoticons"]["onlyNormalConfiguration"] and self.profileName is not None:
return
wx.CallAfter(self.onSettingsPanel, None)


Expand Down Expand Up @@ -405,19 +386,13 @@ def OnResetClick(self, evt):

def onOk(self,evt):
super(EmDicDialog, self).onOk(evt)
if not config.conf["emoticons"]["onlyNormalConfiguration"]:
announcement = config.conf["emoticons"]["announcement"]
else:
announcement = config.conf.profiles[0]["emoticons"]["announcement"]
announcement = config.conf["emoticons"]["announcement"]
if announcement:
activateAnnouncement()

def onCancel(self,evt):
super(EmDicDialog, self).onCancel(evt)
if not config.conf["emoticons"]["onlyNormalConfiguration"]:
announcement = config.conf["emoticons"]["announcement"]
else:
announcement = config.conf.profiles[0]["emoticons"]["announcement"]
announcement = config.conf["emoticons"]["announcement"]
if announcement:
activateAnnouncement()

Expand Down Expand Up @@ -445,20 +420,12 @@ def makeSettings(self, settingsSizer):
# Translators: The label for a setting in Emoticons panel.
self.removeCheckBox = sHelper.addItem(wx.CheckBox(self, label=_("&Remove not used dictionaries")))
self.removeCheckBox.Value = config.conf["emoticons"]["cleanDicts"]
# Translators: The label for a setting in Emoticons panel.
self.onlyNormalCheckBox = sHelper.addItem(wx.CheckBox(self, label=_("&Settings only in normal configuration (not recommended)")))
self.onlyNormalCheckBox.Value = config.conf["emoticons"]["onlyNormalConfiguration"]
profileName = config.conf.profiles[-1].name
self.onlyNormalCheckBox.Enabled = profileName is None

def postInit(self):
self.activateList.SetFocus()

def onSave(self):
announcement = config.conf["emoticons"]["announcement"]
config.conf["emoticons"]["announcement"] = self.activateList.GetSelection()
if config.conf["emoticons"]["announcement"]:
if config.conf["emoticons"]["announcement"] and not announcement:
activateAnnouncement()
else:
elif not config.conf["emoticons"]["announcement"] and announcement:
deactivateAnnouncement()
config.conf["emoticons"]["cleanDicts"] = self.removeCheckBox.Value
config.conf["emoticons"]["onlyNormalConfiguration"] = self.onlyNormalCheckBox.Value
2 changes: 1 addition & 1 deletion buildVars.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# Translators: Long description to be shown for this add-on on add-on information from add-ons manager
"addon_description" : _("Enables the announcement of emoticon names instead of the character Representation."),
# version
"addon_version" : "8.0-dev",
"addon_version" : "8.1-dev",
# Author(s)
"addon_author" : u"Chris Leo <[email protected]>, Noelia Ruiz Martínez <[email protected]>, Mesar Hameed <[email protected]>, Francisco Javier Estrada Martínez <[email protected]>",
# URL for the add-on documentation support
Expand Down
3 changes: 1 addition & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ These are the key commands available by default, you can edit those or add new k

## Changes for 8.0 ##

* Added the possibility of enabling settings changes just for normal configuration.
* Requires NVDA 2018.3.
* Compatible with NVDA 2018.3 (required).

## Changes for 7.0 ##

Expand Down

0 comments on commit dd5e877

Please sign in to comment.