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
This commit is contained in:
Kovid Goyal 2014-10-07 12:45:55 +05:30
parent 59fc8e518a
commit 2f300b1ae8

View File

@ -244,6 +244,12 @@ class Completer(QListView): # {{{
self.hide() self.hide()
if e.isAccepted(): if e.isAccepted():
return True 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: elif etype == e.MouseButtonPress:
if not self.rect().contains(self.mapFromGlobal(e.globalPos())): if not self.rect().contains(self.mapFromGlobal(e.globalPos())):
QTimer.singleShot(0, self.hide) QTimer.singleShot(0, self.hide)