Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 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(closeDatabase()));

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,16 @@ QSharedPointer<CompositeKey> DatabaseOpenWidget::buildDatabaseKey()
return databaseKey;
}

void DatabaseOpenWidget::closeDatabase()
{
if (m_escPressedOnce) {
reject();
} else {
m_escPressedOnce = true;
m_ui->messageWidget->showMessage(tr("Press ESC again to close this database."), MessageWidget::Information);
}
}

void DatabaseOpenWidget::reject()
{
emit dialogFinished(false);
Expand Down
4 changes: 3 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 closeDatabase();
void reject();
void toggleHardwareKeyComponent(bool state);
void pollHardwareKey(bool manualTrigger = false);
void hardwareKeyResponse(bool found);
Expand All @@ -90,6 +91,7 @@ private slots:
bool m_manualHardwareKeyRefresh = false;
bool m_blockQuickUnlock = false;
bool m_unlockingDatabase = false;
bool m_escPressedOnce = false;
QTimer m_hideTimer;
QTimer m_hideNoHardwareKeysFoundTimer;

Expand Down