Skip to content

Commit

Permalink
Prevent user from leaving unlock window by hitting ESC (keepassxreboo…
Browse files Browse the repository at this point in the history
  • Loading branch information
WinnetouL committed Sep 1, 2024
1 parent 48d0f2b commit 69fad1e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
14 changes: 13 additions & 1 deletion src/gui/DatabaseOpenWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion src/gui/DatabaseOpenWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,11 @@ class DatabaseOpenWidget : public DialogyWidget

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);
Expand Down

0 comments on commit 69fad1e

Please sign in to comment.