From: Zack Rusin Date: Wed, 13 Apr 2011 05:54:00 +0000 (-0400) Subject: Allow closing of the goto widget with the escape key. X-Git-Tag: 2.0_alpha^2~1091 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=83387fb4565289a00fa4b1cf0768bbc1c7918f34;p=tools%2Fapitrace.git Allow closing of the goto widget with the escape key. --- diff --git a/gui/jumpwidget.cpp b/gui/jumpwidget.cpp index ca7f4b3..8c9ca33 100644 --- a/gui/jumpwidget.cpp +++ b/gui/jumpwidget.cpp @@ -1,6 +1,7 @@ #include "jumpwidget.h" #include +#include JumpWidget::JumpWidget(QWidget *parent ) : QWidget(parent) @@ -13,6 +14,8 @@ JumpWidget::JumpWidget(QWidget *parent ) SLOT(slotJump())); connect(m_ui.cancelButton, SIGNAL(clicked()), SLOT(slotCancel())); + + installEventFilter(this); } void JumpWidget::slotJump() @@ -34,4 +37,14 @@ void JumpWidget::showEvent(QShowEvent *event) return QWidget::showEvent(event); } +bool JumpWidget::eventFilter(QObject *object, QEvent* event) +{ + if (event->type() == QEvent::KeyPress) { + if ((static_cast(event))->key() == Qt::Key_Escape) { + hide(); + } + } + return QWidget::eventFilter(object, event); +} + #include "jumpwidget.moc" diff --git a/gui/jumpwidget.h b/gui/jumpwidget.h index 40f8b9d..5f71c00 100644 --- a/gui/jumpwidget.h +++ b/gui/jumpwidget.h @@ -4,6 +4,7 @@ #include "ui_jumpwidget.h" #include +class QKeyEvent; class QShowEvent; class JumpWidget : public QWidget @@ -20,6 +21,7 @@ private slots: void slotCancel(); protected: + virtual bool eventFilter(QObject *object, QEvent* event); virtual void showEvent(QShowEvent *event); private: