From a10091170bc0dd6487158c253096595fefbee8cd Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 11 Jun 2010 18:34:01 -0600 Subject: [PATCH] On startup do not focus the search bar. Instead you can acces the search bar easily by pressing the / key or the standard search keyboard shortcut for your operating system --- src/calibre/gui2/search_box.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/calibre/gui2/search_box.py b/src/calibre/gui2/search_box.py index d35f5e0725..f34c52d221 100644 --- a/src/calibre/gui2/search_box.py +++ b/src/calibre/gui2/search_box.py @@ -7,8 +7,8 @@ __copyright__ = '2009, Kovid Goyal ' __docformat__ = 'restructuredtext en' from PyQt4.Qt import QComboBox, Qt, QLineEdit, QStringList, pyqtSlot, \ - pyqtSignal, SIGNAL, QObject, QDialog -from PyQt4.QtGui import QCompleter + pyqtSignal, SIGNAL, QObject, QDialog, QCompleter, \ + QAction, QKeySequence from calibre.gui2 import config from calibre.gui2.dialogs.confirm_delete import confirm @@ -348,8 +348,14 @@ class SearchBoxMixin(object): self.do_advanced_search) self.search.clear() - self.search.setFocus(Qt.OtherFocusReason) self.search.setMaximumWidth(self.width()-150) + self.action_focus_search = QAction(self) + shortcuts = QKeySequence.keyBindings(QKeySequence.Find) + shortcuts = list(shortcuts) + [QKeySequence('/')] + self.action_focus_search.setShortcuts(shortcuts) + self.action_focus_search.triggered.connect(lambda x: + self.search.setFocus(Qt.OtherFocusReason)) + self.addAction(self.action_focus_search) def search_box_cleared(self): self.tags_view.clear()