mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-03 02:56:37 +02: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
2 changed files with 9 additions and 4 deletions
|
|
@ -333,7 +333,9 @@ def find_next(self):
|
|||
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 @@ def __init__(self, parent=None):
|
|||
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 @@ def toggle_toc(self):
|
|||
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…
Reference in a new issue