From 33ddbbd0ff369d8f807a2926b2cb6b970e66ba15 Mon Sep 17 00:00:00 2001 From: WinnetouL <50875993+WinnetouL@users.noreply.github.com> Date: Tue, 3 Sep 2024 17:34:56 +0200 Subject: [PATCH] Replace popup with general message which appears on first ESC or close call (#11199) --- src/gui/DatabaseOpenWidget.cpp | 14 ++++++-------- src/gui/DatabaseOpenWidget.h | 3 ++- 2 files changed, 8 insertions(+), 9 deletions(-) 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;