From a97c31577a6439de593f7fe46b60e6744555ddc6 Mon Sep 17 00:00:00 2001 From: chrys Date: Sat, 8 Sep 2018 22:23:27 +0200 Subject: [PATCH] add setting save --- src/fenrirscreenreader/core/remoteManager.py | 15 +++++++++++++++ src/fenrirscreenreader/core/settingsManager.py | 14 ++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/fenrirscreenreader/core/remoteManager.py b/src/fenrirscreenreader/core/remoteManager.py index 9be43ea0..0d9c8b47 100644 --- a/src/fenrirscreenreader/core/remoteManager.py +++ b/src/fenrirscreenreader/core/remoteManager.py @@ -43,6 +43,7 @@ class remoteManager(): # setting controll self.settingConst = 'SETTING ' self.setSettingConst = 'SET ' + self.saveSettingConst = 'SAVE ' self.resetSettingConst = 'RESET' def initialize(self, environment): self.env = environment @@ -132,6 +133,10 @@ class remoteManager(): if upperSettingsText.startswith(self.setSettingConst): parameterText = settingsText[len(self.setSettingConst):] self.setSettings(parameterText) + # save setting + if upperSettingsText.startswith(self.saveSettingConst): + parameterText = settingsText[len(self.saveSettingConst):] + self.saveSettings(parameterText) # reset setting if upperSettingsText.startswith(self.resetSettingConst): self.resetSettings() @@ -173,9 +178,19 @@ class remoteManager(): def resetWindow(self): self.env['runtime']['cursorManager'].clearWindowForApplication() def say(self, text): + if not text: + return + if text == '': + return self.env['runtime']['outputManager'].speakText(text) def interruptSpeech(self): self.env['runtime']['outputManager'].interruptOutput() + def saveSettings(self, settingConfigPath): + if not settingConfigPath: + return + if settingConfigPath == '': + return + self.env['runtime']['settingsManager'].saveSettings(settingConfigPath) def resetSettings(self): self.env['runtime']['settingsManager'].resetSettingArgDict() def setSettings(self, settingsArgs): diff --git a/src/fenrirscreenreader/core/settingsManager.py b/src/fenrirscreenreader/core/settingsManager.py index 8df06a54..bf572eed 100644 --- a/src/fenrirscreenreader/core/settingsManager.py +++ b/src/fenrirscreenreader/core/settingsManager.py @@ -78,7 +78,21 @@ class settingsManager(): self.env['settings'] = ConfigParser() self.env['settings'].read(settingConfigPath) return True + def saveSettings(self, settingConfigPath): + # set opt dict here + # save file + try: + #print('file: ',settingConfigPath) + for section, settings in self.settingArgDict.items(): + for setting, value in settings.items(): + #print(section, setting, value) + self.env['settings'].set(section, setting, value) + #print('full',self.env['settings']) + configFile = open('/tmp/settings.conf', 'w') + self.env['settings'].write(configFile) + except Exception as e: + print(e) def setSetting(self, section, setting, value): self.setOptionArgDict(section, setting, value) #self.env['settings'].set(section, setting, value)