fix focus problems when using tags browser and keyboard shortcuts to initiate searching

This commit is contained in:
Charles Haley 2010-12-01 14:57:32 +00:00
parent 4bf7bc6b7b
commit 7e76be47b9
2 changed files with 11 additions and 14 deletions

View File

@ -203,14 +203,16 @@ class SearchBox2(QComboBox):
self.set_search_string(joiner.join(tags))
def set_search_string(self, txt):
self.setFocus(Qt.OtherFocusReason)
if not txt:
self.clear()
return
self.normalize_state()
self.setEditText(txt)
self.search.emit(txt)
self.line_edit.end(False)
self.initial_state = False
else:
self.normalize_state()
self.setEditText(txt)
self.search.emit(txt)
self.line_edit.end(False)
self.initial_state = False
self.focus_to_library.emit()
def search_as_you_type(self, enabled):
self.as_you_type = enabled
@ -228,7 +230,6 @@ class SavedSearchBox(QComboBox):
'''
changed = pyqtSignal()
focus_to_library = pyqtSignal()
def __init__(self, parent=None):
QComboBox.__init__(self, parent)
@ -273,7 +274,6 @@ class SavedSearchBox(QComboBox):
def key_pressed(self, event):
if event.key() in (Qt.Key_Return, Qt.Key_Enter):
self.saved_search_selected(self.currentText())
self.focus_to_library.emit()
def saved_search_selected(self, qname):
qname = unicode(qname)
@ -287,7 +287,6 @@ class SavedSearchBox(QComboBox):
self.search_box.set_search_string(u'search:"%s"' % qname)
self.setEditText(qname)
self.setToolTip(saved_searches().lookup(qname))
self.focus_to_library.emit()
def initialize_saved_search_names(self):
qnames = saved_searches().names()
@ -387,7 +386,6 @@ class SavedSearchBoxMixin(object):
def __init__(self):
self.saved_search.changed.connect(self.saved_searches_changed)
self.clear_button.clicked.connect(self.saved_search.clear)
self.saved_search.focus_to_library.connect(self.focus_to_library)
self.save_search_button.clicked.connect(
self.saved_search.save_search_button_clicked)
self.delete_search_button.clicked.connect(
@ -422,7 +420,3 @@ class SavedSearchBoxMixin(object):
if d.result() == d.Accepted:
self.saved_searches_changed()
self.saved_search.clear()
def focus_to_library(self):
self.current_view().setFocus(Qt.OtherFocusReason)

View File

@ -4,6 +4,8 @@ Created on 10 Jun 2010
@author: charles
'''
from PyQt4.Qt import Qt
class SearchRestrictionMixin(object):
def __init__(self):
@ -53,6 +55,7 @@ class SearchRestrictionMixin(object):
self.saved_search.clear()
self.tags_view.set_search_restriction(restriction)
self.set_number_of_books_shown()
self.current_view().setFocus(Qt.OtherFocusReason)
def set_number_of_books_shown(self):
if self.current_view() == self.library_view and self.restriction_in_effect: