From 2f300b1ae84ab24d36e5ae170bd8f1070c825ed1 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 7 Oct 2014 12:45:55 +0530 Subject: [PATCH] OS X: Workaround for regression in Qt 5 that causes pressing the Esc key to close the entire window instead of the current completion popup See https://bugreports.qt-project.org/browse/QTBUG-41806 --- src/calibre/gui2/complete2.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/calibre/gui2/complete2.py b/src/calibre/gui2/complete2.py index f6aa9f378f..3620db5e64 100644 --- a/src/calibre/gui2/complete2.py +++ b/src/calibre/gui2/complete2.py @@ -244,6 +244,12 @@ class Completer(QListView): # {{{ self.hide() if e.isAccepted(): return True + elif isosx and etype == e.InputMethodQuery and e.queries() == (Qt.ImHints | Qt.ImEnabled) and self.isVisible(): + # In Qt 5 the Esc key cause this event and the line edit does not + # handle it, which causes the parent dialog to be closed + # See https://bugreports.qt-project.org/browse/QTBUG-41806 + self.hide(), e.accept() + return True elif etype == e.MouseButtonPress: if not self.rect().contains(self.mapFromGlobal(e.globalPos())): QTimer.singleShot(0, self.hide)