mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix pressing Enter in the search box causes the same search to be executed twice in the plugins and keyboard shortcuts preferences panels
This commit is contained in:
parent
c3d46f1460
commit
dcc5ae6137
@ -20,7 +20,7 @@ from calibre.constants import DEBUG
|
|||||||
from calibre import prints
|
from calibre import prints
|
||||||
from calibre.utils.icu import sort_key, lower
|
from calibre.utils.icu import sort_key, lower
|
||||||
from calibre.gui2 import NONE, error_dialog, info_dialog
|
from calibre.gui2 import NONE, error_dialog, info_dialog
|
||||||
from calibre.utils.search_query_parser import SearchQueryParser
|
from calibre.utils.search_query_parser import SearchQueryParser, ParseException
|
||||||
from calibre.gui2.search_box import SearchBox2
|
from calibre.gui2.search_box import SearchBox2
|
||||||
|
|
||||||
ROOT = QModelIndex()
|
ROOT = QModelIndex()
|
||||||
@ -590,11 +590,19 @@ class ShortcutConfig(QWidget): # {{{
|
|||||||
return self.view.state() == self.view.EditingState
|
return self.view.state() == self.view.EditingState
|
||||||
|
|
||||||
def find(self, query):
|
def find(self, query):
|
||||||
|
if not query:
|
||||||
|
return
|
||||||
|
try:
|
||||||
idx = self._model.find(query)
|
idx = self._model.find(query)
|
||||||
|
except ParseException:
|
||||||
|
self.search.search_done(False)
|
||||||
|
return
|
||||||
|
self.search.search_done(True)
|
||||||
if not idx.isValid():
|
if not idx.isValid():
|
||||||
return info_dialog(self, _('No matches'),
|
info_dialog(self, _('No matches'),
|
||||||
_('Could not find any matching shortcuts'), show=True,
|
_('Could not find any shortcuts matching %s')%query,
|
||||||
show_copy_button=False)
|
show=True, show_copy_button=False)
|
||||||
|
return
|
||||||
self.highlight_index(idx)
|
self.highlight_index(idx)
|
||||||
|
|
||||||
def highlight_index(self, idx):
|
def highlight_index(self, idx):
|
||||||
|
@ -163,6 +163,8 @@ class SearchBox2(QComboBox): # {{{
|
|||||||
# Comes from the combobox itself
|
# Comes from the combobox itself
|
||||||
def keyPressEvent(self, event):
|
def keyPressEvent(self, event):
|
||||||
k = event.key()
|
k = event.key()
|
||||||
|
if k in (Qt.Key_Enter, Qt.Key_Return):
|
||||||
|
return self.do_search()
|
||||||
if k not in (Qt.Key_Up, Qt.Key_Down):
|
if k not in (Qt.Key_Up, Qt.Key_Down):
|
||||||
QComboBox.keyPressEvent(self, event)
|
QComboBox.keyPressEvent(self, event)
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user