mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Tag browser: Have pressing the Enter key find the next match. Fixes #1816276 [Find the first/next matching item with Enter](https://bugs.launchpad.net/calibre/+bug/1816276)
This commit is contained in:
parent
15a3bb4b8d
commit
8d86d10e5a
@ -457,6 +457,7 @@ class TagBrowserBar(QWidget): # {{{
|
||||
self.toggle_search_button.setVisible(True)
|
||||
self.search_button.setVisible(False)
|
||||
self.item_search.setVisible(False)
|
||||
|
||||
# }}}
|
||||
|
||||
|
||||
@ -477,7 +478,6 @@ class TagBrowserWidget(QFrame): # {{{
|
||||
|
||||
self.current_find_position = None
|
||||
self.search_button.clicked.connect(self.find)
|
||||
self.item_search.lineEdit().returnPressed.connect(self.do_find)
|
||||
self.item_search.lineEdit().textEdited.connect(self.find_text_changed)
|
||||
self.item_search.activated[str].connect(self.do_find)
|
||||
|
||||
@ -587,10 +587,14 @@ class TagBrowserWidget(QFrame): # {{{
|
||||
self.current_find_position = None
|
||||
self.find()
|
||||
|
||||
@property
|
||||
def find_text(self):
|
||||
return unicode(self.item_search.currentText()).strip()
|
||||
|
||||
def find(self):
|
||||
model = self.tags_view.model()
|
||||
model.clear_boxed()
|
||||
txt = unicode(self.item_search.currentText()).strip()
|
||||
txt = self.find_text
|
||||
|
||||
if txt.startswith('*'):
|
||||
model.set_categories_filter(txt[1:])
|
||||
@ -636,4 +640,12 @@ class TagBrowserWidget(QFrame): # {{{
|
||||
def not_found_label_timer_event(self):
|
||||
self.not_found_label.setVisible(False)
|
||||
|
||||
def keyPressEvent(self, ev):
|
||||
if ev.key() in (Qt.Key_Enter, Qt.Key_Return) and self.find_text:
|
||||
self.find()
|
||||
ev.accept()
|
||||
return
|
||||
return QFrame.keyPressEvent(self, ev)
|
||||
|
||||
|
||||
# }}}
|
||||
|
Loading…
x
Reference in New Issue
Block a user