diff --git a/src/autotype/AutoTypeSelectDialog.cpp b/src/autotype/AutoTypeSelectDialog.cpp index 240dd723..b39c78e1 100644 --- a/src/autotype/AutoTypeSelectDialog.cpp +++ b/src/autotype/AutoTypeSelectDialog.cpp @@ -58,6 +58,7 @@ AutoTypeSelectDialog::AutoTypeSelectDialog(QWidget* parent) connect(m_view, SIGNAL(activated(QModelIndex)), SLOT(emitEntryActivated(QModelIndex))); connect(m_view, SIGNAL(clicked(QModelIndex)), SLOT(emitEntryActivated(QModelIndex))); + connect(m_view, SIGNAL(rejected()), SLOT(reject())); connect(m_view->model(), SIGNAL(rowsRemoved(QModelIndex,int,int)), SLOT(entryRemoved())); layout->addWidget(m_view); diff --git a/src/autotype/AutoTypeSelectView.cpp b/src/autotype/AutoTypeSelectView.cpp index 717e20a3..76d57ec6 100644 --- a/src/autotype/AutoTypeSelectView.cpp +++ b/src/autotype/AutoTypeSelectView.cpp @@ -17,7 +17,9 @@ #include "AutoTypeSelectView.h" +#include #include +#include AutoTypeSelectView::AutoTypeSelectView(QWidget* parent) : EntryView(parent) @@ -54,3 +56,18 @@ void AutoTypeSelectView::selectFirstEntry() setCurrentIndex(index); } } + +void AutoTypeSelectView::keyReleaseEvent(QKeyEvent* e) +{ + qDebug() << e->key(); + + if (!e->modifiers() || (e->modifiers() & Qt::KeypadModifier && e->key() == Qt::Key_Enter)) { + if (e->key() == Qt::Key_Escape) { + emit rejected(); + } else { + e->ignore(); + } + } else { + e->ignore(); + } +} \ No newline at end of file diff --git a/src/autotype/AutoTypeSelectView.h b/src/autotype/AutoTypeSelectView.h index a781757b..aadf99fa 100644 --- a/src/autotype/AutoTypeSelectView.h +++ b/src/autotype/AutoTypeSelectView.h @@ -31,9 +31,13 @@ public: protected: void mouseMoveEvent(QMouseEvent* event) override; + void keyReleaseEvent(QKeyEvent* e) override; private slots: void selectFirstEntry(); + +signals: + void rejected(); }; #endif // KEEPASSX_AUTOTYPESELECTVIEW_H