handle exoort clipboard

This commit is contained in:
Chrys 2021-06-08 18:59:04 +02:00
parent 2f189da4d0
commit 03ef4710fd

View File

@ -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()