mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-07-29 01:28:47 -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
1 changed files with 36 additions and 2 deletions
|
@ -111,6 +111,10 @@ void PasswordGeneratorWidget::sliderMoved()
|
||||||
|
|
||||||
void PasswordGeneratorWidget::spinBoxChanged()
|
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
|
// Interlock so that we don't update twice - this causes issues as the spinbox can go higher than slider
|
||||||
m_updatingSpinBox = true;
|
m_updatingSpinBox = true;
|
||||||
|
|
||||||
|
@ -161,9 +165,39 @@ PasswordGenerator::GeneratorFlags PasswordGeneratorWidget::generatorFlags()
|
||||||
|
|
||||||
void PasswordGeneratorWidget::updateGenerator()
|
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->setLength(m_ui->spinBoxLength->value());
|
||||||
m_generator->setCharClasses(charClasses());
|
m_generator->setCharClasses(classes);
|
||||||
m_generator->setFlags(generatorFlags());
|
m_generator->setFlags(flags);
|
||||||
|
|
||||||
if (m_generator->isValid()) {
|
if (m_generator->isValid()) {
|
||||||
QString password = m_generator->generatePassword();
|
QString password = m_generator->generatePassword();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue