From 69fad1e3da8cfeea98cb2d05605636a5d93b8c1d Mon Sep 17 00:00:00 2001 From: WinnetouL <50875993+WinnetouL@users.noreply.github.com> Date: Sun, 1 Sep 2024 13:28:27 +0200 Subject: [PATCH] Prevent user from leaving unlock window by hitting ESC (#11199) --- src/gui/DatabaseOpenWidget.cpp | 14 +++++++++++++- src/gui/DatabaseOpenWidget.h | 3 ++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/gui/DatabaseOpenWidget.cpp b/src/gui/DatabaseOpenWidget.cpp index 3b6eb4f3f..3393f25e2 100644 --- a/src/gui/DatabaseOpenWidget.cpp +++ b/src/gui/DatabaseOpenWidget.cpp @@ -85,7 +85,7 @@ DatabaseOpenWidget::DatabaseOpenWidget(QWidget* parent) okBtn->setText(tr("Unlock")); okBtn->setDefault(true); connect(m_ui->buttonBox, SIGNAL(accepted()), SLOT(openDatabase())); - connect(m_ui->buttonBox, SIGNAL(rejected()), SLOT(reject())); + connect(m_ui->buttonBox, SIGNAL(rejected()), SLOT(cancelDatabaseUnlock())); connect(m_ui->addKeyFileLinkLabel, &QLabel::linkActivated, this, &DatabaseOpenWidget::browseKeyFile); connect(m_ui->keyFileLineEdit, &PasswordWidget::textChanged, this, [&](const QString& text) { @@ -448,6 +448,18 @@ QSharedPointer DatabaseOpenWidget::buildDatabaseKey() return databaseKey; } +void DatabaseOpenWidget::cancelDatabaseUnlock() +{ + auto result = MessageBox::question(this, + tr("Cancel Database Unlock"), + tr("Would you like to cancel unlocking this database?"), + MessageBox::Cancel | MessageBox::Ok, + MessageBox::Cancel); + if (result == MessageBox::Ok) { + reject(); + } +} + void DatabaseOpenWidget::reject() { emit dialogFinished(false); diff --git a/src/gui/DatabaseOpenWidget.h b/src/gui/DatabaseOpenWidget.h index f75e118de..58ffb7ddd 100644 --- a/src/gui/DatabaseOpenWidget.h +++ b/src/gui/DatabaseOpenWidget.h @@ -74,10 +74,11 @@ protected: protected slots: virtual void openDatabase(); - void reject(); private slots: bool browseKeyFile(); + void cancelDatabaseUnlock(); + void reject(); void toggleHardwareKeyComponent(bool state); void pollHardwareKey(bool manualTrigger = false); void hardwareKeyResponse(bool found);