From 6eef57563cfe8717c5524d3f38f8e77007cdeccd Mon Sep 17 00:00:00 2001 From: GRiker Date: Sun, 23 Jan 2011 06:46:39 -0700 Subject: [PATCH 1/2] GwR patch mapping ESC to clear search box --- src/calibre/gui2/search_box.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/calibre/gui2/search_box.py b/src/calibre/gui2/search_box.py index e4073a01c9..99d435c913 100644 --- a/src/calibre/gui2/search_box.py +++ b/src/calibre/gui2/search_box.py @@ -76,7 +76,10 @@ class SearchBox2(QComboBox): # {{{ c.setCompletionMode(c.PopupCompletion) c.highlighted[QString].connect(self.completer_used) c.activated[QString].connect(self.history_selected) - + 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) self.line_edit.key_pressed.connect(self.key_pressed, type=Qt.DirectConnection) self.activated.connect(self.history_selected) self.setEditable(True) @@ -91,6 +94,9 @@ class SearchBox2(QComboBox): # {{{ self._in_a_search = False self.tool_tip_text = self.toolTip() + def esc(self, *args): + self.clear() + def initialize(self, opt_name, colorize=False, help_text=_('Search')): self.as_you_type = config['search_as_you_type'] self.opt_name = opt_name From 2be9281390cb693b4c9a5506801f216c82117938 Mon Sep 17 00:00:00 2001 From: GRiker Date: Sun, 23 Jan 2011 11:39:26 -0700 Subject: [PATCH 2/2] GwR 2nd patch mapping ESC to SearchBox2.clear() --- src/calibre/gui2/search_box.py | 8 +------- src/calibre/gui2/ui.py | 9 +++++++-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/calibre/gui2/search_box.py b/src/calibre/gui2/search_box.py index 99d435c913..e4073a01c9 100644 --- a/src/calibre/gui2/search_box.py +++ b/src/calibre/gui2/search_box.py @@ -76,10 +76,7 @@ class SearchBox2(QComboBox): # {{{ c.setCompletionMode(c.PopupCompletion) c.highlighted[QString].connect(self.completer_used) c.activated[QString].connect(self.history_selected) - 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) + self.line_edit.key_pressed.connect(self.key_pressed, type=Qt.DirectConnection) self.activated.connect(self.history_selected) self.setEditable(True) @@ -94,9 +91,6 @@ class SearchBox2(QComboBox): # {{{ self._in_a_search = False self.tool_tip_text = self.toolTip() - def esc(self, *args): - self.clear() - def initialize(self, opt_name, colorize=False, help_text=_('Search')): self.as_you_type = config['search_as_you_type'] self.opt_name = opt_name 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)