mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
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:
parent
89a6e4eaee
commit
c04db5b1ff
@ -1054,7 +1054,7 @@ class BooksView(QTableView): # {{{
|
|||||||
self.select_rows([id_to_select], using_ids=True)
|
self.select_rows([id_to_select], using_ids=True)
|
||||||
elif self._model.highlight_only:
|
elif self._model.highlight_only:
|
||||||
self.clearSelection()
|
self.clearSelection()
|
||||||
if self.isVisible():
|
if self.isVisible() and getattr(txt, 'as_you_type', False) is not True:
|
||||||
self.setFocus(Qt.OtherFocusReason)
|
self.setFocus(Qt.OtherFocusReason)
|
||||||
|
|
||||||
def connect_to_search_box(self, sb, search_done):
|
def connect_to_search_box(self, sb, search_done):
|
||||||
|
@ -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.saved_search_editor import SavedSearchEditor
|
||||||
from calibre.gui2.dialogs.search import SearchDialog
|
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): # {{{
|
class SearchLineEdit(QLineEdit): # {{{
|
||||||
key_pressed = pyqtSignal(object)
|
key_pressed = pyqtSignal(object)
|
||||||
select_on_mouse_press = None
|
select_on_mouse_press = None
|
||||||
@ -189,17 +196,19 @@ class SearchBox2(QComboBox): # {{{
|
|||||||
self.normalize_state()
|
self.normalize_state()
|
||||||
|
|
||||||
def timer_event(self):
|
def timer_event(self):
|
||||||
self.do_search()
|
self._do_search(as_you_type=True)
|
||||||
|
|
||||||
def history_selected(self, text):
|
def history_selected(self, text):
|
||||||
self.changed.emit()
|
self.changed.emit()
|
||||||
self.do_search()
|
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()
|
self.hide_completer_popup()
|
||||||
text = unicode(self.currentText()).strip()
|
text = unicode(self.currentText()).strip()
|
||||||
if not text:
|
if not text:
|
||||||
return self.clear()
|
return self.clear()
|
||||||
|
if as_you_type:
|
||||||
|
text = AsYouType(text)
|
||||||
self.search.emit(text)
|
self.search.emit(text)
|
||||||
|
|
||||||
if store_in_history:
|
if store_in_history:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user