From a70c767b929c916e8e21aec08d2933f4fede6b0f Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Tue, 20 Sep 2011 17:23:05 +0200 Subject: [PATCH] Fixes: Pressing return in search panel didn't run the search. It did so only if the focus was on the search term line edit. Task-number: QTCREATORBUG-6114 Change-Id: I0cf051ed0f5f4e7403d7c36eb2173a71de370276 Reviewed-on: http://codereview.qt-project.org/5252 Reviewed-by: Qt Sanity Bot Reviewed-by: Leandro T. C. Melo --- src/plugins/find/findtoolwindow.cpp | 15 ++++++++++++++- src/plugins/find/findtoolwindow.h | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/plugins/find/findtoolwindow.cpp b/src/plugins/find/findtoolwindow.cpp index 4fc75c96302..93b233f3110 100644 --- a/src/plugins/find/findtoolwindow.cpp +++ b/src/plugins/find/findtoolwindow.cpp @@ -64,7 +64,6 @@ FindToolWindow::FindToolWindow(FindPlugin *plugin, QWidget *parent) connect(m_ui.regExp, SIGNAL(toggled(bool)), m_plugin, SLOT(setRegularExpression(bool))); connect(m_ui.filterList, SIGNAL(activated(int)), this, SLOT(setCurrentFilter(int))); connect(m_ui.searchTerm, SIGNAL(textChanged(QString)), this, SLOT(updateButtonStates())); - connect(m_ui.searchTerm, SIGNAL(returnPressed()), this, SLOT(search())); m_findCompleter->setModel(m_plugin->findCompletionModel()); m_ui.searchTerm->setCompleter(m_findCompleter); @@ -86,6 +85,20 @@ FindToolWindow *FindToolWindow::instance() return m_instance; } +bool FindToolWindow::event(QEvent *event) +{ + if (event->type() == QEvent::KeyPress) { + QKeyEvent *ke = static_cast(event); + if ((ke->key() == Qt::Key_Return || ke->key() == Qt::Key_Enter) + && ke->modifiers() == Qt::NoModifier) { + ke->accept(); + search(); + return true; + } + } + return QWidget::event(event); +} + bool FindToolWindow::eventFilter(QObject *obj, QEvent *event) { if (obj == m_ui.searchTerm && event->type() == QEvent::KeyPress) { diff --git a/src/plugins/find/findtoolwindow.h b/src/plugins/find/findtoolwindow.h index ba9d0e881c4..41d5693e242 100644 --- a/src/plugins/find/findtoolwindow.h +++ b/src/plugins/find/findtoolwindow.h @@ -62,6 +62,7 @@ public: void writeSettings(); protected: + bool event(QEvent *event); bool eventFilter(QObject *obj, QEvent *event); private slots: