Add setting for not displaying KeePassHTTP migration popup

This commit is contained in:
varjolintu 2019-07-02 11:55:15 +03:00 committed by Jonathan White
parent d12f15da92
commit c27ee6aba8
7 changed files with 65 additions and 16 deletions

View File

@ -116,6 +116,7 @@ void BrowserOptionDialog::loadSettings()
m_ui->httpAuthPermission->setChecked(settings->httpAuthPermission());
m_ui->searchInAllDatabases->setChecked(settings->searchInAllDatabases());
m_ui->supportKphFields->setChecked(settings->supportKphFields());
m_ui->noMigrationPrompt->setChecked(settings->noMigrationPrompt());
m_ui->supportBrowserProxy->setChecked(settings->supportBrowserProxy());
m_ui->useCustomProxy->setChecked(settings->useCustomProxy());
m_ui->customProxyLocation->setText(settings->customProxyLocation());
@ -183,6 +184,7 @@ void BrowserOptionDialog::saveSettings()
settings->setHttpAuthPermission(m_ui->httpAuthPermission->isChecked());
settings->setSearchInAllDatabases(m_ui->searchInAllDatabases->isChecked());
settings->setSupportKphFields(m_ui->supportKphFields->isChecked());
settings->setNoMigrationPrompt(m_ui->noMigrationPrompt->isChecked());
settings->setChromeSupport(m_ui->chromeSupport->isChecked());
settings->setChromiumSupport(m_ui->chromiumSupport->isChecked());

View File

@ -321,6 +321,16 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="noMigrationPrompt">
<property name="toolTip">
<string>Don't display the popup suggesting migration of legacy KeePassHTTP settings.</string>
</property>
<property name="text">
<string>&amp;Do not prompt for KeePassHTTP settings migration.</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="updateBinaryPath">
<property name="toolTip">

View File

@ -22,6 +22,7 @@
#include <QMessageBox>
#include <QProgressDialog>
#include <QUuid>
#include <QCheckBox>
#include "BrowserAccessControlDialog.h"
#include "BrowserEntryConfig.h"
@ -1070,7 +1071,7 @@ int BrowserService::moveKeysToCustomData(Entry* entry, const QSharedPointer<Data
bool BrowserService::checkLegacySettings()
{
if (!browserSettings()->isEnabled()) {
if (!browserSettings()->isEnabled() || browserSettings()->noMigrationPrompt()) {
return false;
}
@ -1093,13 +1094,21 @@ bool BrowserService::checkLegacySettings()
return false;
}
auto* checkbox = new QCheckBox(tr("Don't show this warning again"));
QObject::connect(checkbox, &QCheckBox::stateChanged, [&](int state) {
browserSettings()->setNoMigrationPrompt(static_cast<Qt::CheckState>(state) == Qt::CheckState::Checked);
});
auto dialogResult =
MessageBox::warning(nullptr,
tr("KeePassXC: Legacy browser integration settings detected"),
tr("Your KeePassXC-Browser settings need to be moved into the database settings.\n"
"This is necessary to maintain your current browser connections.\n"
"Would you like to migrate your existing settings now?"),
MessageBox::Yes | MessageBox::No);
MessageBox::Yes | MessageBox::No,
MessageBox::NoButton,
MessageBox::Raise,
checkbox);
return dialogResult == MessageBox::Yes;
}

View File

@ -151,6 +151,16 @@ void BrowserSettings::setSupportKphFields(bool supportKphFields)
config()->set("Browser/SupportKphFields", supportKphFields);
}
bool BrowserSettings::noMigrationPrompt()
{
return config()->get("Browser/NoMigrationPrompt", false).toBool();
}
void BrowserSettings::setNoMigrationPrompt(bool prompt)
{
config()->set("Browser/NoMigrationPrompt", prompt);
}
bool BrowserSettings::supportBrowserProxy()
{
return config()->get("Browser/SupportBrowserProxy", true).toBool();

View File

@ -55,6 +55,8 @@ public:
void setHttpAuthPermission(bool httpAuthPermission);
bool supportKphFields();
void setSupportKphFields(bool supportKphFields);
bool noMigrationPrompt();
void setNoMigrationPrompt(bool prompt);
bool supportBrowserProxy();
void setSupportBrowserProxy(bool enabled);

View File

@ -19,6 +19,7 @@
#include "MessageBox.h"
#include <QWindow>
#include <QCheckBox>
QWindow* MessageBox::m_overrideParent(nullptr);
@ -77,7 +78,8 @@ MessageBox::Button MessageBox::messageBox(QWidget* parent,
const QString& text,
MessageBox::Buttons buttons,
MessageBox::Button defaultButton,
MessageBox::Action action)
MessageBox::Action action,
QCheckBox* checkbox)
{
if (m_nextAnswer == MessageBox::NoButton) {
QMessageBox msgBox(parent);
@ -110,6 +112,11 @@ MessageBox::Button MessageBox::messageBox(QWidget* parent,
}
}
if (checkbox) {
checkbox->setParent(&msgBox);
msgBox.setCheckBox(checkbox);
}
if (action == MessageBox::Raise) {
msgBox.setWindowFlags(Qt::WindowStaysOnTopHint);
msgBox.activateWindow();
@ -133,9 +140,10 @@ MessageBox::Button MessageBox::critical(QWidget* parent,
const QString& text,
MessageBox::Buttons buttons,
MessageBox::Button defaultButton,
MessageBox::Action action)
MessageBox::Action action,
QCheckBox* checkbox)
{
return messageBox(parent, QMessageBox::Critical, title, text, buttons, defaultButton, action);
return messageBox(parent, QMessageBox::Critical, title, text, buttons, defaultButton, action, checkbox);
}
MessageBox::Button MessageBox::information(QWidget* parent,
@ -143,9 +151,10 @@ MessageBox::Button MessageBox::information(QWidget* parent,
const QString& text,
MessageBox::Buttons buttons,
MessageBox::Button defaultButton,
MessageBox::Action action)
MessageBox::Action action,
QCheckBox* checkbox)
{
return messageBox(parent, QMessageBox::Information, title, text, buttons, defaultButton, action);
return messageBox(parent, QMessageBox::Information, title, text, buttons, defaultButton, action, checkbox);
}
MessageBox::Button MessageBox::question(QWidget* parent,
@ -153,9 +162,10 @@ MessageBox::Button MessageBox::question(QWidget* parent,
const QString& text,
MessageBox::Buttons buttons,
MessageBox::Button defaultButton,
MessageBox::Action action)
MessageBox::Action action,
QCheckBox* checkbox)
{
return messageBox(parent, QMessageBox::Question, title, text, buttons, defaultButton, action);
return messageBox(parent, QMessageBox::Question, title, text, buttons, defaultButton, action, checkbox);
}
MessageBox::Button MessageBox::warning(QWidget* parent,
@ -163,9 +173,10 @@ MessageBox::Button MessageBox::warning(QWidget* parent,
const QString& text,
MessageBox::Buttons buttons,
MessageBox::Button defaultButton,
MessageBox::Action action)
MessageBox::Action action,
QCheckBox* checkbox)
{
return messageBox(parent, QMessageBox::Warning, title, text, buttons, defaultButton, action);
return messageBox(parent, QMessageBox::Warning, title, text, buttons, defaultButton, action, checkbox);
}
void MessageBox::setNextAnswer(MessageBox::Button button)

View File

@ -81,25 +81,29 @@ public:
const QString& text,
Buttons buttons = MessageBox::Ok,
Button defaultButton = MessageBox::NoButton,
Action action = MessageBox::None);
Action action = MessageBox::None,
QCheckBox* checkbox = nullptr);
static Button information(QWidget* parent,
const QString& title,
const QString& text,
Buttons buttons = MessageBox::Ok,
Button defaultButton = MessageBox::NoButton,
Action action = MessageBox::None);
Action action = MessageBox::None,
QCheckBox* checkbox = nullptr);
static Button question(QWidget* parent,
const QString& title,
const QString& text,
Buttons buttons = MessageBox::Ok,
Button defaultButton = MessageBox::NoButton,
Action action = MessageBox::None);
Action action = MessageBox::None,
QCheckBox* checkbox = nullptr);
static Button warning(QWidget* parent,
const QString& title,
const QString& text,
Buttons buttons = MessageBox::Ok,
Button defaultButton = MessageBox::NoButton,
Action action = MessageBox::None);
Action action = MessageBox::None,
QCheckBox* checkbox = nullptr);
class OverrideParent
{
@ -123,7 +127,8 @@ private:
const QString& text,
Buttons buttons = MessageBox::Ok,
Button defaultButton = MessageBox::NoButton,
Action action = MessageBox::None);
Action action = MessageBox::None,
QCheckBox* checkbox = nullptr);
static QString stdButtonText(QMessageBox::StandardButton button);
};