feat: add a page to recover when an account turns out to be already used while adding it
This page is a bit of a bodge for the fact that the current Accounts model must be 'unlocked' before it can be used. In turn, this means that it is not straightforward to check that an account is still 'available' when presenting the user with the option to add an account received via URI from the commandline. The solution implemented here is to check and let the user recover after unlocking, if necessary. Issues: #7, #14master
parent
72cfaee9bf
commit
92e92557fa
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* SPDX-FileCopyrightText: 2020 Johan Ouwerkerk <jm.ouwerkerk@gmail.com>
|
||||
*/
|
||||
|
||||
import QtQuick 2.1
|
||||
import QtQuick.Layouts 1.2
|
||||
import QtQuick.Controls 2.0 as Controls
|
||||
import org.kde.kirigami 2.8 as Kirigami
|
||||
|
||||
import Keysmith.Application 1.0
|
||||
import Keysmith.Models 1.0 as Models
|
||||
import Keysmith.Validators 1.0 as Validators
|
||||
|
||||
Kirigami.Page {
|
||||
id: root
|
||||
title: i18nc("@title:window", "Rename account to add")
|
||||
signal cancelled
|
||||
signal newAccount(var input)
|
||||
property bool quitEnabled: false
|
||||
property Models.AccountListModel accounts: Keysmith.accountListModel()
|
||||
|
||||
property bool acceptable: accountName.acceptable
|
||||
property Models.ValidatedAccountInput validatedInput: Models.ValidatedAccountInput {}
|
||||
|
||||
Connections {
|
||||
target: validatedInput
|
||||
onTypeChanged: {
|
||||
root.detailsEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
anchors {
|
||||
horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
Controls.Label {
|
||||
text:i18nc("@info:label Keysmith received an account to add via URI on e.g. commandline which is already in use", "Another account with the same name already exists. Please correct the name or issuer for the new account.")
|
||||
color: Kirigami.Theme.negativeTextColor
|
||||
Layout.maximumWidth: root.width - 2 * Kirigami.Units.largeSpacing
|
||||
wrapMode: Text.WordWrap
|
||||
}
|
||||
AccountNameForm {
|
||||
id: accountName
|
||||
validateAccountAvailability: true
|
||||
validatedInput: root.validatedInput
|
||||
}
|
||||
}
|
||||
|
||||
actions.left: Kirigami.Action {
|
||||
text: i18nc("@action:button cancel and dismiss the rename account form", "Cancel")
|
||||
iconName: "edit-undo"
|
||||
onTriggered: {
|
||||
root.cancelled();
|
||||
}
|
||||
}
|
||||
actions.main: Kirigami.Action {
|
||||
text: i18n("Add")
|
||||
iconName: "answer-correct"
|
||||
enabled: acceptable
|
||||
onTriggered: {
|
||||
root.newAccount(root.validatedInput);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,6 +9,7 @@
|
|||
<file alias="AccountsOverview.qml">contents/ui/AccountsOverview.qml</file>
|
||||
<file alias="AddAccount.qml">contents/ui/AddAccount.qml</file>
|
||||
<file alias="ErrorPage.qml">contents/ui/ErrorPage.qml</file>
|
||||
<file alias="RenameAccount.qml">contents/ui/RenameAccount.qml</file>
|
||||
<file alias="AccountNameForm.qml">contents/ui/AccountNameForm.qml</file>
|
||||
<file alias="HOTPDetailsForm.qml">contents/ui/HOTPDetailsForm.qml</file>
|
||||
<file alias="TOTPDetailsForm.qml">contents/ui/TOTPDetailsForm.qml</file>
|
||||
|
|
Loading…
Reference in New Issue