From 3015baf6e6624914a1011956da62bcf7819d7247 Mon Sep 17 00:00:00 2001 From: thez3ro Date: Sun, 4 Jun 2017 21:06:27 +0200 Subject: [PATCH] fix password generator button's enable behavior --- src/gui/PasswordGeneratorWidget.cpp | 10 +++++++--- src/gui/PasswordGeneratorWidget.h | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/gui/PasswordGeneratorWidget.cpp b/src/gui/PasswordGeneratorWidget.cpp index 64aa22da5..8e369775b 100644 --- a/src/gui/PasswordGeneratorWidget.cpp +++ b/src/gui/PasswordGeneratorWidget.cpp @@ -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) diff --git a/src/gui/PasswordGeneratorWidget.h b/src/gui/PasswordGeneratorWidget.h index 9fbcdbeb1..b552e112b 100644 --- a/src/gui/PasswordGeneratorWidget.h +++ b/src/gui/PasswordGeneratorWidget.h @@ -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();