Replace popup with general message which appears on first ESC or close call (#11199)

This commit is contained in:
WinnetouL 2024-09-03 17:34:56 +02:00
parent 69fad1e3da
commit 33ddbbd0ff
2 changed files with 8 additions and 9 deletions

View File

@ -85,7 +85,7 @@ DatabaseOpenWidget::DatabaseOpenWidget(QWidget* parent)
okBtn->setText(tr("Unlock")); okBtn->setText(tr("Unlock"));
okBtn->setDefault(true); okBtn->setDefault(true);
connect(m_ui->buttonBox, SIGNAL(accepted()), SLOT(openDatabase())); 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->addKeyFileLinkLabel, &QLabel::linkActivated, this, &DatabaseOpenWidget::browseKeyFile);
connect(m_ui->keyFileLineEdit, &PasswordWidget::textChanged, this, [&](const QString& text) { connect(m_ui->keyFileLineEdit, &PasswordWidget::textChanged, this, [&](const QString& text) {
@ -448,15 +448,13 @@ QSharedPointer<CompositeKey> DatabaseOpenWidget::buildDatabaseKey()
return databaseKey; return databaseKey;
} }
void DatabaseOpenWidget::cancelDatabaseUnlock() void DatabaseOpenWidget::closeDatabase()
{ {
auto result = MessageBox::question(this, if (m_escPressedOnce) {
tr("Cancel Database Unlock"),
tr("Would you like to cancel unlocking this database?"),
MessageBox::Cancel | MessageBox::Ok,
MessageBox::Cancel);
if (result == MessageBox::Ok) {
reject(); reject();
} else {
m_escPressedOnce = true;
m_ui->messageWidget->showMessage(tr("Press ESC again to close this database."), MessageWidget::Information);
} }
} }

View File

@ -77,7 +77,7 @@ protected slots:
private slots: private slots:
bool browseKeyFile(); bool browseKeyFile();
void cancelDatabaseUnlock(); void closeDatabase();
void reject(); void reject();
void toggleHardwareKeyComponent(bool state); void toggleHardwareKeyComponent(bool state);
void pollHardwareKey(bool manualTrigger = false); void pollHardwareKey(bool manualTrigger = false);
@ -91,6 +91,7 @@ private:
bool m_manualHardwareKeyRefresh = false; bool m_manualHardwareKeyRefresh = false;
bool m_blockQuickUnlock = false; bool m_blockQuickUnlock = false;
bool m_unlockingDatabase = false; bool m_unlockingDatabase = false;
bool m_escPressedOnce = false;
QTimer m_hideTimer; QTimer m_hideTimer;
QTimer m_hideNoHardwareKeysFoundTimer; QTimer m_hideNoHardwareKeysFoundTimer;