diff --git a/share/translations/keepassxc_en.ts b/share/translations/keepassxc_en.ts
index a70b0ec312..8bb51f7d82 100644
--- a/share/translations/keepassxc_en.ts
+++ b/share/translations/keepassxc_en.ts
@@ -8596,10 +8596,6 @@ This option is deprecated, use --set-key-file instead.
-
-
-
-
@@ -8690,22 +8686,6 @@ This option is deprecated, use --set-key-file instead.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/browser/BrowserService.cpp b/src/browser/BrowserService.cpp
index 93c51f2820..2b5a8bf199 100644
--- a/src/browser/BrowserService.cpp
+++ b/src/browser/BrowserService.cpp
@@ -662,7 +662,7 @@ QJsonObject BrowserService::showPasskeysRegisterPrompt(const QJsonObject& public
// If no entry is selected, show the import dialog for manual entry selection
auto selectedEntry = confirmDialog.getSelectedEntry();
if (!selectedEntry) {
- PasskeyImporter passkeyImporter;
+ PasskeyImporter passkeyImporter(m_currentDatabaseWidget);
const auto result = passkeyImporter.showImportDialog(db,
nullptr,
origin,
@@ -672,7 +672,8 @@ QJsonObject BrowserService::showPasskeysRegisterPrompt(const QJsonObject& public
userId,
publicKeyCredentials.key,
tr("KeePassXC - Passkey credentials"),
- tr("Register a new passkey to this entry:"));
+ tr("Register a new passkey to this entry:"),
+ tr("Register"));
if (!result) {
return getPasskeyError(ERROR_PASSKEYS_REQUEST_CANCELED);
}
diff --git a/src/gui/DatabaseWidget.cpp b/src/gui/DatabaseWidget.cpp
index 816d3ace1d..edbed3dde0 100644
--- a/src/gui/DatabaseWidget.cpp
+++ b/src/gui/DatabaseWidget.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2023 KeePassXC Team
+ * Copyright (C) 2024 KeePassXC Team
* Copyright (C) 2010 Felix Geyer
*
* This program is free software: you can redistribute it and/or modify
@@ -1411,7 +1411,7 @@ void DatabaseWidget::switchToPasskeys()
void DatabaseWidget::showImportPasskeyDialog(bool isEntry)
{
- PasskeyImporter passkeyImporter;
+ PasskeyImporter passkeyImporter(this);
if (isEntry) {
auto currentEntry = currentSelectedEntry();
diff --git a/src/gui/passkeys/PasskeyExporter.cpp b/src/gui/passkeys/PasskeyExporter.cpp
index 2585c76e04..315825b4bb 100644
--- a/src/gui/passkeys/PasskeyExporter.cpp
+++ b/src/gui/passkeys/PasskeyExporter.cpp
@@ -27,13 +27,18 @@
#include
#include
+PasskeyExporter::PasskeyExporter(QWidget* parent)
+ : m_parent(parent)
+{
+}
+
void PasskeyExporter::showExportDialog(const QList& items)
{
if (items.isEmpty()) {
return;
}
- PasskeyExportDialog passkeyExportDialog;
+ PasskeyExportDialog passkeyExportDialog(m_parent);
passkeyExportDialog.setEntries(items);
auto ret = passkeyExportDialog.exec();
@@ -69,7 +74,7 @@ void PasskeyExporter::exportSelectedEntry(const Entry* entry, const QString& fol
{
const auto fullPath = QString("%1/%2.passkey").arg(folder, Tools::cleanFilename(entry->title()));
if (QFile::exists(fullPath)) {
- auto dialogResult = MessageBox::warning(nullptr,
+ auto dialogResult = MessageBox::warning(m_parent,
tr("KeePassXC: Passkey Export"),
tr("File \"%1.passkey\" already exists.\n"
"Do you want to overwrite it?\n")
@@ -84,7 +89,7 @@ void PasskeyExporter::exportSelectedEntry(const Entry* entry, const QString& fol
QFile passkeyFile(fullPath);
if (!passkeyFile.open(QIODevice::WriteOnly)) {
MessageBox::information(
- nullptr, tr("Cannot open file"), tr("Cannot open file \"%1\" for writing.").arg(fullPath));
+ m_parent, tr("Cannot open file"), tr("Cannot open file \"%1\" for writing.").arg(fullPath));
return;
}
diff --git a/src/gui/passkeys/PasskeyExporter.h b/src/gui/passkeys/PasskeyExporter.h
index 4214cbea33..ca59ea4b34 100644
--- a/src/gui/passkeys/PasskeyExporter.h
+++ b/src/gui/passkeys/PasskeyExporter.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2023 KeePassXC Team
+ * Copyright (C) 2024 KeePassXC Team
*
* 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
@@ -20,6 +20,8 @@
#include
#include
+#include
+#include
class Entry;
@@ -28,12 +30,15 @@ class PasskeyExporter : public QObject
Q_OBJECT
public:
- explicit PasskeyExporter() = default;
+ explicit PasskeyExporter(QWidget* parent = nullptr);
void showExportDialog(const QList& items);
private:
void exportSelectedEntry(const Entry* entry, const QString& folder);
+
+private:
+ QPointer m_parent;
};
#endif // KEEPASSXC_PASSKEYEXPORTER_H
diff --git a/src/gui/passkeys/PasskeyImportDialog.cpp b/src/gui/passkeys/PasskeyImportDialog.cpp
index 7d1f89874b..179b2ed96d 100644
--- a/src/gui/passkeys/PasskeyImportDialog.cpp
+++ b/src/gui/passkeys/PasskeyImportDialog.cpp
@@ -50,7 +50,8 @@ void PasskeyImportDialog::setInfo(const QString& relyingParty,
const QSharedPointer& database,
bool isEntry,
const QString& titleText,
- const QString& infoText)
+ const QString& infoText,
+ const QString& importButtonText)
{
m_ui->relyingPartyLabel->setText(tr("Relying Party: %1").arg(relyingParty));
m_ui->usernameLabel->setText(tr("Username: %1").arg(username));
@@ -80,6 +81,10 @@ void PasskeyImportDialog::setInfo(const QString& relyingParty,
if (!infoText.isEmpty()) {
m_ui->infoLabel->setText(infoText);
}
+
+ if (!importButtonText.isEmpty()) {
+ m_ui->importButton->setText(importButtonText);
+ }
}
QSharedPointer PasskeyImportDialog::getSelectedDatabase() const
diff --git a/src/gui/passkeys/PasskeyImportDialog.h b/src/gui/passkeys/PasskeyImportDialog.h
index 8e7eb2e9ec..920a6a020a 100644
--- a/src/gui/passkeys/PasskeyImportDialog.h
+++ b/src/gui/passkeys/PasskeyImportDialog.h
@@ -41,7 +41,8 @@ class PasskeyImportDialog : public QDialog
const QSharedPointer& database,
bool isEntry,
const QString& titleText = {},
- const QString& infoText = {});
+ const QString& infoText = {},
+ const QString& importButtonText = {});
QSharedPointer getSelectedDatabase() const;
QUuid getSelectedEntryUuid() const;
QUuid getSelectedGroupUuid() const;
diff --git a/src/gui/passkeys/PasskeyImporter.cpp b/src/gui/passkeys/PasskeyImporter.cpp
index 7ea80da043..22435b99ea 100644
--- a/src/gui/passkeys/PasskeyImporter.cpp
+++ b/src/gui/passkeys/PasskeyImporter.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2023 KeePassXC Team
+ * Copyright (C) 2024 KeePassXC Team
*
* 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
@@ -30,6 +30,11 @@
static const QString IMPORTED_PASSKEYS_GROUP = QStringLiteral("Imported Passkeys");
+PasskeyImporter::PasskeyImporter(QWidget* parent)
+ : m_parent(parent)
+{
+}
+
void PasskeyImporter::importPasskey(QSharedPointer& database, Entry* entry)
{
auto filter = QString("%1 (*.passkey);;%2 (*)").arg(tr("Passkey file"), tr("All files"));
@@ -56,7 +61,7 @@ void PasskeyImporter::importSelectedFile(QFile& file, QSharedPointer&
const auto fileData = file.readAll();
const auto passkeyObject = browserMessageBuilder()->getJsonObject(fileData);
if (passkeyObject.isEmpty()) {
- MessageBox::information(nullptr,
+ MessageBox::information(m_parent,
tr("Cannot import passkey"),
tr("Cannot import passkey file \"%1\". Data is missing.").arg(file.fileName()));
return;
@@ -70,16 +75,15 @@ void PasskeyImporter::importSelectedFile(QFile& file, QSharedPointer&
<< "credentialId"
<< "userHandle"
<< "privateKey");
-
if (!missingKeys.isEmpty()) {
- MessageBox::information(nullptr,
+ MessageBox::information(m_parent,
tr("Cannot import passkey"),
tr("Cannot import passkey file \"%1\".\nThe following data is missing:\n%2")
.arg(file.fileName(), missingKeys.join(", ")));
} else if (!privateKey.startsWith("-----BEGIN PRIVATE KEY-----")
|| !privateKey.trimmed().endsWith("-----END PRIVATE KEY-----")) {
MessageBox::information(
- nullptr,
+ m_parent,
tr("Cannot import passkey"),
tr("Cannot import passkey file \"%1\". Private key is missing or malformed.").arg(file.fileName()));
} else {
@@ -101,10 +105,12 @@ bool PasskeyImporter::showImportDialog(QSharedPointer& database,
const QString& userHandle,
const QString& privateKey,
const QString& titleText,
- const QString& infoText)
+ const QString& infoText,
+ const QString& importButtonText)
{
- PasskeyImportDialog passkeyImportDialog;
- passkeyImportDialog.setInfo(relyingParty, username, database, entry != nullptr, titleText, infoText);
+ PasskeyImportDialog passkeyImportDialog(m_parent);
+ passkeyImportDialog.setInfo(
+ relyingParty, username, database, entry != nullptr, titleText, infoText, importButtonText);
auto ret = passkeyImportDialog.exec();
if (ret != QDialog::Accepted) {
diff --git a/src/gui/passkeys/PasskeyImporter.h b/src/gui/passkeys/PasskeyImporter.h
index 6a446485a7..9fd7097d5c 100644
--- a/src/gui/passkeys/PasskeyImporter.h
+++ b/src/gui/passkeys/PasskeyImporter.h
@@ -21,7 +21,9 @@
#include "core/Database.h"
#include
#include
+#include
#include
+#include
class Entry;
@@ -30,7 +32,7 @@ class PasskeyImporter : public QObject
Q_OBJECT
public:
- explicit PasskeyImporter() = default;
+ explicit PasskeyImporter(QWidget* parent = nullptr);
void importPasskey(QSharedPointer& database, Entry* entry = nullptr);
bool showImportDialog(QSharedPointer& database,
@@ -42,12 +44,15 @@ class PasskeyImporter : public QObject
const QString& userHandle,
const QString& privateKey,
const QString& titleText = {},
- const QString& infoText = {});
+ const QString& infoText = {},
+ const QString& importButtonText = {});
private:
void importSelectedFile(QFile& file, QSharedPointer& database, Entry* entry);
-
Group* getDefaultGroup(QSharedPointer& database) const;
+
+private:
+ QPointer m_parent;
};
#endif // KEEPASSXC_PASSKEYIMPORTER_H
diff --git a/src/gui/reports/ReportsWidgetPasskeys.cpp b/src/gui/reports/ReportsWidgetPasskeys.cpp
index e671509060..696fcd832c 100644
--- a/src/gui/reports/ReportsWidgetPasskeys.cpp
+++ b/src/gui/reports/ReportsWidgetPasskeys.cpp
@@ -282,7 +282,7 @@ void ReportsWidgetPasskeys::selectionChanged()
void ReportsWidgetPasskeys::importPasskey()
{
- PasskeyImporter passkeyImporter;
+ PasskeyImporter passkeyImporter(this);
passkeyImporter.importPasskey(m_db);
updateEntries();
@@ -300,6 +300,6 @@ void ReportsWidgetPasskeys::exportPasskey()
return;
}
- PasskeyExporter passkeyExporter;
+ PasskeyExporter passkeyExporter(this);
passkeyExporter.showExportDialog(getSelectedEntries());
}