Prevent user from leaving unlock window by hitting ESC (#11199)

This commit is contained in:
WinnetouL 2024-09-01 13:28:27 +02:00
parent 48d0f2b159
commit 69fad1e3da
2 changed files with 15 additions and 2 deletions

View File

@ -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<CompositeKey> 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);

View File

@ -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);