mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Update min. length for password generator.
Update the minimum length for the password generator depending on the chosen options. Closes #420
This commit is contained in:
parent
e9c8363b70
commit
9532bedd7d
@ -111,6 +111,10 @@ void PasswordGeneratorWidget::sliderMoved()
|
||||
|
||||
void PasswordGeneratorWidget::spinBoxChanged()
|
||||
{
|
||||
if (m_updatingSpinBox) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Interlock so that we don't update twice - this causes issues as the spinbox can go higher than slider
|
||||
m_updatingSpinBox = true;
|
||||
|
||||
@ -161,9 +165,39 @@ PasswordGenerator::GeneratorFlags PasswordGeneratorWidget::generatorFlags()
|
||||
|
||||
void PasswordGeneratorWidget::updateGenerator()
|
||||
{
|
||||
PasswordGenerator::CharClasses classes = charClasses();
|
||||
PasswordGenerator::GeneratorFlags flags = generatorFlags();
|
||||
|
||||
int minLength = 0;
|
||||
if (flags.testFlag(PasswordGenerator::CharFromEveryGroup)) {
|
||||
if (classes.testFlag(PasswordGenerator::LowerLetters)) {
|
||||
minLength++;
|
||||
}
|
||||
if (classes.testFlag(PasswordGenerator::UpperLetters)) {
|
||||
minLength++;
|
||||
}
|
||||
if (classes.testFlag(PasswordGenerator::Numbers)) {
|
||||
minLength++;
|
||||
}
|
||||
if (classes.testFlag(PasswordGenerator::SpecialCharacters)) {
|
||||
minLength++;
|
||||
}
|
||||
}
|
||||
minLength = qMax(minLength, 1);
|
||||
|
||||
if (m_ui->spinBoxLength->value() < minLength) {
|
||||
m_updatingSpinBox = true;
|
||||
m_ui->spinBoxLength->setValue(minLength);
|
||||
m_ui->sliderLength->setValue(minLength);
|
||||
m_updatingSpinBox = false;
|
||||
}
|
||||
|
||||
m_ui->spinBoxLength->setMinimum(minLength);
|
||||
m_ui->sliderLength->setMinimum(minLength);
|
||||
|
||||
m_generator->setLength(m_ui->spinBoxLength->value());
|
||||
m_generator->setCharClasses(charClasses());
|
||||
m_generator->setFlags(generatorFlags());
|
||||
m_generator->setCharClasses(classes);
|
||||
m_generator->setFlags(flags);
|
||||
|
||||
if (m_generator->isValid()) {
|
||||
QString password = m_generator->generatePassword();
|
||||
|
Loading…
Reference in New Issue
Block a user