diff --git a/src/libs/utils/completingtextedit.cpp b/src/libs/utils/completingtextedit.cpp index f32dcbbf88d..77f061c7b41 100644 --- a/src/libs/utils/completingtextedit.cpp +++ b/src/libs/utils/completingtextedit.cpp @@ -190,6 +190,20 @@ void CompletingTextEdit::focusInEvent(QFocusEvent *e) QTextEdit::focusInEvent(e); } +bool CompletingTextEdit::event(QEvent *e) +{ + // workaround for QTCREATORBUG-9453 + if (e->type() == QEvent::ShortcutOverride && completer() + && completer()->popup() && completer()->popup()->isVisible()) { + QKeyEvent *ke = static_cast(e); + if (ke->key() == Qt::Key_Escape && !ke->modifiers()) { + ke->accept(); + return true; + } + } + return QTextEdit::event(e); +} + } // namespace Utils #include "moc_completingtextedit.cpp" diff --git a/src/libs/utils/completingtextedit.h b/src/libs/utils/completingtextedit.h index 17b4600ee17..f7ece3e47e3 100644 --- a/src/libs/utils/completingtextedit.h +++ b/src/libs/utils/completingtextedit.h @@ -36,6 +36,7 @@ QT_BEGIN_NAMESPACE class QCompleter; +class QEvent; QT_END_NAMESPACE namespace Utils { @@ -59,6 +60,7 @@ public: protected: void keyPressEvent(QKeyEvent *e); void focusInEvent(QFocusEvent *e); + bool event(QEvent *e); private: class CompletingTextEditPrivate *d; diff --git a/src/libs/utils/fancylineedit.cpp b/src/libs/utils/fancylineedit.cpp index 489d3022ce5..4df20ce614f 100644 --- a/src/libs/utils/fancylineedit.cpp +++ b/src/libs/utils/fancylineedit.cpp @@ -31,13 +31,15 @@ #include "historycompleter.h" #include "qtcassert.h" -#include -#include +#include #include +#include +#include +#include #include #include +#include #include -#include /*! Opens a menu at the specified widget position. * This functions computes the position where to show the menu, and opens it with @@ -251,6 +253,20 @@ void FancyLineEdit::resizeEvent(QResizeEvent *) updateButtonPositions(); } +bool FancyLineEdit::event(QEvent *e) +{ + // workaround for QTCREATORBUG-9453 + if (e->type() == QEvent::ShortcutOverride && completer() + && completer()->popup() && completer()->popup()->isVisible()) { + QKeyEvent *ke = static_cast(e); + if (ke->key() == Qt::Key_Escape && !ke->modifiers()) { + ke->accept(); + return true; + } + } + return QLineEdit::event(e); +} + void FancyLineEdit::setButtonPixmap(Side side, const QPixmap &buttonPixmap) { d->m_iconbutton[side]->setPixmap(buttonPixmap); diff --git a/src/libs/utils/fancylineedit.h b/src/libs/utils/fancylineedit.h index 3d08eb14858..fec5dced30e 100644 --- a/src/libs/utils/fancylineedit.h +++ b/src/libs/utils/fancylineedit.h @@ -35,6 +35,10 @@ #include #include +QT_BEGIN_NAMESPACE +class QEvent; +QT_END_NAMESPACE + namespace Utils { class FancyLineEditPrivate; @@ -109,7 +113,8 @@ private slots: void iconClicked(); protected: - virtual void resizeEvent(QResizeEvent *e); + void resizeEvent(QResizeEvent *e); + bool event(QEvent *e); private: // Unimplemented, to force the user to make a decision on