Close variable chooser on escape (if it has focus).

Task-number: QTCREATORBUG-4307

Change-Id: Ib85f5fda1310fe6fb0e0824488fb6c79962ae35b
Reviewed-on: http://codereview.qt.nokia.com/624
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Robert Löhning <robert.loehning@nokia.com>
This commit is contained in:
con
2011-06-22 16:21:04 +02:00
committed by Eike Ziller
parent 7827af9712
commit 2707f7a74b
2 changed files with 13 additions and 0 deletions

View File

@@ -35,6 +35,8 @@
#include "variablemanager.h" #include "variablemanager.h"
#include "coreconstants.h" #include "coreconstants.h"
#include <QtCore/QTimer>
using namespace Core; using namespace Core;
VariableChooser::VariableChooser(QWidget *parent) : VariableChooser::VariableChooser(QWidget *parent) :
@@ -175,3 +177,11 @@ void VariableChooser::insertVariable(const QString &variable)
m_plainTextEdit->activateWindow(); m_plainTextEdit->activateWindow();
} }
} }
void VariableChooser::keyPressEvent(QKeyEvent *ke)
{
if (ke->key() == Qt::Key_Escape && !ke->modifiers()) {
ke->accept();
QTimer::singleShot(0, this, SLOT(close()));
}
}

View File

@@ -58,6 +58,9 @@ public:
explicit VariableChooser(QWidget *parent = 0); explicit VariableChooser(QWidget *parent = 0);
~VariableChooser(); ~VariableChooser();
protected:
void keyPressEvent(QKeyEvent *ke);
private slots: private slots:
void updateDescription(const QString &variable); void updateDescription(const QString &variable);
void updateCurrentEditor(QWidget *old, QWidget *widget); void updateCurrentEditor(QWidget *old, QWidget *widget);