From e4088d5e6cdbb231d54f0ceaa66d6af3bc526f45 Mon Sep 17 00:00:00 2001 From: thez3ro Date: Mon, 22 Jan 2018 15:44:42 +0100 Subject: [PATCH] quit autotype dialog with esc key --- src/autotype/AutoTypeSelectDialog.cpp | 1 + src/autotype/AutoTypeSelectView.cpp | 17 +++++++++++++++++ src/autotype/AutoTypeSelectView.h | 4 ++++ 3 files changed, 22 insertions(+) diff --git a/src/autotype/AutoTypeSelectDialog.cpp b/src/autotype/AutoTypeSelectDialog.cpp index 240dd723b..b39c78e1d 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 717e20a31..76d57ec60 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 a781757b8..aadf99fa6 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