Generate new password whenever the generator widget is opened.

Closes #414
This commit is contained in:
Felix Geyer 2016-08-06 11:29:47 +02:00
parent 8d16522d39
commit 7d4ef0b8d0
3 changed files with 11 additions and 4 deletions

View file

@ -88,6 +88,14 @@ void PasswordGeneratorWidget::reset()
updateGenerator(); updateGenerator();
} }
void PasswordGeneratorWidget::regeneratePassword()
{
if (m_generator->isValid()) {
QString password = m_generator->generatePassword();
m_ui->editNewPassword->setEditText(password);
}
}
void PasswordGeneratorWidget::updateApplyEnabled(const QString& password) void PasswordGeneratorWidget::updateApplyEnabled(const QString& password)
{ {
m_ui->buttonApply->setEnabled(!password.isEmpty()); m_ui->buttonApply->setEnabled(!password.isEmpty());
@ -199,8 +207,5 @@ void PasswordGeneratorWidget::updateGenerator()
m_generator->setCharClasses(classes); m_generator->setCharClasses(classes);
m_generator->setFlags(flags); m_generator->setFlags(flags);
if (m_generator->isValid()) { regeneratePassword();
QString password = m_generator->generatePassword();
m_ui->editNewPassword->setEditText(password);
}
} }

View file

@ -39,6 +39,7 @@ public:
~PasswordGeneratorWidget(); ~PasswordGeneratorWidget();
void loadSettings(); void loadSettings();
void reset(); void reset();
void regeneratePassword();
Q_SIGNALS: Q_SIGNALS:
void newPassword(const QString& password); void newPassword(const QString& password);

View file

@ -487,6 +487,7 @@ void EditEntryWidget::clear()
void EditEntryWidget::togglePasswordGeneratorButton(bool checked) void EditEntryWidget::togglePasswordGeneratorButton(bool checked)
{ {
m_mainUi->passwordGenerator->regeneratePassword();
m_mainUi->passwordGenerator->setVisible(checked); m_mainUi->passwordGenerator->setVisible(checked);
} }