Edit Book: When unmarking marked text, automatically ensure the current search scope is not to search in marked text

This commit is contained in:
Kovid Goyal 2016-09-13 09:13:55 +05:30
parent b0f808f2a0
commit e44ca5f067
2 changed files with 6 additions and 0 deletions

View File

@ -796,6 +796,8 @@ class Boss(QObject):
ed.mark_selected_text() ed.mark_selected_text()
if ed.has_marked_text: if ed.has_marked_text:
self.gui.central.search_panel.set_where('selected-text') self.gui.central.search_panel.set_where('selected-text')
else:
self.gui.central.search_panel.unset_marked()
def editor_action(self, action): def editor_action(self, action):
ed = self.gui.central.current_editor ed = self.gui.central.current_editor

View File

@ -485,6 +485,10 @@ class SearchPanel(QWidget): # {{{
def set_where(self, val): def set_where(self, val):
self.widget.where = val self.widget.where = val
def unset_marked(self):
if self.widget.where == 'selected-text':
self.widget.where = self.widget.DEFAULT_STATE['where']
def keyPressEvent(self, ev): def keyPressEvent(self, ev):
if ev.key() == Qt.Key_Escape: if ev.key() == Qt.Key_Escape:
self.hide_panel() self.hide_panel()