Add keypress handler to the password generator widget so that esc quits

in standalone mode.
This commit is contained in:
Matt Signorini 2017-10-07 17:19:55 +11:00 committed by TheZ3ro
parent 5584481bef
commit 8f48ede957
2 changed files with 18 additions and 0 deletions

View File

@ -21,6 +21,7 @@
#include <QLineEdit>
#include <QDir>
#include <QKeyEvent>
#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) {

View File

@ -81,6 +81,9 @@ private:
const QScopedPointer<PasswordGenerator> m_passwordGenerator;
const QScopedPointer<PassphraseGenerator> m_dicewareGenerator;
const QScopedPointer<Ui::PasswordGeneratorWidget> m_ui;
protected:
void keyPressEvent(QKeyEvent* e) override;
};
#endif // KEEPASSX_PASSWORDGENERATORWIDGET_H