From 03ef4710fdf8c1260d5a420f9592dcf7fc43e019 Mon Sep 17 00:00:00 2001 From: Chrys Date: Tue, 8 Jun 2021 18:59:04 +0200 Subject: [PATCH] handle exoort clipboard --- src/fenrirscreenreader/core/remoteManager.py | 32 +++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/fenrirscreenreader/core/remoteManager.py b/src/fenrirscreenreader/core/remoteManager.py index 612c43ee..54a741c1 100644 --- a/src/fenrirscreenreader/core/remoteManager.py +++ b/src/fenrirscreenreader/core/remoteManager.py @@ -28,7 +28,7 @@ command interrupt from fenrirscreenreader.core import debug from fenrirscreenreader.core.eventData import fenrirEventType -import time +import time, os class remoteManager(): def __init__(self): @@ -43,6 +43,8 @@ class remoteManager(): self.defineWindowConst = 'WINDOW ' self.resetWindowConst = 'RESETWINDOW' self.setClipboardConst = 'CLIPBOARD ' + self.exportConst = 'EXPORT' + self.readClipboard = 'READ' # setting controll self.settingConst = 'SETTING ' self.setSettingConst = 'SET ' @@ -148,6 +150,34 @@ class remoteManager(): self.env['runtime']['outputManager'].speakText(text) def interruptSpeech(self): self.env['runtime']['outputManager'].interruptOutput() + def handleClipboard(self, parameter): + upperParameter = parameter.upper() + # export clipboard + if upperParameter.startswith(self.setSettingConst): + self.exportClipboard(parameterText) + # read clipboard + elif upperParameter.startswith(self.readClipboard): + self.setClipboard(parameterText) + elif: + self.setClipboard(parameterText) + def exportClipboard(self): + clipboardFilePath = self.env['runtime']['settingsManager'].getSetting('general', 'clipboardExportPath') + clipboardFilePath = clipboardFilePath.replace('$user',self.env['general']['currUser']) + clipboardFilePath = clipboardFilePath.replace('$USER',self.env['general']['currUser']) + clipboardFilePath = clipboardFilePath.replace('$User',self.env['general']['currUser']) + clipboardFile = open(clipboardFilePath,'w') + try: + if self.env['runtime']['memoryManager'].isIndexListEmpty('clipboardHistory'): + self.env['runtime']['outputManager'].presentText(_('clipboard empty'), interrupt=True) + return + clipboard = self.env['runtime']['memoryManager'].getIndexListElement('clipboardHistory') + clipboardFile.write(clipboard) + clipboardFile.close() + os.chmod(clipboardFilePath, 0o666) + self.env['runtime']['outputManager'].presentText(_('clipboard exported to file'), interrupt=True) + except Exception as e: + self.env['runtime']['debug'].writeDebugOut('export_clipboard_to_file:run: Filepath:'+ clipboardFile +' trace:' + str(e),debug.debugLevel.ERROR) + def saveSettings(self, settingConfigPath = None): if not settingConfigPath: settingConfigPath = self.env['runtime']['settingsManager'].getSettingsFile()