From 7d4ef0b8d0577b4b75d60cec560a24f97c71bfd4 Mon Sep 17 00:00:00 2001 From: Felix Geyer Date: Sat, 6 Aug 2016 11:29:47 +0200 Subject: [PATCH] Generate new password whenever the generator widget is opened. Closes #414 --- src/gui/PasswordGeneratorWidget.cpp | 13 +++++++++---- src/gui/PasswordGeneratorWidget.h | 1 + src/gui/entry/EditEntryWidget.cpp | 1 + 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/gui/PasswordGeneratorWidget.cpp b/src/gui/PasswordGeneratorWidget.cpp index 4cb14c4de..95efa5b2b 100644 --- a/src/gui/PasswordGeneratorWidget.cpp +++ b/src/gui/PasswordGeneratorWidget.cpp @@ -88,6 +88,14 @@ void PasswordGeneratorWidget::reset() updateGenerator(); } +void PasswordGeneratorWidget::regeneratePassword() +{ + if (m_generator->isValid()) { + QString password = m_generator->generatePassword(); + m_ui->editNewPassword->setEditText(password); + } +} + void PasswordGeneratorWidget::updateApplyEnabled(const QString& password) { m_ui->buttonApply->setEnabled(!password.isEmpty()); @@ -199,8 +207,5 @@ void PasswordGeneratorWidget::updateGenerator() m_generator->setCharClasses(classes); m_generator->setFlags(flags); - if (m_generator->isValid()) { - QString password = m_generator->generatePassword(); - m_ui->editNewPassword->setEditText(password); - } + regeneratePassword(); } diff --git a/src/gui/PasswordGeneratorWidget.h b/src/gui/PasswordGeneratorWidget.h index 96f3f6023..8759672a2 100644 --- a/src/gui/PasswordGeneratorWidget.h +++ b/src/gui/PasswordGeneratorWidget.h @@ -39,6 +39,7 @@ public: ~PasswordGeneratorWidget(); void loadSettings(); void reset(); + void regeneratePassword(); Q_SIGNALS: void newPassword(const QString& password); diff --git a/src/gui/entry/EditEntryWidget.cpp b/src/gui/entry/EditEntryWidget.cpp index 8cad92462..035abad4a 100644 --- a/src/gui/entry/EditEntryWidget.cpp +++ b/src/gui/entry/EditEntryWidget.cpp @@ -487,6 +487,7 @@ void EditEntryWidget::clear() void EditEntryWidget::togglePasswordGeneratorButton(bool checked) { + m_mainUi->passwordGenerator->regeneratePassword(); m_mainUi->passwordGenerator->setVisible(checked); }