0
0
mirror of https://github.com/keepassxreboot/keepassxc.git synced 2024-09-19 20:02:18 +02:00

Fix issues with locking database

* Fix #6593 - force close any modal dialogs associated with a database widget that is being locked.

* Partial fix for #721 but doesn't address the problem of needing to save a modified entry or database while locking.

* Also improves import dialog behavior if databases(s) lock while it is visible.
This commit is contained in:
Jonathan White 2024-05-05 09:46:03 -04:00
parent 6b62beab6e
commit bd449f3226
3 changed files with 25 additions and 4 deletions

View File

@ -1755,9 +1755,17 @@ 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;
// Force close any modal widgets associated with this widget
auto modalWidget = QApplication::activeModalWidget();
if (modalWidget) {
auto parent = modalWidget->parentWidget();
while (parent) {
if (parent == this) {
modalWidget->close();
break;
}
parent = parent->parentWidget();
}
}
clipboard()->clearCopiedText();

View File

@ -1821,7 +1821,9 @@ void MainWindow::closeModalWindow()
void MainWindow::lockDatabasesAfterInactivity()
{
m_ui->tabWidget->lockDatabases();
if (!m_ui->tabWidget->lockDatabases()) {
m_inactivityTimer->activate();
}
}
bool MainWindow::isTrayIconEnabled() const

View File

@ -126,11 +126,17 @@ void ImportWizardPageSelect::updateDatabaseChoices() const
auto mainWindow = getMainWindow();
if (mainWindow) {
for (auto dbWidget : mainWindow->getOpenDatabases()) {
// Remove all connections
disconnect(dbWidget, nullptr, nullptr, nullptr);
// Skip over locked databases
if (dbWidget->isLocked()) {
continue;
}
connect(dbWidget, &DatabaseWidget::databaseLocked, this, &ImportWizardPageSelect::updateDatabaseChoices);
connect(dbWidget, &DatabaseWidget::databaseModified, this, &ImportWizardPageSelect::updateDatabaseChoices);
// Enable the selection of an existing database
m_ui->existingDatabaseRadio->setEnabled(true);
m_ui->existingDatabaseRadio->setToolTip("");
@ -161,6 +167,11 @@ void ImportWizardPageSelect::updateDatabaseChoices() const
}
}
}
if (m_ui->existingDatabaseChoice->count() == 0) {
m_ui->existingDatabaseRadio->setEnabled(false);
m_ui->newDatabaseRadio->setChecked(true);
}
}
void ImportWizardPageSelect::chooseImportFile()