From c3382f8a8ea3c856ac31d51159e42760abd20d1f Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Mon, 27 Jan 2025 21:26:42 +0100 Subject: keepassxc: spawn dialogs without parents --- overlays/keepassxc/database-open-dialog.patch | 126 ++++++++++++++++++++++++++ overlays/keepassxc/default.nix | 8 ++ 2 files changed, 134 insertions(+) create mode 100644 overlays/keepassxc/database-open-dialog.patch create mode 100644 overlays/keepassxc/default.nix diff --git a/overlays/keepassxc/database-open-dialog.patch b/overlays/keepassxc/database-open-dialog.patch new file mode 100644 index 00000000..4916dc1b --- /dev/null +++ b/overlays/keepassxc/database-open-dialog.patch @@ -0,0 +1,126 @@ +diff -u3 -r source.orig/src/browser/BrowserService.cpp source/src/browser/BrowserService.cpp +--- source.orig/src/browser/BrowserService.cpp 2025-01-27 20:55:04.128198171 +0100 ++++ source/src/browser/BrowserService.cpp 2025-01-27 21:16:07.068959077 +0100 +@@ -249,7 +249,7 @@ + return result; + } + +- auto dialogResult = MessageBox::warning(m_currentDatabaseWidget, ++ auto dialogResult = MessageBox::warning(nullptr, + tr("KeePassXC - Create a new group"), + tr("A request for creating a new group \"%1\" has been received.\n" + "Do you want to create this group?\n") +@@ -422,7 +422,7 @@ + + m_dialogActive = true; + updateWindowState(); +- BrowserAccessControlDialog accessControlDialog(m_currentDatabaseWidget); ++ BrowserAccessControlDialog accessControlDialog{}; + + connect(m_currentDatabaseWidget, SIGNAL(databaseLockRequested()), &accessControlDialog, SLOT(reject())); + +@@ -512,7 +512,7 @@ + QString id; + + do { +- QInputDialog keyDialog(m_currentDatabaseWidget); ++ QInputDialog keyDialog{}; + 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" +@@ -535,7 +535,7 @@ + + contains = db->metadata()->customData()->contains(CustomData::BrowserKeyPrefix + id); + if (contains) { +- dialogResult = MessageBox::warning(m_currentDatabaseWidget, ++ dialogResult = MessageBox::warning(nullptr, + tr("KeePassXC - Overwrite existing key?"), + tr("A shared encryption key with the name \"%1\" " + "already exists.\nDo you want to overwrite it?") +@@ -595,7 +595,7 @@ + const auto existingEntries = getPasskeyEntriesWithUserHandle(rpId, userId, keyList); + + raiseWindow(); +- BrowserPasskeysConfirmationDialog confirmDialog(m_currentDatabaseWidget); ++ BrowserPasskeysConfirmationDialog confirmDialog{}; + confirmDialog.registerCredential(username, rpId, existingEntries, timeout); + + auto dialogResult = confirmDialog.exec(); +@@ -612,7 +612,7 @@ + // If no entry is selected, show the import dialog for manual entry selection + auto selectedEntry = confirmDialog.getSelectedEntry(); + if (!selectedEntry) { +- PasskeyImporter passkeyImporter(m_currentDatabaseWidget); ++ PasskeyImporter passkeyImporter{}; + const auto result = passkeyImporter.showImportDialog(db, + nullptr, + origin, +@@ -683,7 +683,7 @@ + const auto timeout = publicKeyOptions["timeout"].toInt(); + + raiseWindow(); +- BrowserPasskeysConfirmationDialog confirmDialog(m_currentDatabaseWidget); ++ BrowserPasskeysConfirmationDialog confirmDialog{}; + confirmDialog.authenticateCredential(entries, rpId, timeout); + auto dialogResult = confirmDialog.exec(); + if (dialogResult == QDialog::Accepted) { +@@ -760,7 +760,7 @@ + + // Ask confirmation if entry already contains a Passkey + if (entry->hasPasskey()) { +- if (MessageBox::question(m_currentDatabaseWidget, ++ if (MessageBox::question(nullptr, + tr("KeePassXC - Update passkey"), + tr("Entry already has a passkey.\nDo you want to overwrite the passkey in %1 - %2?") + .arg(entry->title(), passkeyUtils()->getUsernameFromEntry(entry)), +@@ -873,7 +873,7 @@ + MessageBox::Button dialogResult = MessageBox::No; + if (!browserSettings()->alwaysAllowUpdate()) { + raiseWindow(); +- dialogResult = MessageBox::question(m_currentDatabaseWidget, ++ dialogResult = MessageBox::question(nullptr, + tr("KeePassXC - Update Entry"), + tr("Do you want to update the information in %1 - %2?") + .arg(QUrl(entryParameters.siteUrl).host(), username), +@@ -909,7 +909,7 @@ + return false; + } + +- auto dialogResult = MessageBox::warning(m_currentDatabaseWidget, ++ auto dialogResult = MessageBox::warning(nullptr, + tr("KeePassXC - Delete entry"), + tr("A request for deleting entry \"%1\" has been received.\n" + "Do you want to delete the entry?\n") +@@ -1536,7 +1536,7 @@ + } + } + +- BrowserEntrySaveDialog browserEntrySaveDialog(m_currentDatabaseWidget); ++ BrowserEntrySaveDialog browserEntrySaveDialog{}; + int openDatabaseCount = browserEntrySaveDialog.setItems(databaseWidgets, m_currentDatabaseWidget); + if (openDatabaseCount > 1) { + int res = browserEntrySaveDialog.exec(); +diff -u3 -r source.orig/src/fdosecrets/objects/Prompt.cpp source/src/fdosecrets/objects/Prompt.cpp +--- source.orig/src/fdosecrets/objects/Prompt.cpp 2025-01-27 20:55:04.135942791 +0100 ++++ source/src/fdosecrets/objects/Prompt.cpp 2025-01-27 21:01:37.166710935 +0100 +@@ -313,7 +313,7 @@ + if (!entries.isEmpty()) { + QString app = tr("%1 (PID: %2)").arg(client->name()).arg(client->pid()); + auto ac = new AccessControlDialog( +- findWindow(m_windowId), entries, app, client->processInfo(), AuthOption::Remember); ++ nullptr, entries, app, client->processInfo(), AuthOption::Remember); + connect(ac, &AccessControlDialog::finished, this, &UnlockPrompt::itemUnlockFinished); + connect(ac, &AccessControlDialog::finished, ac, &AccessControlDialog::deleteLater); + ac->open(); +diff -u3 -r source.orig/src/gui/DatabaseTabWidget.cpp source/src/gui/DatabaseTabWidget.cpp +--- source.orig/src/gui/DatabaseTabWidget.cpp 2025-01-27 20:55:04.134589500 +0100 ++++ source/src/gui/DatabaseTabWidget.cpp 2025-01-27 21:07:09.785284837 +0100 +@@ -41,7 +41,7 @@ + : QTabWidget(parent) + , m_dbWidgetStateSync(new DatabaseWidgetStateSync(this)) + , m_dbWidgetPendingLock(nullptr) +- , m_databaseOpenDialog(new DatabaseOpenDialog(this)) ++ , m_databaseOpenDialog(new DatabaseOpenDialog()) + , m_databaseOpenInProgress(false) + { + auto* tabBar = new QTabBar(this); diff --git a/overlays/keepassxc/default.nix b/overlays/keepassxc/default.nix new file mode 100644 index 00000000..25429a66 --- /dev/null +++ b/overlays/keepassxc/default.nix @@ -0,0 +1,8 @@ +{ final, prev, ... }: +{ + keepassxc = prev.keepassxc.overrideAttrs (oldAttrs: { + patches = (oldAttrs.patches or []) ++ [ + ./database-open-dialog.patch + ]; + }); +} -- cgit v1.2.3