1

Basics for persistent text box functionality

Text is saved in the JSON upon closing and loaded on startup if the
flag “rememberTextBoxContent” is true (default). Text seems to be
escaped automatically for export into the JSON. Tested with quote
characters only.

Missing the UI for controlling this feature, as discussed.


Former-commit-id: 77c46388edc0a25e36ae8d2538448f1c1e61c069
This commit is contained in:
felixvd 2015-02-12 13:14:31 +09:00
parent 7179dd6436
commit 5226adca67
2 changed files with 8 additions and 2 deletions

View File

@ -4,10 +4,12 @@
"fgColor": 4278190080, "fgColor": 4278190080,
"fontFamily": "Arial", "fontFamily": "Arial",
"fontSize": 12, "fontSize": 12,
"loadRecentFile": true, "rememberTextBoxContent": true,
"loadRecentFile": false,
"maxResults": 20, "maxResults": 20,
"profiles": {}, "profiles": {},
"recentFiles": [], "recentFiles": [],
"textBoxContent": "",
"scanLength": 16, "scanLength": 16,
"stripReadings": false, "stripReadings": false,
"tags": [], "tags": [],

View File

@ -60,7 +60,9 @@ class MainWindowReader(QtGui.QMainWindow, gen.reader_ui.Ui_MainWindowReader):
self.updateVocabDefs() self.updateVocabDefs()
self.updateKanjiDefs() self.updateKanjiDefs()
if filename is not None: if self.preferences['rememberTextBoxContent']:
self.textContent.setPlainText(self.preferences['textBoxContent'])
elif filename is not None:
self.openFile(filename) self.openFile(filename)
elif self.preferences['loadRecentFile']: elif self.preferences['loadRecentFile']:
filenames = self.preferences.recentFiles() filenames = self.preferences.recentFiles()
@ -133,6 +135,8 @@ class MainWindowReader(QtGui.QMainWindow, gen.reader_ui.Ui_MainWindowReader):
def closeEvent(self, event): def closeEvent(self, event):
if self.preferences['rememberTextBoxContent']: # Before closeFile() because that clears the window
self.preferences['textBoxContent'] = unicode(self.textContent.toPlainText())
self.closeFile() self.closeFile()
self.preferences['windowState'] = str(self.saveState().toBase64()) self.preferences['windowState'] = str(self.saveState().toBase64())
self.preferences.save() self.preferences.save()