Browser: Fix cancel with database unlock dialog (#11435)

This commit is contained in:
Sami Vänttinen 2024-11-11 00:30:38 +02:00 committed by GitHub
parent bff0b93f5f
commit 2fc24be331
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 23 additions and 1 deletions

View File

@ -86,6 +86,10 @@ BrowserService::BrowserService()
connect(getMainWindow(), &MainWindow::databaseUnlocked, this, &BrowserService::databaseUnlocked);
connect(getMainWindow(), &MainWindow::databaseLocked, this, &BrowserService::databaseLocked);
connect(getMainWindow(), &MainWindow::activeDatabaseChanged, this, &BrowserService::activeDatabaseChanged);
connect(getMainWindow(),
&MainWindow::databaseUnlockDialogFinished,
this,
&BrowserService::handleDatabaseUnlockDialogFinished);
setEnabled(browserSettings()->isEnabled());
}
@ -1678,6 +1682,15 @@ void BrowserService::activeDatabaseChanged(DatabaseWidget* dbWidget)
m_currentDatabaseWidget = dbWidget;
}
void BrowserService::handleDatabaseUnlockDialogFinished(bool accepted, DatabaseWidget* dbWidget)
{
// User canceled the database open dialog
if (dbWidget && !accepted && m_bringToFrontRequested) {
m_bringToFrontRequested = false;
hideWindow();
}
}
void BrowserService::processClientMessage(QLocalSocket* socket, const QJsonObject& message)
{
auto clientID = message["clientID"].toString();

View File

@ -145,6 +145,7 @@ public slots:
private slots:
void processClientMessage(QLocalSocket* socket, const QJsonObject& message);
void handleDatabaseUnlockDialogFinished(bool accepted, DatabaseWidget* dbWidget);
private:
enum Access

View File

@ -821,6 +821,9 @@ void DatabaseTabWidget::handleDatabaseUnlockDialogFinished(bool accepted, Databa
m_dbWidgetPendingLock = dbWidget;
}
// If browser extension requested the unlock make sure cancel is handled
m_databaseOpenInProgress = false;
// signal other objects that the dialog finished
emit databaseUnlockDialogFinished(accepted, dbWidget);
}

View File

@ -192,6 +192,10 @@ MainWindow::MainWindow()
connect(m_ui->tabWidget, &DatabaseTabWidget::databaseLocked, this, &MainWindow::databaseLocked);
connect(m_ui->tabWidget, &DatabaseTabWidget::databaseUnlocked, this, &MainWindow::databaseUnlocked);
connect(m_ui->tabWidget, &DatabaseTabWidget::activeDatabaseChanged, this, &MainWindow::activeDatabaseChanged);
connect(m_ui->tabWidget,
&DatabaseTabWidget::databaseUnlockDialogFinished,
this,
&MainWindow::databaseUnlockDialogFinished);
initViewMenu();
initActionCollection();

View File

@ -1,6 +1,6 @@
/*
* Copyright (C) 2024 KeePassXC Team <team@keepassxc.org>
* Copyright (C) 2010 Felix Geyer <debfx@fobos.de>
* Copyright (C) 2020 KeePassXC Team <team@keepassxc.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -67,6 +67,7 @@ signals:
void databaseUnlocked(DatabaseWidget* dbWidget);
void databaseLocked(DatabaseWidget* dbWidget);
void activeDatabaseChanged(DatabaseWidget* dbWidget);
void databaseUnlockDialogFinished(bool accepted, DatabaseWidget* dbWidget);
public slots:
void openDatabase(const QString& filePath, const QString& password = {}, const QString& keyfile = {});