refactor: move property assignments to main.qml

Ensure that all logic for property assignment is concentrated in
main.qml in preparation for the introduction of view model classes.
master
Johan Ouwerkerk 2021-02-15 21:05:43 +01:00 committed by Bhushan Shah
parent 12e060923e
commit 131e59aa3a
7 changed files with 21 additions and 14 deletions

View File

@ -14,8 +14,8 @@ import org.kde.kirigami 2.8 as Kirigami
Kirigami.FormLayout {
id: root
property bool validateAccountAvailability: true
property Models.AccountListModel accounts: Keysmith.accountListModel()
property bool validateAccountAvailability
property Models.AccountListModel accounts
property Models.ValidatedAccountInput validatedInput
onValidatedInputChanged: {

View File

@ -21,8 +21,8 @@ Kirigami.ScrollablePage {
title: i18nc("@title:window", "Accounts")
signal accountWanted
property bool addActionEnabled : true
property Models.AccountListModel accounts: Keysmith.accountListModel()
property bool addActionEnabled
property Models.AccountListModel accounts
property string accountErrorMessage: i18nc("generic error shown when adding or updating an account failed", "Failed to update accounts")
property string loadingErrorMessage: i18nc("error message shown when loading accounts from storage failed", "Some accounts failed to load.")

View File

@ -19,7 +19,7 @@ Kirigami.ScrollablePage {
signal quit
signal cancelled
signal newAccount(var input)
property Models.AccountListModel accounts: Keysmith.accountListModel()
property Models.AccountListModel accounts
property bool quitEnabled: false
property bool detailsEnabled: false
property bool validateAccountAvailability: true
@ -31,7 +31,7 @@ Kirigami.ScrollablePage {
property bool tokenDetailsAcceptable: hotpDetailsAcceptable && totpDetailsAcceptable
property bool acceptable: accountName.acceptable && secretAcceptable && tokenTypeAcceptable && tokenDetailsAcceptable
property Models.ValidatedAccountInput validatedInput: Models.ValidatedAccountInput {}
property Models.ValidatedAccountInput validatedInput
Connections {
target: validatedInput
@ -45,6 +45,7 @@ Kirigami.ScrollablePage {
AccountNameForm {
id: accountName
Layout.fillWidth: true
accounts: root.accounts
validateAccountAvailability: root.validateAccountAvailability
validatedInput: root.validatedInput
twinFormLayouts: [requiredDetails, hotpDetails, totpDetails]

View File

@ -17,11 +17,10 @@ Kirigami.Page {
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 Models.AccountListModel accounts
property bool acceptable: accountName.acceptable
property Models.ValidatedAccountInput validatedInput: Models.ValidatedAccountInput {}
property Models.ValidatedAccountInput validatedInput
Connections {
target: validatedInput
@ -42,6 +41,7 @@ Kirigami.Page {
}
AccountNameForm {
id: accountName
accounts: root.accounts
validateAccountAvailability: true
validatedInput: root.validatedInput
}

View File

@ -17,8 +17,8 @@ Kirigami.ScrollablePage {
id: root
title: i18nc("@title:window", "Password")
property bool bannerTextError : false
property Models.PasswordRequestModel passwordRequest: Keysmith.passwordRequest()
property bool bannerTextError
property Models.PasswordRequestModel passwordRequest
ColumnLayout {
spacing: Kirigami.Units.largeSpacing

View File

@ -17,8 +17,8 @@ Kirigami.ScrollablePage {
id: root
title: i18nc("@title:window", "Password")
property bool bannerTextError : false
property Models.PasswordRequestModel passwordRequest: Keysmith.passwordRequest()
property bool bannerTextError
property Models.PasswordRequestModel passwordRequest
header: Controls.Control {
padding: Kirigami.Units.smallSpacing

View File

@ -33,7 +33,6 @@ Kirigami.ApplicationWindow {
name: "__init__"
Component {
Kirigami.Page {
}
}
}
@ -42,6 +41,8 @@ Kirigami.ApplicationWindow {
name: "setup"
Component {
SetupPassword {
bannerTextError : false
passwordRequest: root.passwordRequest
}
}
}
@ -50,6 +51,8 @@ Kirigami.ApplicationWindow {
name: "unlock"
Component {
UnlockAccounts {
bannerTextError : false
passwordRequest: root.passwordRequest
}
}
}
@ -72,7 +75,10 @@ Kirigami.ApplicationWindow {
name: "add-new"
Component {
AddAccount {
quitEnabled: false
validateAccountAvailability: true
accounts: root.accounts
validatedInput: Models.ValidatedAccountInput {}
onCancelled: {
root.addActionEnabled = true;
Kirigami.PageRouter.navigateToRoute("accounts");