diff --git a/src/browser/BrowserService.cpp b/src/browser/BrowserService.cpp index c2198faf2..5e1173df4 100644 --- a/src/browser/BrowserService.cpp +++ b/src/browser/BrowserService.cpp @@ -321,7 +321,7 @@ QString BrowserService::storeKey(const QString& key) do { QInputDialog keyDialog; - connect(m_currentDatabaseWidget, SIGNAL(databaseLocked()), &keyDialog, SLOT(reject())); + connect(m_currentDatabaseWidget, SIGNAL(databaseLockRequested()), &keyDialog, SLOT(reject())); keyDialog.setWindowTitle(tr("KeePassXC: New key association request")); keyDialog.setLabelText(tr("You have received an association request for the following database:\n%1\n\n" "Give the connection a unique name or ID, for example:\nchrome-laptop.") @@ -772,7 +772,7 @@ QList BrowserService::confirmEntries(QList& pwEntriesToConfirm, updateWindowState(); BrowserAccessControlDialog accessControlDialog; - connect(m_currentDatabaseWidget, SIGNAL(databaseLocked()), &accessControlDialog, SLOT(reject())); + connect(m_currentDatabaseWidget, SIGNAL(databaseLockRequested()), &accessControlDialog, SLOT(reject())); connect(&accessControlDialog, &BrowserAccessControlDialog::disableAccess, [&](QTableWidgetItem* item) { auto entry = pwEntriesToConfirm[item->row()]; diff --git a/src/gui/DatabaseWidget.cpp b/src/gui/DatabaseWidget.cpp index 505e7f0ba..3846db76b 100644 --- a/src/gui/DatabaseWidget.cpp +++ b/src/gui/DatabaseWidget.cpp @@ -216,7 +216,7 @@ DatabaseWidget::DatabaseWidget(QSharedPointer db, QWidget* parent) #ifdef WITH_XC_SSHAGENT if (sshAgent()->isEnabled()) { - connect(this, SIGNAL(databaseLockRequested()), sshAgent(), SLOT(databaseLocked())); + connect(this, SIGNAL(databaseLocked()), sshAgent(), SLOT(databaseLocked())); connect(this, SIGNAL(databaseUnlocked()), sshAgent(), SLOT(databaseUnlocked())); } #endif @@ -437,6 +437,7 @@ void DatabaseWidget::showTotp() } auto totpDialog = new TotpDialog(this, currentEntry); + connect(this, &DatabaseWidget::databaseLockRequested, totpDialog, &TotpDialog::close); totpDialog->open(); } @@ -460,6 +461,7 @@ void DatabaseWidget::setupTotp() auto setupTotpDialog = new TotpSetupDialog(this, currentEntry); connect(setupTotpDialog, SIGNAL(totpUpdated()), SIGNAL(entrySelectionChanged())); + connect(this, &DatabaseWidget::databaseLockRequested, setupTotpDialog, &TotpSetupDialog::close); setupTotpDialog->open(); } @@ -701,6 +703,7 @@ void DatabaseWidget::showTotpKeyQrCode() auto currentEntry = currentSelectedEntry(); if (currentEntry) { auto totpDisplayDialog = new TotpExportSettingsDialog(this, currentEntry); + connect(this, &DatabaseWidget::databaseLockRequested, totpDisplayDialog, &TotpExportSettingsDialog::close); totpDisplayDialog->open(); } } @@ -1528,6 +1531,11 @@ bool DatabaseWidget::lock() emit databaseLockRequested(); + // ignore event if we are active and a modal dialog is still open (such as a message box or file dialog) + if (isVisible() && QApplication::activeModalWidget()) { + return false; + } + clipboard()->clearCopiedText(); if (isEditWidgetModified()) { diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index cbfc1b077..aa6205e15 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -1536,11 +1536,6 @@ void MainWindow::toggleWindow() void MainWindow::lockDatabasesAfterInactivity() { - // ignore event if a modal dialog is open (such as a message box or file dialog) - if (QApplication::activeModalWidget()) { - return; - } - m_ui->tabWidget->lockDatabases(); } diff --git a/src/gui/TotpDialog.cpp b/src/gui/TotpDialog.cpp index 871c2863c..c348b3f27 100644 --- a/src/gui/TotpDialog.cpp +++ b/src/gui/TotpDialog.cpp @@ -31,10 +31,7 @@ TotpDialog::TotpDialog(QWidget* parent, Entry* entry) , m_ui(new Ui::TotpDialog()) , m_entry(entry) { - if (!m_entry->hasTotp()) { - close(); - return; - } + setAttribute(Qt::WA_DeleteOnClose); m_ui->setupUi(this); @@ -42,14 +39,11 @@ TotpDialog::TotpDialog(QWidget* parent, Entry* entry) resetCounter(); updateProgressBar(); - connect(parent, SIGNAL(databaseLocked()), SLOT(close())); connect(&m_totpUpdateTimer, SIGNAL(timeout()), this, SLOT(updateProgressBar())); connect(&m_totpUpdateTimer, SIGNAL(timeout()), this, SLOT(updateSeconds())); m_totpUpdateTimer.start(m_step * 10); updateTotp(); - setAttribute(Qt::WA_DeleteOnClose); - new QShortcut(QKeySequence(QKeySequence::Copy), this, SLOT(copyToClipboard())); m_ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Copy")); diff --git a/src/gui/TotpExportSettingsDialog.cpp b/src/gui/TotpExportSettingsDialog.cpp index f73b9877a..cee9fc824 100644 --- a/src/gui/TotpExportSettingsDialog.cpp +++ b/src/gui/TotpExportSettingsDialog.cpp @@ -59,7 +59,6 @@ TotpExportSettingsDialog::TotpExportSettingsDialog(DatabaseWidget* parent, Entry connect(m_buttonBox, SIGNAL(rejected()), SLOT(close())); connect(m_buttonBox, SIGNAL(accepted()), SLOT(copyToClipboard())); connect(m_timer, SIGNAL(timeout()), SLOT(autoClose())); - connect(parent, SIGNAL(lockedDatabase()), SLOT(close())); new QShortcut(QKeySequence(QKeySequence::Copy), this, SLOT(copyToClipboard()));