mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-12-24 23:09:44 -05:00
Ask before discarding generated password
This commit is contained in:
parent
7498fe24dc
commit
ee9ec0504b
@ -6979,6 +6979,14 @@ Do you want to overwrite it?</source>
|
||||
<source>Characters: %1</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Confirm Discard</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Do you want to discard this password?</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Excluded characters: "0", "1", "l", "I", "O", "|", "﹒", "B", "8", "G", "6"</source>
|
||||
<translation type="unfinished"></translation>
|
||||
|
@ -1973,7 +1973,11 @@ bool DatabaseWidget::lock()
|
||||
auto parent = modalWidget->parentWidget();
|
||||
while (parent) {
|
||||
if (parent == this) {
|
||||
// Preempt any popup questions
|
||||
// TODO: Figure out a way to "reject" or "accept" instead of specific buttons
|
||||
MessageBox::setNextAnswer(MessageBox::Discard);
|
||||
modalWidget->close();
|
||||
MessageBox::setNextAnswer(MessageBox::NoButton);
|
||||
break;
|
||||
}
|
||||
parent = parent->parentWidget();
|
||||
|
@ -67,7 +67,7 @@ PasswordGeneratorWidget::PasswordGeneratorWidget(QWidget* parent)
|
||||
connect(m_ui->buttonGenerate, SIGNAL(clicked()), SLOT(regeneratePassword()));
|
||||
connect(m_ui->buttonDeleteWordList, SIGNAL(clicked()), SLOT(deleteWordList()));
|
||||
connect(m_ui->buttonAddWordList, SIGNAL(clicked()), SLOT(addWordList()));
|
||||
connect(m_ui->buttonClose, SIGNAL(clicked()), SIGNAL(closed()));
|
||||
connect(m_ui->buttonClose, SIGNAL(clicked()), SLOT(confirmClose()));
|
||||
|
||||
connect(m_ui->sliderLength, SIGNAL(valueChanged(int)), SLOT(passwordLengthChanged(int)));
|
||||
connect(m_ui->spinBoxLength, SIGNAL(valueChanged(int)), SLOT(passwordLengthChanged(int)));
|
||||
@ -121,9 +121,25 @@ PasswordGeneratorWidget::~PasswordGeneratorWidget() = default;
|
||||
|
||||
void PasswordGeneratorWidget::closeEvent(QCloseEvent* event)
|
||||
{
|
||||
// Emits closed signal when clicking X from title bar
|
||||
confirmClose();
|
||||
event->ignore();
|
||||
}
|
||||
|
||||
void PasswordGeneratorWidget::confirmClose()
|
||||
{
|
||||
// Only ask for discard confirmation if in popup mode
|
||||
if (!m_standalone) {
|
||||
auto result = MessageBox::question(this,
|
||||
tr("Confirm Discard"),
|
||||
tr("Do you want to discard this password?"),
|
||||
MessageBox::Discard | MessageBox::Cancel,
|
||||
MessageBox::Cancel);
|
||||
if (result == MessageBox::Cancel) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
emit closed();
|
||||
QWidget::closeEvent(event);
|
||||
}
|
||||
|
||||
PasswordGeneratorWidget* PasswordGeneratorWidget::popupGenerator(QWidget* parent)
|
||||
@ -325,10 +341,12 @@ void PasswordGeneratorWidget::updatePasswordLengthLabel(const QString& password)
|
||||
|
||||
void PasswordGeneratorWidget::applyPassword()
|
||||
{
|
||||
saveSettings();
|
||||
m_passwordGenerated = true;
|
||||
emit appliedPassword(m_ui->editNewPassword->text());
|
||||
emit closed();
|
||||
if (!m_standalone) {
|
||||
saveSettings();
|
||||
m_passwordGenerated = true;
|
||||
emit appliedPassword(m_ui->editNewPassword->text());
|
||||
emit closed();
|
||||
}
|
||||
}
|
||||
|
||||
void PasswordGeneratorWidget::copyPassword()
|
||||
|
@ -69,6 +69,7 @@ public slots:
|
||||
void setPasswordVisible(bool visible);
|
||||
void deleteWordList();
|
||||
void addWordList();
|
||||
void confirmClose();
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent* event) override;
|
||||
|
Loading…
Reference in New Issue
Block a user