mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 14:32:22 -04:00
Set to browser.py findreplace.ui remember the last selected field
by creating saveComboActiveIndex and restoreComboActiveIndex. https://anki.tenderapp.com/discussions/ankidesktop/39468-find-and-replace-does-not-remember-the-input-from-last-time
This commit is contained in:
parent
40f98a244f
commit
a74e43a515
2 changed files with 24 additions and 1 deletions
|
@ -36,11 +36,13 @@ from aqt.utils import (
|
||||||
getTag,
|
getTag,
|
||||||
openHelp,
|
openHelp,
|
||||||
qtMenuShortcutWorkaround,
|
qtMenuShortcutWorkaround,
|
||||||
|
restoreComboActiveIndex,
|
||||||
restoreGeom,
|
restoreGeom,
|
||||||
restoreHeader,
|
restoreHeader,
|
||||||
restoreIsChecked,
|
restoreIsChecked,
|
||||||
restoreSplitter,
|
restoreSplitter,
|
||||||
restoreState,
|
restoreState,
|
||||||
|
saveComboActiveIndex,
|
||||||
saveComboBoxHistory,
|
saveComboBoxHistory,
|
||||||
saveGeom,
|
saveGeom,
|
||||||
saveHeader,
|
saveHeader,
|
||||||
|
@ -1942,13 +1944,17 @@ update cards set usn=?, mod=?, did=? where id in """
|
||||||
restoreIsChecked(frm.ignoreCase, combo + "ignoreCase")
|
restoreIsChecked(frm.ignoreCase, combo + "ignoreCase")
|
||||||
|
|
||||||
frm.find.setFocus()
|
frm.find.setFocus()
|
||||||
frm.field.addItems([_("All Fields")] + fields)
|
allfields = [_("All Fields")] + fields
|
||||||
|
frm.field.addItems(allfields)
|
||||||
|
restoreComboActiveIndex(frm.field, allfields, combo + "Field")
|
||||||
qconnect(frm.buttonBox.helpRequested, self.onFindReplaceHelp)
|
qconnect(frm.buttonBox.helpRequested, self.onFindReplaceHelp)
|
||||||
restoreGeom(d, "findreplace")
|
restoreGeom(d, "findreplace")
|
||||||
r = d.exec_()
|
r = d.exec_()
|
||||||
saveGeom(d, "findreplace")
|
saveGeom(d, "findreplace")
|
||||||
if not r:
|
if not r:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
saveComboActiveIndex(frm.field, combo + "Field")
|
||||||
if frm.field.currentIndex() == 0:
|
if frm.field.currentIndex() == 0:
|
||||||
field = None
|
field = None
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -503,6 +503,23 @@ def restoreIsChecked(widget, key):
|
||||||
widget.setChecked(aqt.mw.pm.profile[key])
|
widget.setChecked(aqt.mw.pm.profile[key])
|
||||||
|
|
||||||
|
|
||||||
|
def saveComboActiveIndex(widget, key):
|
||||||
|
textKey = key + "ComboActiveText"
|
||||||
|
indexKey = key + "ComboActiveIndex"
|
||||||
|
aqt.mw.pm.profile[textKey] = widget.currentText()
|
||||||
|
aqt.mw.pm.profile[indexKey] = widget.currentIndex()
|
||||||
|
|
||||||
|
|
||||||
|
def restoreComboActiveIndex(widget, history, key):
|
||||||
|
textKey = key + "ComboActiveText"
|
||||||
|
indexKey = key + "ComboActiveIndex"
|
||||||
|
text = aqt.mw.pm.profile.get(textKey)
|
||||||
|
index = aqt.mw.pm.profile.get(indexKey)
|
||||||
|
if text is not None and index is not None:
|
||||||
|
if index < len(history) and history[index] == text:
|
||||||
|
widget.setCurrentIndex(index)
|
||||||
|
|
||||||
|
|
||||||
def saveSplitter(widget, key):
|
def saveSplitter(widget, key):
|
||||||
key += "Splitter"
|
key += "Splitter"
|
||||||
aqt.mw.pm.profile[key] = widget.saveState()
|
aqt.mw.pm.profile[key] = widget.saveState()
|
||||||
|
|
Loading…
Reference in a new issue