diff --git a/src/gui/DatabaseOpenWidget.cpp b/src/gui/DatabaseOpenWidget.cpp index 3b6eb4f3f9..cdf3912bd6 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(closeDatabase())); connect(m_ui->addKeyFileLinkLabel, &QLabel::linkActivated, this, &DatabaseOpenWidget::browseKeyFile); connect(m_ui->keyFileLineEdit, &PasswordWidget::textChanged, this, [&](const QString& text) { @@ -448,6 +448,16 @@ QSharedPointer 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); diff --git a/src/gui/DatabaseOpenWidget.h b/src/gui/DatabaseOpenWidget.h index f75e118de0..f31278e270 100644 --- a/src/gui/DatabaseOpenWidget.h +++ b/src/gui/DatabaseOpenWidget.h @@ -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); @@ -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;