mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #1878123 [[Enhancement - Viewer] Opening the search panel with text selected should add the selected text in the search field](https://bugs.launchpad.net/calibre/+bug/1878123)
This commit is contained in:
parent
1a1c4359dc
commit
23442569d7
@ -333,7 +333,9 @@ class SearchInput(QWidget): # {{{
|
||||
def find_previous(self):
|
||||
self.emit_search(backwards=True)
|
||||
|
||||
def focus_input(self):
|
||||
def focus_input(self, text=None):
|
||||
if text and hasattr(text, 'rstrip'):
|
||||
self.search_box.setText(text)
|
||||
self.search_box.setFocus(Qt.OtherFocusReason)
|
||||
le = self.search_box.lineEdit()
|
||||
le.end(False)
|
||||
@ -454,8 +456,8 @@ class SearchPanel(QWidget): # {{{
|
||||
def update_hidden_message(self):
|
||||
self.hidden_message.setVisible(self.results.current_result_is_hidden)
|
||||
|
||||
def focus_input(self):
|
||||
self.search_input.focus_input()
|
||||
def focus_input(self, text=None):
|
||||
self.search_input.focus_input(text)
|
||||
|
||||
def start_search(self, search_query, current_name):
|
||||
if self.current_search is not None and search_query == self.current_search:
|
||||
|
@ -288,10 +288,13 @@ class EbookViewer(MainWindow):
|
||||
self.toc_dock.setVisible(not self.toc_dock.isVisible())
|
||||
|
||||
def show_search(self):
|
||||
self.web_view.get_current_cfi(self.show_search_with_current_selection)
|
||||
|
||||
def show_search_with_current_selection(self, pos_data):
|
||||
self.search_dock.setVisible(True)
|
||||
self.search_dock.activateWindow()
|
||||
self.search_dock.raise_()
|
||||
self.search_widget.focus_input()
|
||||
self.search_widget.focus_input(pos_data.get('selected_text'))
|
||||
|
||||
def start_search(self, search_query):
|
||||
name = self.web_view.current_content_file
|
||||
|
Loading…
x
Reference in New Issue
Block a user