diff --git a/src/gui/PasswordGeneratorWidget.cpp b/src/gui/PasswordGeneratorWidget.cpp index d594cba8..048c3954 100644 --- a/src/gui/PasswordGeneratorWidget.cpp +++ b/src/gui/PasswordGeneratorWidget.cpp @@ -179,9 +179,15 @@ void PasswordGeneratorWidget::saveSettings() config()->set("generator/Type", m_ui->tabWidget->currentIndex()); } -void PasswordGeneratorWidget::reset() +void PasswordGeneratorWidget::reset(int length) { m_ui->editNewPassword->setText(""); + if (length > 0) { + m_ui->spinBoxLength->setValue(length); + } else { + m_ui->spinBoxLength->setValue(config()->get("generator/Length", PasswordGenerator::DefaultLength).toInt()); + } + setStandaloneMode(false); setPasswordVisible(config()->get("security/passwordscleartext").toBool()); updateGenerator(); diff --git a/src/gui/PasswordGeneratorWidget.h b/src/gui/PasswordGeneratorWidget.h index 0607f0fe..f736aea1 100644 --- a/src/gui/PasswordGeneratorWidget.h +++ b/src/gui/PasswordGeneratorWidget.h @@ -48,7 +48,7 @@ public: ~PasswordGeneratorWidget(); void loadSettings(); void saveSettings(); - void reset(); + void reset(int length = 0); void setStandaloneMode(bool standalone); QString getGeneratedPassword(); bool isPasswordVisible() const; diff --git a/src/gui/entry/EditEntryWidget.cpp b/src/gui/entry/EditEntryWidget.cpp index e1cdcf94..83eb3561 100644 --- a/src/gui/entry/EditEntryWidget.cpp +++ b/src/gui/entry/EditEntryWidget.cpp @@ -681,7 +681,7 @@ void EditEntryWidget::setForms(const Entry* entry, bool restore) m_mainUi->notesHint->setVisible(config()->get("security/hidenotes").toBool()); m_mainUi->togglePasswordGeneratorButton->setChecked(false); m_mainUi->togglePasswordGeneratorButton->setDisabled(m_history); - m_mainUi->passwordGenerator->reset(); + m_mainUi->passwordGenerator->reset(entry->password().length()); m_advancedUi->attachmentsWidget->setReadOnly(m_history); m_advancedUi->addAttributeButton->setEnabled(!m_history); @@ -934,6 +934,7 @@ void EditEntryWidget::cancel() QMessageBox::Cancel | QMessageBox::Save | QMessageBox::Discard, QMessageBox::Cancel); if (result == QMessageBox::Cancel) { + m_mainUi->passwordGenerator->reset(); return; } if (result == QMessageBox::Save) {