From 633b90f1e814586839413ae0c71cfcbe4f8cb915 Mon Sep 17 00:00:00 2001 From: chrys Date: Tue, 12 Feb 2019 23:44:57 +0100 Subject: [PATCH] handle binding backup more clean --- src/fenrirscreenreader/core/helpManager.py | 5 +---- src/fenrirscreenreader/core/settingsManager.py | 6 +++++- src/fenrirscreenreader/core/vmenuManager.py | 5 +---- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/fenrirscreenreader/core/helpManager.py b/src/fenrirscreenreader/core/helpManager.py index 03c7b2ce..61fb02a5 100755 --- a/src/fenrirscreenreader/core/helpManager.py +++ b/src/fenrirscreenreader/core/helpManager.py @@ -11,7 +11,6 @@ class helpManager(): def __init__(self): self.helpDict = {} self.tutorialListIndex = None - self.bindingsBackup = None def initialize(self, environment): self.env = environment def shutdown(self): @@ -23,7 +22,6 @@ class helpManager(): return self.env['general']['tutorialMode'] = newTutorialMode if newTutorialMode: - self.bindingsBackup = self.env['bindings'].copy() self.createHelpDict() self.env['bindings'][str([1, ['KEY_ESC']])] = 'TOGGLE_TUTORIAL_MODE' self.env['bindings'][str([1, ['KEY_UP']])] = 'PREV_HELP' @@ -31,8 +29,7 @@ class helpManager(): self.env['bindings'][str([1, ['KEY_SPACE']])] = 'CURR_HELP' else: try: - self.env['bindings'] = self.bindingsBackup.copy() - self.bindingsBackup = None + self.env['bindings'] = self.env['runtime']['settingsManager'].getBindingBackup() except: pass def isTutorialMode(self): diff --git a/src/fenrirscreenreader/core/settingsManager.py b/src/fenrirscreenreader/core/settingsManager.py index b094c546..a46618fc 100644 --- a/src/fenrirscreenreader/core/settingsManager.py +++ b/src/fenrirscreenreader/core/settingsManager.py @@ -39,11 +39,13 @@ class settingsManager(): def __init__(self): self.settings = settingsData self.settingArgDict = {} + self.bindingsBackup = None def initialize(self, environment): self.env = environment def shutdown(self): pass - + def getBindingBackup(self): + return self.bindingsBackup.copy() def loadSoundIcons(self, soundIconPath): siConfig = open(soundIconPath + '/soundicons.conf',"r") while(True): @@ -392,4 +394,6 @@ class settingsManager(): environment['runtime']['debug'].writeDebugOut(str(environment['settings']._sections) , debug.debugLevel.INFO, onAnyLevel=True) environment['runtime']['debug'].writeDebugOut('\/-------self.settingArgDict-------\/',debug.debugLevel.INFO, onAnyLevel=True) environment['runtime']['debug'].writeDebugOut(str( self.settingArgDict) ,debug.debugLevel.INFO, onAnyLevel=True) + self.bindingsBackup = environment['bindings'].copy() + return environment diff --git a/src/fenrirscreenreader/core/vmenuManager.py b/src/fenrirscreenreader/core/vmenuManager.py index ee85cc2c..254cb1ac 100755 --- a/src/fenrirscreenreader/core/vmenuManager.py +++ b/src/fenrirscreenreader/core/vmenuManager.py @@ -21,7 +21,6 @@ class vmenuManager(): self.useTimeout = True self.searchText = '' self.lastSearchTime = time.time() - self.bindingsBackup = None def initialize(self, environment): self.env = environment # use default path @@ -104,7 +103,6 @@ class vmenuManager(): except Exception as e: print(e) try: - self.bindingsBackup = self.env['bindings'].copy() # navigation self.env['bindings'][str([1, ['KEY_ESC']])] = 'TOGGLE_VMENU_MODE' self.env['bindings'][str([1, ['KEY_UP']])] = 'PREV_VMENU_ENTRY' @@ -145,8 +143,7 @@ class vmenuManager(): else: try: self.currIndex = None - self.env['bindings'] = self.bindingsBackup.copy() - self.bindingsBackup = None + self.env['bindings'] = self.env['runtime']['settingsManager'].getBindingBackup() except: pass def createMenuTree(self):