diff --git a/src/gui/DatabaseOpenWidget.cpp b/src/gui/DatabaseOpenWidget.cpp index 3393f25e2..cdf3912bd 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(cancelDatabaseUnlock())); + 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,15 +448,13 @@ QSharedPointer DatabaseOpenWidget::buildDatabaseKey() return databaseKey; } -void DatabaseOpenWidget::cancelDatabaseUnlock() +void DatabaseOpenWidget::closeDatabase() { - 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) { + if (m_escPressedOnce) { reject(); + } else { + m_escPressedOnce = true; + m_ui->messageWidget->showMessage(tr("Press ESC again to close this database."), MessageWidget::Information); } } diff --git a/src/gui/DatabaseOpenWidget.h b/src/gui/DatabaseOpenWidget.h index 58ffb7ddd..f31278e27 100644 --- a/src/gui/DatabaseOpenWidget.h +++ b/src/gui/DatabaseOpenWidget.h @@ -77,7 +77,7 @@ protected slots: private slots: bool browseKeyFile(); - void cancelDatabaseUnlock(); + void closeDatabase(); void reject(); void toggleHardwareKeyComponent(bool state); void pollHardwareKey(bool manualTrigger = false); @@ -91,6 +91,7 @@ private: bool m_manualHardwareKeyRefresh = false; bool m_blockQuickUnlock = false; bool m_unlockingDatabase = false; + bool m_escPressedOnce = false; QTimer m_hideTimer; QTimer m_hideNoHardwareKeysFoundTimer;