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,
"fontFamily": "Arial",
"fontSize": 12,
"loadRecentFile": true,
"rememberTextBoxContent": true,
"loadRecentFile": false,
"maxResults": 20,
"profiles": {},
"recentFiles": [],
"textBoxContent": "",
"scanLength": 16,
"stripReadings": false,
"tags": [],

View File

@ -60,7 +60,9 @@ class MainWindowReader(QtGui.QMainWindow, gen.reader_ui.Ui_MainWindowReader):
self.updateVocabDefs()
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)
elif self.preferences['loadRecentFile']:
filenames = self.preferences.recentFiles()
@ -133,6 +135,8 @@ class MainWindowReader(QtGui.QMainWindow, gen.reader_ui.Ui_MainWindowReader):
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.preferences['windowState'] = str(self.saveState().toBase64())
self.preferences.save()