Clear search histories in preferences should clear the fts dialog's search history as well

This commit is contained in:
Kovid Goyal 2022-07-12 14:46:06 +05:30
parent 6c79a163ba
commit 75bbecc534
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
4 changed files with 18 additions and 1 deletions

View File

@ -31,3 +31,7 @@ class FullTextSearchAction(InterfaceAction):
def library_changed(self, db):
if self._dialog is not None:
self._dialog.library_changed()
def clear_search_history(self):
if self._dialog is not None:
self._dialog.clear_search_history()

View File

@ -96,6 +96,9 @@ class FTSDialog(Dialog):
self.scan_status.startup()
self.results_panel.on_show()
def clear_search_history(self):
self.results_panel.clear_history()
if __name__ == '__main__':
from calibre.gui2 import Application

View File

@ -497,6 +497,9 @@ class SearchInputPanel(QWidget):
self.layout().addLayout(v2)
def clear_history(self):
self.search_box.clear_history()
def start(self):
self.pi.start()
@ -777,6 +780,9 @@ class ResultsPanel(QWidget):
if st is not None:
s.restoreState(st)
def clear_history(self):
self.sip.clear_history()
def remove_book_from_results(self, book_id):
self.results_view.m.remove_book(book_id)

View File

@ -253,12 +253,16 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
for key in (
'bulk_edit_search_for', 'bulk_edit_replace_with',
'viewer-highlights-search-panel-expression',
'viewer-search-panel-expression',
'viewer-search-panel-expression', 'library-fts-search-box',
):
history.set('lineedit_history_' + key, [])
from calibre.gui2.viewer.config import vprefs
for k in ('search', 'highlights'):
vprefs.set(f'saved-{k}-settings', {})
from calibre.gui2.ui import get_gui
gui = get_gui()
if gui is not None:
gui.iactions['Full Text Search'].clear_search_history()
if __name__ == '__main__':