Fix new password generator closed reply with Browser Integration (#7359)

This commit is contained in:
Sami Vänttinen 2022-01-30 17:59:29 +02:00 committed by Jonathan White
parent 4f0710350f
commit 6791024995
No known key found for this signature in database
GPG Key ID: 440FC65F2E0C6E01
3 changed files with 15 additions and 4 deletions

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (C) 2013 Francois Ferrand * Copyright (C) 2013 Francois Ferrand
* Copyright (C) 2017 Sami Vänttinen <sami.vanttinen@protonmail.com> * Copyright (C) 2017 Sami Vänttinen <sami.vanttinen@protonmail.com>
* Copyright (C) 2021 KeePassXC Team <team@keepassxc.org> * Copyright (C) 2022 KeePassXC Team <team@keepassxc.org>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -317,8 +317,11 @@ void BrowserService::showPasswordGenerator(const QJsonObject& errorMessage, cons
m_passwordGenerator.reset(PasswordGeneratorWidget::popupGenerator()); m_passwordGenerator.reset(PasswordGeneratorWidget::popupGenerator());
connect(m_passwordGenerator.data(), &PasswordGeneratorWidget::closed, m_passwordGenerator.data(), [=] { connect(m_passwordGenerator.data(), &PasswordGeneratorWidget::closed, m_passwordGenerator.data(), [=] {
if (!m_passwordGenerator->isPasswordGenerated()) {
m_browserHost->sendClientMessage(errorMessage);
}
m_passwordGenerator.reset(); m_passwordGenerator.reset();
m_browserHost->sendClientMessage(errorMessage);
hideWindow(); hideWindow();
}); });

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (C) 2013 Felix Geyer <debfx@fobos.de> * Copyright (C) 2013 Felix Geyer <debfx@fobos.de>
* Copyright (C) 2021 KeePassXC Team <team@keepassxc.org> * Copyright (C) 2022 KeePassXC Team <team@keepassxc.org>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -294,6 +294,7 @@ void PasswordGeneratorWidget::updatePasswordStrength(const QString& password)
void PasswordGeneratorWidget::applyPassword() void PasswordGeneratorWidget::applyPassword()
{ {
saveSettings(); saveSettings();
m_passwordGenerated = true;
emit appliedPassword(m_ui->editNewPassword->text()); emit appliedPassword(m_ui->editNewPassword->text());
emit closed(); emit closed();
} }
@ -341,6 +342,11 @@ bool PasswordGeneratorWidget::isPasswordVisible() const
return m_ui->editNewPassword->isPasswordVisible(); return m_ui->editNewPassword->isPasswordVisible();
} }
bool PasswordGeneratorWidget::isPasswordGenerated() const
{
return m_passwordGenerated;
}
void PasswordGeneratorWidget::deleteWordList() void PasswordGeneratorWidget::deleteWordList()
{ {
if (m_ui->comboBoxWordList->currentIndex() < m_firstCustomWordlistIndex) { if (m_ui->comboBoxWordList->currentIndex() < m_firstCustomWordlistIndex) {

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (C) 2013 Felix Geyer <debfx@fobos.de> * Copyright (C) 2013 Felix Geyer <debfx@fobos.de>
* Copyright (C) 2021 KeePassXC Team <team@keepassxc.org> * Copyright (C) 2022 KeePassXC Team <team@keepassxc.org>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -53,6 +53,7 @@ public:
void setStandaloneMode(bool standalone); void setStandaloneMode(bool standalone);
QString getGeneratedPassword(); QString getGeneratedPassword();
bool isPasswordVisible() const; bool isPasswordVisible() const;
bool isPasswordGenerated() const;
static PasswordGeneratorWidget* popupGenerator(QWidget* parent = nullptr); static PasswordGeneratorWidget* popupGenerator(QWidget* parent = nullptr);
@ -82,6 +83,7 @@ private slots:
private: private:
bool m_standalone = false; bool m_standalone = false;
bool m_passwordGenerated = false;
int m_firstCustomWordlistIndex; int m_firstCustomWordlistIndex;
void closeEvent(QCloseEvent* event); void closeEvent(QCloseEvent* event);