mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-08-19 19:48:36 -04:00
FdoSecrets: only emit completed signal when the action actually finishes
This commit is contained in:
parent
af14929af1
commit
adb29dd0e4
10 changed files with 71 additions and 15 deletions
|
@ -49,6 +49,14 @@ namespace FdoSecrets
|
||||||
connect(backend, &DatabaseWidget::databaseUnlocked, this, &Collection::onDatabaseLockChanged);
|
connect(backend, &DatabaseWidget::databaseUnlocked, this, &Collection::onDatabaseLockChanged);
|
||||||
connect(backend, &DatabaseWidget::databaseLocked, this, &Collection::onDatabaseLockChanged);
|
connect(backend, &DatabaseWidget::databaseLocked, this, &Collection::onDatabaseLockChanged);
|
||||||
|
|
||||||
|
// get notified whenever unlock db dialog finishes
|
||||||
|
connect(parent, &Service::doneUnlockDatabaseInDialog, this, [this](bool accepted, DatabaseWidget* dbWidget) {
|
||||||
|
if (!dbWidget || dbWidget != m_backend) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
emit doneUnlockCollection(accepted);
|
||||||
|
});
|
||||||
|
|
||||||
reloadBackend();
|
reloadBackend();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,6 +71,8 @@ namespace FdoSecrets
|
||||||
void aliasAdded(const QString& alias);
|
void aliasAdded(const QString& alias);
|
||||||
void aliasRemoved(const QString& alias);
|
void aliasRemoved(const QString& alias);
|
||||||
|
|
||||||
|
void doneUnlockCollection(bool accepted);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DBusReturn<void> setProperties(const QVariantMap& properties);
|
DBusReturn<void> setProperties(const QVariantMap& properties);
|
||||||
|
|
||||||
|
|
|
@ -93,9 +93,9 @@ namespace FdoSecrets
|
||||||
|
|
||||||
MessageBox::OverrideParent override(findWindow(windowId));
|
MessageBox::OverrideParent override(findWindow(windowId));
|
||||||
// only need to delete in backend, collection will react itself.
|
// only need to delete in backend, collection will react itself.
|
||||||
service()->doCloseDatabase(m_collection->backend());
|
auto accepted = service()->doCloseDatabase(m_collection->backend());
|
||||||
|
|
||||||
emit completed(false, {});
|
emit completed(!accepted, {});
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -189,19 +189,44 @@ namespace FdoSecrets
|
||||||
|
|
||||||
MessageBox::OverrideParent override(findWindow(windowId));
|
MessageBox::OverrideParent override(findWindow(windowId));
|
||||||
|
|
||||||
QList<QDBusObjectPath> unlocked;
|
|
||||||
for (const auto& c : asConst(m_collections)) {
|
for (const auto& c : asConst(m_collections)) {
|
||||||
if (c) {
|
if (c) {
|
||||||
|
connect(c, &Collection::doneUnlockCollection, this, &UnlockCollectionsPrompt::collectionUnlockFinished);
|
||||||
c->doUnlock();
|
c->doUnlock();
|
||||||
unlocked << c->objectPath();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
emit completed(false, QVariant::fromValue(unlocked));
|
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UnlockCollectionsPrompt::collectionUnlockFinished(bool accepted)
|
||||||
|
{
|
||||||
|
auto coll = qobject_cast<Collection*>(sender());
|
||||||
|
if (!coll) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!m_collections.contains(coll)) {
|
||||||
|
// should not happen
|
||||||
|
coll->disconnect(this);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// one shot
|
||||||
|
coll->disconnect(this);
|
||||||
|
|
||||||
|
if (accepted) {
|
||||||
|
m_unlocked << coll->objectPath();
|
||||||
|
} else {
|
||||||
|
m_numRejected += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if we've get all
|
||||||
|
if (m_numRejected + m_unlocked.size() == m_collections.size()) {
|
||||||
|
emit completed(m_unlocked.isEmpty(), QVariant::fromValue(m_unlocked));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DeleteItemPrompt::DeleteItemPrompt(Service* parent, Item* item)
|
DeleteItemPrompt::DeleteItemPrompt(Service* parent, Item* item)
|
||||||
: PromptBase(parent)
|
: PromptBase(parent)
|
||||||
, m_item(item)
|
, m_item(item)
|
||||||
|
|
|
@ -98,8 +98,13 @@ namespace FdoSecrets
|
||||||
|
|
||||||
DBusReturn<void> prompt(const QString& windowId) override;
|
DBusReturn<void> prompt(const QString& windowId) override;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void collectionUnlockFinished(bool accepted);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<QPointer<Collection>> m_collections;
|
QList<QPointer<Collection>> m_collections;
|
||||||
|
QList<QDBusObjectPath> m_unlocked;
|
||||||
|
int m_numRejected = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Item;
|
class Item;
|
||||||
|
|
|
@ -47,6 +47,8 @@ namespace FdoSecrets
|
||||||
, m_insdieEnsureDefaultAlias(false)
|
, m_insdieEnsureDefaultAlias(false)
|
||||||
, m_serviceWatcher(nullptr)
|
, m_serviceWatcher(nullptr)
|
||||||
{
|
{
|
||||||
|
connect(
|
||||||
|
m_databases, &DatabaseTabWidget::databaseUnlockDialogFinished, this, &Service::doneUnlockDatabaseInDialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
Service::~Service()
|
Service::~Service()
|
||||||
|
@ -447,9 +449,9 @@ namespace FdoSecrets
|
||||||
return m_sessions;
|
return m_sessions;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Service::doCloseDatabase(DatabaseWidget* dbWidget)
|
bool Service::doCloseDatabase(DatabaseWidget* dbWidget)
|
||||||
{
|
{
|
||||||
m_databases->closeDatabaseTab(dbWidget);
|
return m_databases->closeDatabaseTab(dbWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
Collection* Service::doNewDatabase()
|
Collection* Service::doNewDatabase()
|
||||||
|
@ -472,11 +474,10 @@ namespace FdoSecrets
|
||||||
|
|
||||||
void Service::doSwitchToChangeDatabaseSettings(DatabaseWidget* dbWidget)
|
void Service::doSwitchToChangeDatabaseSettings(DatabaseWidget* dbWidget)
|
||||||
{
|
{
|
||||||
// switch selected to current
|
|
||||||
// unlock if needed
|
|
||||||
if (dbWidget->isLocked()) {
|
if (dbWidget->isLocked()) {
|
||||||
m_databases->unlockDatabaseInDialog(dbWidget, DatabaseOpenDialog::Intent::None);
|
return;
|
||||||
}
|
}
|
||||||
|
// switch selected to current
|
||||||
m_databases->setCurrentWidget(dbWidget);
|
m_databases->setCurrentWidget(dbWidget);
|
||||||
m_databases->changeDatabaseSettings();
|
m_databases->changeDatabaseSettings();
|
||||||
|
|
||||||
|
|
|
@ -88,6 +88,13 @@ namespace FdoSecrets
|
||||||
*/
|
*/
|
||||||
void error(const QString& msg);
|
void error(const QString& msg);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finish signal for async action doUnlockDatabaseInDialog
|
||||||
|
* @param accepted If false, the action is canceled by the user
|
||||||
|
* @param dbWidget The unlocked the dbWidget if succeed
|
||||||
|
*/
|
||||||
|
void doneUnlockDatabaseInDialog(bool accepted, DatabaseWidget* dbWidget);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* List of sessions
|
* List of sessions
|
||||||
|
@ -101,9 +108,14 @@ namespace FdoSecrets
|
||||||
}
|
}
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void doCloseDatabase(DatabaseWidget* dbWidget);
|
bool doCloseDatabase(DatabaseWidget* dbWidget);
|
||||||
Collection* doNewDatabase();
|
Collection* doNewDatabase();
|
||||||
void doSwitchToChangeDatabaseSettings(DatabaseWidget* dbWidget);
|
void doSwitchToChangeDatabaseSettings(DatabaseWidget* dbWidget);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Async, connect to signal doneUnlockDatabaseInDialog for finish notification
|
||||||
|
* @param dbWidget
|
||||||
|
*/
|
||||||
void doUnlockDatabaseInDialog(DatabaseWidget* dbWidget);
|
void doUnlockDatabaseInDialog(DatabaseWidget* dbWidget);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
|
@ -51,7 +51,7 @@ void DatabaseOpenDialog::setTargetDatabaseWidget(DatabaseWidget* dbWidget)
|
||||||
disconnect(this, nullptr, m_dbWidget, nullptr);
|
disconnect(this, nullptr, m_dbWidget, nullptr);
|
||||||
}
|
}
|
||||||
m_dbWidget = dbWidget;
|
m_dbWidget = dbWidget;
|
||||||
connect(this, SIGNAL(dialogFinished(bool)), dbWidget, SLOT(unlockDatabase(bool)));
|
connect(this, &DatabaseOpenDialog::dialogFinished, dbWidget, &DatabaseWidget::unlockDatabase);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseOpenDialog::setIntent(DatabaseOpenDialog::Intent intent)
|
void DatabaseOpenDialog::setIntent(DatabaseOpenDialog::Intent intent)
|
||||||
|
@ -90,6 +90,6 @@ void DatabaseOpenDialog::complete(bool accepted)
|
||||||
} else {
|
} else {
|
||||||
reject();
|
reject();
|
||||||
}
|
}
|
||||||
emit dialogFinished(accepted);
|
emit dialogFinished(accepted, m_dbWidget);
|
||||||
clearForms();
|
clearForms();
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ public:
|
||||||
void clearForms();
|
void clearForms();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void dialogFinished(bool);
|
void dialogFinished(bool accepted, DatabaseWidget* dbWidget);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void complete(bool accepted);
|
void complete(bool accepted);
|
||||||
|
|
|
@ -63,6 +63,8 @@ DatabaseTabWidget::DatabaseTabWidget(QWidget* parent)
|
||||||
connect(autoType(), SIGNAL(globalAutoTypeTriggered()), SLOT(performGlobalAutoType()));
|
connect(autoType(), SIGNAL(globalAutoTypeTriggered()), SLOT(performGlobalAutoType()));
|
||||||
connect(autoType(), SIGNAL(autotypePerformed()), SLOT(relockPendingDatabase()));
|
connect(autoType(), SIGNAL(autotypePerformed()), SLOT(relockPendingDatabase()));
|
||||||
connect(autoType(), SIGNAL(autotypeRejected()), SLOT(relockPendingDatabase()));
|
connect(autoType(), SIGNAL(autotypeRejected()), SLOT(relockPendingDatabase()));
|
||||||
|
connect(m_databaseOpenDialog.data(), &DatabaseOpenDialog::dialogFinished,
|
||||||
|
this, &DatabaseTabWidget::databaseUnlockDialogFinished);
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
#ifdef Q_OS_MACOS
|
#ifdef Q_OS_MACOS
|
||||||
|
|
|
@ -90,6 +90,7 @@ signals:
|
||||||
void tabNameChanged();
|
void tabNameChanged();
|
||||||
void messageGlobal(const QString&, MessageWidget::MessageType type);
|
void messageGlobal(const QString&, MessageWidget::MessageType type);
|
||||||
void messageDismissGlobal();
|
void messageDismissGlobal();
|
||||||
|
void databaseUnlockDialogFinished(bool accepted, DatabaseWidget* dbWidget);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void toggleTabbar();
|
void toggleTabbar();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue