Searching: When search as you type is active, do not change automatically change focus to the book list when searching, unless the user presses Enter. Fixes #1463042 [The focus issue of the search box after checked the Search as you type option](https://bugs.launchpad.net/calibre/+bug/1463042)

This commit is contained in:
Kovid Goyal 2015-06-09 09:08:35 +05:30
parent 89a6e4eaee
commit c04db5b1ff
2 changed files with 12 additions and 3 deletions

View File

@ -1054,7 +1054,7 @@ class BooksView(QTableView): # {{{
self.select_rows([id_to_select], using_ids=True)
elif self._model.highlight_only:
self.clearSelection()
if self.isVisible():
if self.isVisible() and getattr(txt, 'as_you_type', False) is not True:
self.setFocus(Qt.OtherFocusReason)
def connect_to_search_box(self, sb, search_done):

View File

@ -19,6 +19,13 @@ from calibre.gui2.dialogs.confirm_delete import confirm
from calibre.gui2.dialogs.saved_search_editor import SavedSearchEditor
from calibre.gui2.dialogs.search import SearchDialog
class AsYouType(unicode):
def __new__(cls, text):
self = unicode.__new__(cls, text)
self.as_you_type = True
return self
class SearchLineEdit(QLineEdit): # {{{
key_pressed = pyqtSignal(object)
select_on_mouse_press = None
@ -189,17 +196,19 @@ class SearchBox2(QComboBox): # {{{
self.normalize_state()
def timer_event(self):
self.do_search()
self._do_search(as_you_type=True)
def history_selected(self, text):
self.changed.emit()
self.do_search()
def _do_search(self, store_in_history=True):
def _do_search(self, store_in_history=True, as_you_type=False):
self.hide_completer_popup()
text = unicode(self.currentText()).strip()
if not text:
return self.clear()
if as_you_type:
text = AsYouType(text)
self.search.emit(text)
if store_in_history: