Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make password generator length use existing length if available #2318

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/gui/PasswordGeneratorWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/gui/PasswordGeneratorWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class PasswordGeneratorWidget : public QWidget
~PasswordGeneratorWidget();
void loadSettings();
void saveSettings();
void reset();
void reset(int length = 0);
void setStandaloneMode(bool standalone);
QString getGeneratedPassword();
bool isPasswordVisible() const;
Expand Down
3 changes: 2 additions & 1 deletion src/gui/entry/EditEntryWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down