diff --git a/src/calibre/gui2/ui.py b/src/calibre/gui2/ui.py index b33c059c9b..6a74ccd6ea 100644 --- a/src/calibre/gui2/ui.py +++ b/src/calibre/gui2/ui.py @@ -16,7 +16,7 @@ from PyQt4.Qt import Qt, SIGNAL, QTimer, \ QPixmap, QMenu, QIcon, pyqtSignal, \ QDialog, \ QSystemTrayIcon, QApplication, QKeySequence, \ - QMessageBox, QHelpEvent + QMessageBox, QHelpEvent, QAction from calibre import prints 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) + 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 ######################## QTimer.singleShot(1000, self.add_spare_server) @@ -294,6 +298,8 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{ 'the file: %s
The ' 'log will be displayed automatically.')%self.gui_debug, show=True) + def esc(self, *args): + self.search.clear() def start_content_server(self): 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.test_server_timer = QTimer.singleShot(10000, self.test_server) - def resizeEvent(self, ev): MainWindow.resizeEvent(self, ev) self.search.setMaximumWidth(self.width()-150) diff --git a/src/calibre/manual/gui.rst b/src/calibre/manual/gui.rst index c84800116d..3718f830f3 100644 --- a/src/calibre/manual/gui.rst +++ b/src/calibre/manual/gui.rst @@ -478,6 +478,8 @@ Calibre has several keyboard shortcuts to save you time and mouse movement. Thes - Focus the search bar * - :kbd:`Shift+Ctrl+F` - Open the advanced search dialog + * - :kbd:`Esc` + - Clear the current search * - :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) * - :kbd:`Shift+N or Shift+F3`