Passkeys: UI adjustments

This commit is contained in:
varjolintu 2023-11-25 12:45:29 +02:00 committed by Jonathan White
parent 6820400b11
commit 6d19ab8894
10 changed files with 180 additions and 161 deletions

View file

@ -33,6 +33,7 @@ BrowserPasskeysConfirmationDialog::BrowserPasskeysConfirmationDialog(QWidget* pa
m_ui->setupUi(this);
m_ui->updateButton->setVisible(false);
m_ui->verticalLayout->setAlignment(Qt::AlignTop);
connect(m_ui->credentialsTable, SIGNAL(cellDoubleClicked(int, int)), this, SLOT(accept()));
connect(m_ui->confirmButton, SIGNAL(clicked()), SLOT(accept()));
@ -48,12 +49,13 @@ BrowserPasskeysConfirmationDialog::~BrowserPasskeysConfirmationDialog()
}
void BrowserPasskeysConfirmationDialog::registerCredential(const QString& username,
const QString& siteId,
const QString& relyingParty,
const QList<Entry*>& existingEntries,
int timeout)
{
m_ui->firstLabel->setText(tr("Do you want to register Passkey for:"));
m_ui->dataLabel->setText(tr("%1 (%2)").arg(username, siteId));
m_ui->relyingPartyLabel->setText(tr("Relying Party: %1").arg(relyingParty));
m_ui->usernameLabel->setText(tr("Username: %1").arg(username));
m_ui->secondLabel->setText("");
if (!existingEntries.isEmpty()) {
@ -64,6 +66,7 @@ void BrowserPasskeysConfirmationDialog::registerCredential(const QString& userna
m_ui->confirmButton->setText(tr("Register new"));
updateEntriesToTable(existingEntries);
} else {
m_ui->verticalLayout->setSizeConstraint(QLayout::SetFixedSize);
m_ui->confirmButton->setText(tr("Register"));
m_ui->credentialsTable->setVisible(false);
}
@ -72,11 +75,12 @@ void BrowserPasskeysConfirmationDialog::registerCredential(const QString& userna
}
void BrowserPasskeysConfirmationDialog::authenticateCredential(const QList<Entry*>& entries,
const QString& origin,
const QString& relyingParty,
int timeout)
{
m_ui->firstLabel->setText(tr("Authenticate Passkey credentials for:"));
m_ui->dataLabel->setText(origin);
m_ui->relyingPartyLabel->setText(tr("Relying Party: %1").arg(relyingParty));
m_ui->usernameLabel->setVisible(false);
m_ui->secondLabel->setText("");
updateEntriesToTable(entries);
startCounter(timeout);

View file

@ -38,10 +38,10 @@ public:
~BrowserPasskeysConfirmationDialog() override;
void registerCredential(const QString& username,
const QString& siteId,
const QString& relyingParty,
const QList<Entry*>& existingEntries,
int timeout);
void authenticateCredential(const QList<Entry*>& entries, const QString& origin, int timeout);
void authenticateCredential(const QList<Entry*>& entries, const QString& relyingParty, int timeout);
Entry* getSelectedEntry() const;
bool isPasskeyUpdated() const;

View file

@ -6,69 +6,73 @@
<rect>
<x>0</x>
<y>0</y>
<width>405</width>
<height>282</height>
<width>400</width>
<height>274</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>KeePassXC: Passkey credentials</string>
<string>KeePassXC - Passkey credentials</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="firstLabel">
<property name="font">
<font>
<bold>true</bold>
</font>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="dataLabel">
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="secondLabel">
<property name="font">
<font>
<bold>true</bold>
</font>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>10</height>
</size>
</property>
</spacer>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="firstLabel">
<property name="font">
<font>
<bold>true</bold>
</font>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="relyingPartyLabel">
<property name="text">
<string>Relying Party: %1</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="usernameLabel">
<property name="text">
<string>Username: %1</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="secondLabel">
<property name="font">
<font>
<bold>true</bold>
</font>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QTableWidget" name="credentialsTable">

View file

@ -276,7 +276,7 @@ QJsonObject BrowserService::createNewGroup(const QString& groupName)
}
auto dialogResult = MessageBox::warning(m_currentDatabaseWidget,
tr("KeePassXC: Create a new group"),
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")
.arg(groupName),
@ -560,7 +560,7 @@ QString BrowserService::storeKey(const QString& key)
do {
QInputDialog keyDialog(m_currentDatabaseWidget);
connect(m_currentDatabaseWidget, SIGNAL(databaseLockRequested()), &keyDialog, SLOT(reject()));
keyDialog.setWindowTitle(tr("KeePassXC: New key association request"));
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"
"Give the connection a unique name or ID, for example:\nchrome-laptop.")
.arg(db->metadata()->name().toHtmlEscaped()));
@ -582,7 +582,7 @@ QString BrowserService::storeKey(const QString& key)
contains = db->metadata()->customData()->contains(CustomData::BrowserKeyPrefix + id);
if (contains) {
dialogResult = MessageBox::warning(m_currentDatabaseWidget,
tr("KeePassXC: Overwrite existing key?"),
tr("KeePassXC - Overwrite existing key?"),
tr("A shared encryption key with the name \"%1\" "
"already exists.\nDo you want to overwrite it?")
.arg(id),
@ -713,7 +713,7 @@ QJsonObject BrowserService::showPasskeysAuthenticationPrompt(const QJsonObject&
raiseWindow();
BrowserPasskeysConfirmationDialog confirmDialog;
confirmDialog.authenticateCredential(entries, origin, timeout);
confirmDialog.authenticateCredential(entries, rpId, timeout);
auto dialogResult = confirmDialog.exec();
if (dialogResult == QDialog::Accepted) {
hideWindow();
@ -777,7 +777,7 @@ void BrowserService::addPasskeyToEntry(Entry* entry,
if (entry->hasPasskey()) {
if (MessageBox::question(
m_currentDatabaseWidget,
tr("KeePassXC: Update Passkey"),
tr("KeePassXC - Update Passkey"),
tr("Entry already has a Passkey.\nDo you want to overwrite the Passkey in %1 - %2?")
.arg(entry->title(), entry->attributes()->value(BrowserPasskeys::KPEX_PASSKEY_USERNAME)),
MessageBox::Overwrite | MessageBox::Cancel,
@ -889,7 +889,7 @@ bool BrowserService::updateEntry(const EntryParameters& entryParameters, const Q
if (!browserSettings()->alwaysAllowUpdate()) {
raiseWindow();
dialogResult = MessageBox::question(m_currentDatabaseWidget,
tr("KeePassXC: Update Entry"),
tr("KeePassXC - Update Entry"),
tr("Do you want to update the information in %1 - %2?")
.arg(QUrl(entryParameters.siteUrl).host(), username),
MessageBox::Save | MessageBox::Cancel,
@ -925,7 +925,7 @@ bool BrowserService::deleteEntry(const QString& uuid)
}
auto dialogResult = MessageBox::warning(m_currentDatabaseWidget,
tr("KeePassXC: Delete entry"),
tr("KeePassXC - Delete entry"),
tr("A request for deleting entry \"%1\" has been received.\n"
"Do you want to delete the entry?\n")
.arg(entry->title()),