fix password generator button's enable behavior

This commit is contained in:
thez3ro 2017-06-04 21:06:27 +02:00
parent 3c51455fa3
commit 3015baf6e6
No known key found for this signature in database
GPG Key ID: F628F9E41DD7C073
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();