diff --git a/src/gui/PasswordGeneratorWidget.cpp b/src/gui/PasswordGeneratorWidget.cpp index d77634415..dd3cd5802 100644 --- a/src/gui/PasswordGeneratorWidget.cpp +++ b/src/gui/PasswordGeneratorWidget.cpp @@ -21,6 +21,7 @@ #include #include +#include #include "core/Config.h" #include "core/PasswordGenerator.h" @@ -149,6 +150,20 @@ void PasswordGeneratorWidget::setStandaloneMode(bool standalone) } } +void PasswordGeneratorWidget::keyPressEvent(QKeyEvent* e) +{ + if (!e->modifiers() || (e->modifiers() & Qt::KeypadModifier && e->key() == Qt::Key_Enter)) { + if (e->key() == Qt::Key_Escape && m_standalone == true) { + emit dialogTerminated(); + } else { + e->ignore(); + } + } + else { + e->ignore(); + } +} + void PasswordGeneratorWidget::regeneratePassword() { if (m_ui->tabWidget->currentIndex() == Password) { diff --git a/src/gui/PasswordGeneratorWidget.h b/src/gui/PasswordGeneratorWidget.h index 130106461..3d6d27a55 100644 --- a/src/gui/PasswordGeneratorWidget.h +++ b/src/gui/PasswordGeneratorWidget.h @@ -81,6 +81,9 @@ private: const QScopedPointer m_passwordGenerator; const QScopedPointer m_dicewareGenerator; const QScopedPointer m_ui; + +protected: + void keyPressEvent(QKeyEvent* e) override; }; #endif // KEEPASSX_PASSWORDGENERATORWIDGET_H