Merge pull request #622 from keepassxreboot/fix/passgen-buttons

Fix password generator button's enable behavior
This commit is contained in:
TheZ3ro 2017-06-05 23:38:02 +02:00 committed by GitHub
commit 1847312c7a
2 changed files with 9 additions and 4 deletions

View File

@ -37,7 +37,7 @@ PasswordGeneratorWidget::PasswordGeneratorWidget(QWidget* parent)
m_ui->togglePasswordButton->setIcon(filePath()->onOffIcon("actions", "password-show"));
connect(m_ui->editNewPassword, SIGNAL(textChanged(QString)), SLOT(updateApplyEnabled(QString)));
connect(m_ui->editNewPassword, SIGNAL(textChanged(QString)), SLOT(updateButtonsEnabled(QString)));
connect(m_ui->editNewPassword, SIGNAL(textChanged(QString)), SLOT(updatePasswordStrength(QString)));
connect(m_ui->togglePasswordButton, SIGNAL(toggled(bool)), SLOT(togglePasswordShown(bool)));
connect(m_ui->buttonApply, SIGNAL(clicked()), SLOT(applyPassword()));
@ -139,6 +139,7 @@ void PasswordGeneratorWidget::reset()
void PasswordGeneratorWidget::setStandaloneMode(bool standalone)
{
m_standalone = standalone;
if (standalone) {
m_ui->buttonApply->setText(tr("Close"));
togglePasswordShown(true);
@ -164,9 +165,12 @@ void PasswordGeneratorWidget::regeneratePassword()
}
}
void PasswordGeneratorWidget::updateApplyEnabled(const QString& password)
void PasswordGeneratorWidget::updateButtonsEnabled(const QString& password)
{
m_ui->buttonApply->setEnabled(!password.isEmpty());
if (!m_standalone) {
m_ui->buttonApply->setEnabled(!password.isEmpty());
}
m_ui->buttonCopy->setEnabled(!password.isEmpty());
}
void PasswordGeneratorWidget::updatePasswordStrength(const QString& password)

View File

@ -58,7 +58,7 @@ signals:
private slots:
void applyPassword();
void copyPassword();
void updateApplyEnabled(const QString& password);
void updateButtonsEnabled(const QString& password);
void updatePasswordStrength(const QString& password);
void togglePasswordShown(bool hidden);
@ -72,6 +72,7 @@ private slots:
private:
bool m_updatingSpinBox;
bool m_standalone = false;
PasswordGenerator::CharClasses charClasses();
PasswordGenerator::GeneratorFlags generatorFlags();