Fixes
Former-commit-id: c119b1999e6972f50302230e8beb79898a236aba
This commit is contained in:
parent
26012a5679
commit
3c484fcbbd
@ -412,8 +412,8 @@ class MainWindowReader(QtGui.QMainWindow, gen.reader_ui.Ui_MainWindowReader):
|
|||||||
self.listDefinitions.setCurrentRow(self.listDefinitions.count() - 1)
|
self.listDefinitions.setCurrentRow(self.listDefinitions.count() - 1)
|
||||||
self.setStatus(u'Added fact {0}; {1} new fact(s) total'.format(markup['summary'], len(self.facts)))
|
self.setStatus(u'Added fact {0}; {1} new fact(s) total'.format(markup['summary'], len(self.facts)))
|
||||||
|
|
||||||
self.updateVocabDefs(False)
|
self.updateVocabDefs(scroll=True)
|
||||||
self.updateKanjiDefs(False)
|
self.updateKanjiDefs(scroll=True)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
@ -535,34 +535,36 @@ class MainWindowReader(QtGui.QMainWindow, gen.reader_ui.Ui_MainWindowReader):
|
|||||||
self.preferences.updateRecentFile(self.state.filename, self.state.scanPosition)
|
self.preferences.updateRecentFile(self.state.filename, self.state.scanPosition)
|
||||||
|
|
||||||
|
|
||||||
def updateVocabDefs(self, scroll=True, trim=True):
|
def updateDefs(self, defs, builder, control, **options):
|
||||||
vocabDefs = self.state.vocabDefs
|
if options.get('trim', True):
|
||||||
if trim:
|
defs = defs[:self.preferences['maxResults']]
|
||||||
vocabDefs = vocabDefs[:self.preferences['maxResults']]
|
|
||||||
|
|
||||||
html = reader_util.buildVocabDefs(vocabDefs, self.ankiIsFactValid)
|
html = builder(defs, self.ankiIsFactValid)
|
||||||
|
|
||||||
scrollbar = self.textVocabDefs.verticalScrollBar()
|
scrollbar = control.verticalScrollBar()
|
||||||
position = scrollbar.sliderPosition()
|
position = scrollbar.sliderPosition()
|
||||||
self.textVocabDefs.setHtml(html)
|
control.setHtml(html)
|
||||||
|
|
||||||
if not scroll:
|
if options.get('scroll', False):
|
||||||
scrollbar.setSliderPosition(position)
|
scrollbar.setSliderPosition(position)
|
||||||
|
|
||||||
|
|
||||||
def updateKanjiDefs(self, scroll=True, trim=True):
|
def updateVocabDefs(self, **options):
|
||||||
kanjiDefs = self.state.kanjiDefs
|
self.updateDefs(
|
||||||
if trim:
|
self.state.vocabDefs,
|
||||||
kanjiDefs = kanjiDefs[:self.preferences['maxResults']]
|
reader_util.buildVocabDefs,
|
||||||
|
self.textVocabDefs,
|
||||||
|
**options
|
||||||
|
)
|
||||||
|
|
||||||
html = reader_util.buildKanjiDefs(kanjiDefs, self.ankiIsFactValid)
|
|
||||||
|
|
||||||
scrollbar = self.textKanjiDefs.verticalScrollBar()
|
def updateKanjiDefs(self, **options):
|
||||||
position = scrollbar.sliderPosition()
|
self.updateDefs(
|
||||||
self.textKanjiDefs.setHtml(html)
|
self.state.kanjiDefs,
|
||||||
|
reader_util.buildKanjiDefs,
|
||||||
if not scroll:
|
self.textKanjiDefs,
|
||||||
scrollbar.setSliderPosition(position)
|
**options
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def importWordList(self, words):
|
def importWordList(self, words):
|
||||||
@ -576,8 +578,8 @@ class MainWindowReader(QtGui.QMainWindow, gen.reader_ui.Ui_MainWindowReader):
|
|||||||
if self.dockKanji.isVisible():
|
if self.dockKanji.isVisible():
|
||||||
self.state.kanjiDefs += self.language.findCharacters(word)
|
self.state.kanjiDefs += self.language.findCharacters(word)
|
||||||
|
|
||||||
self.updateVocabDefs(True, False)
|
self.updateVocabDefs(trim=False, scroll=True)
|
||||||
self.updateKanjiDefs(True, False)
|
self.updateKanjiDefs(trim=False, scroll=True)
|
||||||
|
|
||||||
|
|
||||||
def setStatus(self, status):
|
def setStatus(self, status):
|
||||||
|
Loading…
Reference in New Issue
Block a user