Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/keepassxreboot/keepassxc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorJonathan White <support@dmapps.us>2020-12-12 20:08:02 +0300
committerJonathan White <support@dmapps.us>2020-12-12 20:31:43 +0300
commitf0204dbb109a8fbaf739c35b9c459d247bdccd88 (patch)
treecc62b8c0a1fef9c7a8b440bbcab57a99e852493c /src/gui
parent3b29f20d60f8fa00581c8c19a2e43e420d7a5d09 (diff)
Fix closing modal dialogs on database lock
* Fixes #5719, Fixes #5744
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/DatabaseWidget.cpp10
-rw-r--r--src/gui/MainWindow.cpp5
-rw-r--r--src/gui/TotpDialog.cpp8
-rw-r--r--src/gui/TotpExportSettingsDialog.cpp1
4 files changed, 10 insertions, 14 deletions
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<Database> 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()));