Set to remember the last replace input for findreplace.ui

https://anki.tenderapp.com/discussions/ankidesktop/39468-find-and-replace-does-not-remember-the-input-from-last-time
This commit is contained in:
evandrocoan 2020-05-31 00:18:51 -03:00
parent ba99c5ecb5
commit 3971ea5518
2 changed files with 28 additions and 2 deletions

View File

@ -1936,6 +1936,11 @@ update cards set usn=?, mod=?, did=? where id in """
frm.find.lineEdit().selectAll()
frm.find.setFocus()
replacehistory = self.mw.pm.profile.get("FindAndReplaceReplaceHistory", [])
frm.replace.addItems(replacehistory)
frm.replace.lineEdit().setText(replacehistory[0] if replacehistory else "")
frm.replace.lineEdit().selectAll()
frm.field.addItems([_("All Fields")] + fields)
qconnect(frm.buttonBox.helpRequested, self.onFindReplaceHelp)
restoreGeom(d, "findreplace")
@ -1957,7 +1962,15 @@ update cards set usn=?, mod=?, did=? where id in """
frm.find.addItems(findhistory)
self.mw.pm.profile["FindAndReplaceFindHistory"] = findhistory
replace = frm.replace.text()
replace = frm.replace.lineEdit().text()
if replace in replacehistory:
replacehistory.remove(replace)
replacehistory.insert(0, replace)
replacehistory = replacehistory[:30]
frm.replace.clear()
frm.replace.addItems(replacehistory)
self.mw.pm.profile["FindAndReplaceReplaceHistory"] = replacehistory
regex = frm.re.isChecked()
nocase = frm.ignoreCase.isChecked()

View File

@ -47,7 +47,20 @@
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="replace"/>
<widget class="QComboBox" name="replace">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>9</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="editable">
<bool>true</bool>
</property>
<property name="insertPolicy">
<enum>QComboBox::NoInsert</enum>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">