Skip to content

Commit

Permalink
Adjusted the timer interval settings in the settings panel, Simplifie…
Browse files Browse the repository at this point in the history
…d initialization of configuration.
  • Loading branch information
cary-rowen committed Sep 7, 2023
1 parent c9fbf5e commit 0be1305
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
19 changes: 5 additions & 14 deletions addon/globalPlugins/objWatcher/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@

addonHandler.initTranslation()

WATCHER_TIMER_INTERVAL = 100 # milliseconds

interval: int = WATCHER_TIMER_INTERVAL
confspec = {
"interval": "integer(default=100)"
}
config.conf.spec["objWatcher"] = confspec


class GlobalPlugin(globalPluginHandler.GlobalPlugin):
Expand All @@ -29,16 +30,6 @@ class GlobalPlugin(globalPluginHandler.GlobalPlugin):

def __init__(self):
super().__init__()
if "objWatcher" in config.conf:
if "interval" in config.conf["objWatcher"]:
global interval
interval = int(config.conf["objWatcher"]["interval"])
else:
config.conf["objWatcher"]["interval"] = WATCHER_TIMER_INTERVAL
else:
config.conf["objWatcher"] = dict()
config.conf["objWatcher"]["interval"] = WATCHER_TIMER_INTERVAL

self.watchingObj = None
self.lastAttributeText = None
# self.callLater will be assigned the value wx.CallLater(510,
Expand Down Expand Up @@ -88,7 +79,7 @@ def _toggleWatcher(self):
else:
self.watchingObj = api.getNavigatorObject()
if self.watchingObj:
self.timer.Start(interval)
self.timer.Start(config.conf["objWatcher"]["interval"])
cues.Start()
# Translators: Messages reported when watcher is started.
ui.message(_("Started watcher {}").format(
Expand Down
4 changes: 2 additions & 2 deletions addon/globalPlugins/objWatcher/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

addonHandler.initTranslation()


class ObjWatcherPanel(gui.settingsDialogs.SettingsPanel):
# Translators: This is the label for the ObjWatcher settings panel.
title = _("ObjWatcher")
Expand All @@ -23,10 +24,9 @@ def makeSettings(self, settingsSizer):
self.intervalEdit = settingsSizerHelper.addLabeledControl(
intervalLabelText,
nvdaControls.SelectOnFocusSpinCtrl,
min=10, max=500,
initial=int(config.conf["objWatcher"]["interval"])
)

def onSave(self):
config.conf["objWatcher"]["interval"] = self.intervalEdit.Value
global interval
interval = int(config.conf["objWatcher"]["interval"])

0 comments on commit 0be1305

Please sign in to comment.