From aa88ad2e8687bd1b5d79c1a85ea5547bba1c8458 Mon Sep 17 00:00:00 2001 From: Balazs Gyurak Date: Fri, 21 Jun 2019 22:02:39 +0100 Subject: [PATCH] Fix password generator properties initialization --- CHANGELOG | 1 + src/gui/PasswordGeneratorWidget.cpp | 14 ++++++++++---- src/gui/PasswordGeneratorWidget.h | 3 +++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 07e50663df..91c7604212 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -6,6 +6,7 @@ - Move notes to General tab on Group Preview Panel [#3336] - Add 'Monospaced font' option to the Notes field [#3321] - Drop to background when copy feature [#3253] +- Fix password generator issues with special characters [#3303] 2.4.3 (2019-06-12) ========================= diff --git a/src/gui/PasswordGeneratorWidget.cpp b/src/gui/PasswordGeneratorWidget.cpp index 902dbdfea7..e0f8fbe5fc 100644 --- a/src/gui/PasswordGeneratorWidget.cpp +++ b/src/gui/PasswordGeneratorWidget.cpp @@ -92,13 +92,18 @@ PasswordGeneratorWidget::PasswordGeneratorWidget(QWidget* parent) } loadSettings(); - reset(); } PasswordGeneratorWidget::~PasswordGeneratorWidget() { } +void PasswordGeneratorWidget::showEvent(QShowEvent* event) +{ + QWidget::showEvent(event); + reset(); +} + void PasswordGeneratorWidget::loadSettings() { // Password config @@ -107,6 +112,8 @@ void PasswordGeneratorWidget::loadSettings() m_ui->checkBoxUpper->setChecked(config()->get("generator/UpperCase", PasswordGenerator::DefaultUpper).toBool()); m_ui->checkBoxUpperAdv->setChecked(config()->get("generator/UpperCase", PasswordGenerator::DefaultUpper).toBool()); m_ui->checkBoxNumbers->setChecked(config()->get("generator/Numbers", PasswordGenerator::DefaultNumbers).toBool()); + m_ui->checkBoxSpecialChars->setChecked( + config()->get("generator/SpecialChars", PasswordGenerator::DefaultSpecial).toBool()); m_ui->checkBoxNumbersAdv->setChecked( config()->get("generator/Numbers", PasswordGenerator::DefaultNumbers).toBool()); m_ui->advancedBar->setVisible( @@ -119,6 +126,7 @@ void PasswordGeneratorWidget::loadSettings() config()->get("generator/AdvancedMode", PasswordGenerator::DefaultAdvancedMode).toBool()); m_ui->editExcludedChars->setText( config()->get("generator/ExcludedChars", PasswordGenerator::DefaultExcludedChars).toString()); + m_ui->simpleBar->setVisible( !(config()->get("generator/AdvancedMode", PasswordGenerator::DefaultAdvancedMode).toBool())); m_ui->checkBoxBraces->setChecked(config()->get("generator/Braces", PasswordGenerator::DefaultBraces).toBool()); @@ -164,6 +172,7 @@ void PasswordGeneratorWidget::saveSettings() config()->set("generator/Numbers", m_ui->checkBoxNumbersAdv->isChecked()); config()->set("generator/EASCII", m_ui->checkBoxExtASCIIAdv->isChecked()); } + config()->set("generator/AdvancedMode", m_ui->advancedBar->isVisible()); config()->set("generator/SpecialChars", m_ui->checkBoxSpecialChars->isChecked()); config()->set("generator/Braces", m_ui->checkBoxBraces->isChecked()); config()->set("generator/Punctuation", m_ui->checkBoxPunctuation->isChecked()); @@ -406,7 +415,6 @@ PasswordGenerator::CharClasses PasswordGeneratorWidget::charClasses() PasswordGenerator::CharClasses classes; if (m_ui->simpleBar->isVisible()) { - if (m_ui->checkBoxLower->isChecked()) { classes |= PasswordGenerator::LowerLetters; } @@ -426,9 +434,7 @@ PasswordGenerator::CharClasses PasswordGeneratorWidget::charClasses() if (m_ui->checkBoxExtASCII->isChecked()) { classes |= PasswordGenerator::EASCII; } - } else { - if (m_ui->checkBoxLowerAdv->isChecked()) { classes |= PasswordGenerator::LowerLetters; } diff --git a/src/gui/PasswordGeneratorWidget.h b/src/gui/PasswordGeneratorWidget.h index f736aea13e..b39a2f10f9 100644 --- a/src/gui/PasswordGeneratorWidget.h +++ b/src/gui/PasswordGeneratorWidget.h @@ -53,6 +53,9 @@ class PasswordGeneratorWidget : public QWidget QString getGeneratedPassword(); bool isPasswordVisible() const; +protected: + void showEvent(QShowEvent* event) override; + public slots: void regeneratePassword(); void applyPassword();