Commit 2e1ecb5c authored by con's avatar con
Browse files

Function argument widget was closing too early.



In case the completion shortcut contained the escape key (Mac xcode-like
shortcut settings).
Reviewed-by: default avatarThorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com>
parent cbcf5e48
...@@ -99,6 +99,7 @@ private: ...@@ -99,6 +99,7 @@ private:
int m_startpos; int m_startpos;
int m_currentarg; int m_currentarg;
int m_current; int m_current;
bool m_escapePressed;
TextEditor::ITextEditor *m_editor; TextEditor::ITextEditor *m_editor;
...@@ -197,7 +198,8 @@ using namespace CppTools::Internal; ...@@ -197,7 +198,8 @@ using namespace CppTools::Internal;
FunctionArgumentWidget::FunctionArgumentWidget(): FunctionArgumentWidget::FunctionArgumentWidget():
m_startpos(-1), m_startpos(-1),
m_current(0) m_current(0),
m_escapePressed(false)
{ {
QObject *editorObject = Core::EditorManager::instance()->currentEditor(); QObject *editorObject = Core::EditorManager::instance()->currentEditor();
m_editor = qobject_cast<TextEditor::ITextEditor *>(editorObject); m_editor = qobject_cast<TextEditor::ITextEditor *>(editorObject);
...@@ -267,6 +269,7 @@ void FunctionArgumentWidget::showFunctionHint(QList<Function *> functionSymbols, ...@@ -267,6 +269,7 @@ void FunctionArgumentWidget::showFunctionHint(QList<Function *> functionSymbols,
m_context = context; m_context = context;
m_startpos = startPosition; m_startpos = startPosition;
m_current = 0; m_current = 0;
m_escapePressed = false;
// update the text // update the text
m_currentarg = -1; m_currentarg = -1;
...@@ -326,7 +329,15 @@ void FunctionArgumentWidget::updateArgumentHighlight() ...@@ -326,7 +329,15 @@ void FunctionArgumentWidget::updateArgumentHighlight()
bool FunctionArgumentWidget::eventFilter(QObject *obj, QEvent *e) bool FunctionArgumentWidget::eventFilter(QObject *obj, QEvent *e)
{ {
switch (e->type()) { switch (e->type()) {
case QEvent::ShortcutOverride:
if (static_cast<QKeyEvent*>(e)->key() == Qt::Key_Escape) {
m_escapePressed = true;
}
break;
case QEvent::KeyPress: case QEvent::KeyPress:
if (static_cast<QKeyEvent*>(e)->key() == Qt::Key_Escape) {
m_escapePressed = true;
}
if (m_items.size() > 1) { if (m_items.size() > 1) {
QKeyEvent *ke = static_cast<QKeyEvent*>(e); QKeyEvent *ke = static_cast<QKeyEvent*>(e);
if (ke->key() == Qt::Key_Up) { if (ke->key() == Qt::Key_Up) {
...@@ -340,7 +351,7 @@ bool FunctionArgumentWidget::eventFilter(QObject *obj, QEvent *e) ...@@ -340,7 +351,7 @@ bool FunctionArgumentWidget::eventFilter(QObject *obj, QEvent *e)
} }
break; break;
case QEvent::KeyRelease: case QEvent::KeyRelease:
if (static_cast<QKeyEvent*>(e)->key() == Qt::Key_Escape) { if (static_cast<QKeyEvent*>(e)->key() == Qt::Key_Escape && m_escapePressed) {
m_popupFrame->close(); m_popupFrame->close();
return false; return false;
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment