mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add a search button to explicitly run a search with the text currently in the quick search box
This commit is contained in:
parent
64e0d84fa1
commit
9acddf2f9e
@ -8,7 +8,7 @@ __docformat__ = 'restructuredtext en'
|
||||
from functools import partial
|
||||
|
||||
from PyQt4.Qt import QIcon, Qt, QWidget, QToolBar, QSize, \
|
||||
pyqtSignal, QToolButton, \
|
||||
pyqtSignal, QToolButton, QPushButton, \
|
||||
QObject, QVBoxLayout, QSizePolicy, QLabel, QHBoxLayout, QActionGroup, \
|
||||
QMenu
|
||||
|
||||
@ -171,16 +171,20 @@ class SearchBar(QWidget): # {{{
|
||||
l.addWidget(x)
|
||||
x.setToolTip(_("Advanced search"))
|
||||
|
||||
self.label = x = QLabel(_('&Search:'))
|
||||
l.addWidget(self.label)
|
||||
x.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
|
||||
|
||||
x = parent.search = SearchBox2(self)
|
||||
x.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)
|
||||
x.setObjectName("search")
|
||||
x.setToolTip(_("<p>Search the list of books by title, author, publisher, tags, comments, etc.<br><br>Words separated by spaces are ANDed"))
|
||||
l.addWidget(x)
|
||||
|
||||
self.search_button = QPushButton(_('S&earch'))
|
||||
l.addWidget(self.search_button)
|
||||
self.search_button.setSizePolicy(QSizePolicy.Minimum,
|
||||
QSizePolicy.Minimum)
|
||||
self.search_button.clicked.connect(parent.search.do_search)
|
||||
self.search_button.setToolTip(
|
||||
_('Do Quick Search (you can also press the Enter key)'))
|
||||
|
||||
x = parent.clear_button = QToolButton(self)
|
||||
x.setIcon(QIcon(I('clear_left.png')))
|
||||
x.setObjectName("clear_button")
|
||||
@ -211,7 +215,6 @@ class SearchBar(QWidget): # {{{
|
||||
l.addWidget(x)
|
||||
x.setToolTip(_("Delete current saved search"))
|
||||
|
||||
self.label.setBuddy(parent.search)
|
||||
|
||||
|
||||
# }}}
|
||||
|
@ -183,7 +183,7 @@ class SearchBox2(QComboBox):
|
||||
return ''
|
||||
return text
|
||||
|
||||
def do_search(self):
|
||||
def do_search(self, *args):
|
||||
text = unicode(self.currentText()).strip()
|
||||
if not text or text == self.help_text:
|
||||
return self.clear()
|
||||
@ -372,7 +372,7 @@ class SearchBoxMixin(object):
|
||||
self.search.setMaximumWidth(self.width()-150)
|
||||
self.action_focus_search = QAction(self)
|
||||
shortcuts = QKeySequence.keyBindings(QKeySequence.Find)
|
||||
shortcuts = list(shortcuts) + [QKeySequence('/')]
|
||||
shortcuts = list(shortcuts) + [QKeySequence('/'), QKeySequence('Alt+S')]
|
||||
self.action_focus_search.setShortcuts(shortcuts)
|
||||
self.action_focus_search.triggered.connect(lambda x:
|
||||
self.search.setFocus(Qt.OtherFocusReason))
|
||||
|
Loading…
x
Reference in New Issue
Block a user