When showing the FTS dialog pre populate the search box with the contents of the main calibre search box if the main search box contains a simple search. Fixes #2052460 [[Enhancement] Automatically search for what is typed in the main calibre Search field when opening the Full text dialog](https://bugs.launchpad.net/calibre/+bug/2052460)

This commit is contained in:
Kovid Goyal 2024-02-06 08:47:07 +05:30
parent 296e74e7d7
commit f179b8c9b9
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 12 additions and 0 deletions

View File

@ -25,6 +25,9 @@ class FullTextSearchAction(InterfaceAction):
return self._dialog return self._dialog
def show_fts(self): def show_fts(self):
text = self.gui.search.text()
if text and ':' not in text:
self.dialog.set_search_text(text)
self.dialog.show() self.dialog.show()
self.dialog.raise_() self.dialog.raise_()

View File

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

View File

@ -519,6 +519,9 @@ class SearchInputPanel(QWidget):
def clear_history(self): def clear_history(self):
self.search_box.clear_history() self.search_box.clear_history()
def set_search_text(self, text):
self.search_box.setText(text)
def start(self): def start(self):
self.pi.start() self.pi.start()
@ -813,6 +816,9 @@ class ResultsPanel(QWidget):
def clear_history(self): def clear_history(self):
self.sip.clear_history() self.sip.clear_history()
def set_search_text(self, text):
self.sip.set_search_text(text)
def remove_book_from_results(self, book_id): def remove_book_from_results(self, book_id):
self.results_view.m.remove_book(book_id) self.results_view.m.remove_book(book_id)