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>
|
<source>Characters: %1</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</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>
|
<message>
|
||||||
<source>Excluded characters: "0", "1", "l", "I", "O", "|", "﹒", "B", "8", "G", "6"</source>
|
<source>Excluded characters: "0", "1", "l", "I", "O", "|", "﹒", "B", "8", "G", "6"</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
|
@ -1973,7 +1973,11 @@ bool DatabaseWidget::lock()
|
|||||||
auto parent = modalWidget->parentWidget();
|
auto parent = modalWidget->parentWidget();
|
||||||
while (parent) {
|
while (parent) {
|
||||||
if (parent == this) {
|
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();
|
modalWidget->close();
|
||||||
|
MessageBox::setNextAnswer(MessageBox::NoButton);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
parent = parent->parentWidget();
|
parent = parent->parentWidget();
|
||||||
|
@ -67,7 +67,7 @@ PasswordGeneratorWidget::PasswordGeneratorWidget(QWidget* parent)
|
|||||||
connect(m_ui->buttonGenerate, SIGNAL(clicked()), SLOT(regeneratePassword()));
|
connect(m_ui->buttonGenerate, SIGNAL(clicked()), SLOT(regeneratePassword()));
|
||||||
connect(m_ui->buttonDeleteWordList, SIGNAL(clicked()), SLOT(deleteWordList()));
|
connect(m_ui->buttonDeleteWordList, SIGNAL(clicked()), SLOT(deleteWordList()));
|
||||||
connect(m_ui->buttonAddWordList, SIGNAL(clicked()), SLOT(addWordList()));
|
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->sliderLength, SIGNAL(valueChanged(int)), SLOT(passwordLengthChanged(int)));
|
||||||
connect(m_ui->spinBoxLength, 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)
|
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();
|
emit closed();
|
||||||
QWidget::closeEvent(event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PasswordGeneratorWidget* PasswordGeneratorWidget::popupGenerator(QWidget* parent)
|
PasswordGeneratorWidget* PasswordGeneratorWidget::popupGenerator(QWidget* parent)
|
||||||
@ -325,10 +341,12 @@ void PasswordGeneratorWidget::updatePasswordLengthLabel(const QString& password)
|
|||||||
|
|
||||||
void PasswordGeneratorWidget::applyPassword()
|
void PasswordGeneratorWidget::applyPassword()
|
||||||
{
|
{
|
||||||
saveSettings();
|
if (!m_standalone) {
|
||||||
m_passwordGenerated = true;
|
saveSettings();
|
||||||
emit appliedPassword(m_ui->editNewPassword->text());
|
m_passwordGenerated = true;
|
||||||
emit closed();
|
emit appliedPassword(m_ui->editNewPassword->text());
|
||||||
|
emit closed();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PasswordGeneratorWidget::copyPassword()
|
void PasswordGeneratorWidget::copyPassword()
|
||||||
|
@ -69,6 +69,7 @@ public slots:
|
|||||||
void setPasswordVisible(bool visible);
|
void setPasswordVisible(bool visible);
|
||||||
void deleteWordList();
|
void deleteWordList();
|
||||||
void addWordList();
|
void addWordList();
|
||||||
|
void confirmClose();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void closeEvent(QCloseEvent* event) override;
|
void closeEvent(QCloseEvent* event) override;
|
||||||
|
Loading…
Reference in New Issue
Block a user