From f179b8c9b9ab1f6bb3dbeaffe956fe67407f30a7 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 6 Feb 2024 08:47:07 +0530 Subject: [PATCH] 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) --- src/calibre/gui2/actions/fts.py | 3 +++ src/calibre/gui2/fts/dialog.py | 3 +++ src/calibre/gui2/fts/search.py | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/src/calibre/gui2/actions/fts.py b/src/calibre/gui2/actions/fts.py index 8e73fd2080..6571b3ce9d 100644 --- a/src/calibre/gui2/actions/fts.py +++ b/src/calibre/gui2/actions/fts.py @@ -25,6 +25,9 @@ class FullTextSearchAction(InterfaceAction): return self._dialog 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.raise_() diff --git a/src/calibre/gui2/fts/dialog.py b/src/calibre/gui2/fts/dialog.py index afc6d2865e..7a86039415 100644 --- a/src/calibre/gui2/fts/dialog.py +++ b/src/calibre/gui2/fts/dialog.py @@ -118,6 +118,9 @@ class FTSDialog(Dialog): def clear_search_history(self): self.results_panel.clear_history() + def set_search_text(self, text): + self.results_panel.set_search_text(text) + if __name__ == '__main__': from calibre.gui2 import Application diff --git a/src/calibre/gui2/fts/search.py b/src/calibre/gui2/fts/search.py index d21be4bac1..f4f8876089 100644 --- a/src/calibre/gui2/fts/search.py +++ b/src/calibre/gui2/fts/search.py @@ -519,6 +519,9 @@ class SearchInputPanel(QWidget): def clear_history(self): self.search_box.clear_history() + def set_search_text(self, text): + self.search_box.setText(text) + def start(self): self.pi.start() @@ -813,6 +816,9 @@ class ResultsPanel(QWidget): def clear_history(self): self.sip.clear_history() + def set_search_text(self, text): + self.sip.set_search_text(text) + def remove_book_from_results(self, book_id): self.results_view.m.remove_book(book_id)