Pressing Esc clears the current search in the main book list

This commit is contained in:
Kovid Goyal 2011-01-23 11:59:03 -07:00
commit 04761e12e9
2 changed files with 9 additions and 2 deletions

View File

@ -16,7 +16,7 @@ from PyQt4.Qt import Qt, SIGNAL, QTimer, \
QPixmap, QMenu, QIcon, pyqtSignal, \ QPixmap, QMenu, QIcon, pyqtSignal, \
QDialog, \ QDialog, \
QSystemTrayIcon, QApplication, QKeySequence, \ QSystemTrayIcon, QApplication, QKeySequence, \
QMessageBox, QHelpEvent QMessageBox, QHelpEvent, QAction
from calibre import prints from calibre import prints
from calibre.constants import __appname__, isosx from calibre.constants import __appname__, isosx
@ -198,6 +198,10 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
self.system_tray_icon.activated.connect( self.system_tray_icon.activated.connect(
self.system_tray_icon_activated) self.system_tray_icon_activated)
self.esc_action = QAction(self)
self.addAction(self.esc_action)
self.esc_action.setShortcut(QKeySequence(Qt.Key_Escape))
self.esc_action.triggered.connect(self.esc)
####################### Start spare job server ######################## ####################### Start spare job server ########################
QTimer.singleShot(1000, self.add_spare_server) QTimer.singleShot(1000, self.add_spare_server)
@ -294,6 +298,8 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
'the file: %s<p>The ' 'the file: %s<p>The '
'log will be displayed automatically.')%self.gui_debug, show=True) 'log will be displayed automatically.')%self.gui_debug, show=True)
def esc(self, *args):
self.search.clear()
def start_content_server(self): def start_content_server(self):
from calibre.library.server.main import start_threaded_server from calibre.library.server.main import start_threaded_server
@ -305,7 +311,6 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
self.content_server.state_callback(True) self.content_server.state_callback(True)
self.test_server_timer = QTimer.singleShot(10000, self.test_server) self.test_server_timer = QTimer.singleShot(10000, self.test_server)
def resizeEvent(self, ev): def resizeEvent(self, ev):
MainWindow.resizeEvent(self, ev) MainWindow.resizeEvent(self, ev)
self.search.setMaximumWidth(self.width()-150) self.search.setMaximumWidth(self.width()-150)

View File

@ -478,6 +478,8 @@ Calibre has several keyboard shortcuts to save you time and mouse movement. Thes
- Focus the search bar - Focus the search bar
* - :kbd:`Shift+Ctrl+F` * - :kbd:`Shift+Ctrl+F`
- Open the advanced search dialog - Open the advanced search dialog
* - :kbd:`Esc`
- Clear the current search
* - :kbd:`N or F3` * - :kbd:`N or F3`
- Find the next book that matches the current search (only works if the highlight checkbox next to the search bar is checked) - Find the next book that matches the current search (only works if the highlight checkbox next to the search bar is checked)
* - :kbd:`Shift+N or Shift+F3` * - :kbd:`Shift+N or Shift+F3`