fix: make Kirigami relayout the password setup page with proper word wrapping for the banner text

This is a hack/work-around for a deficiency in Kirigami pending a proper fix upstream.

See-Also: https://invent.kde.org/frameworks/kirigami/-/merge_requests/159
master
Carl Schwan 2020-11-11 14:41:34 +01:00 committed by Johan Ouwerkerk
parent abd2319a34
commit 5c5a7e1ca0
1 changed files with 36 additions and 23 deletions

View File

@ -18,24 +18,34 @@ Kirigami.ScrollablePage {
property bool bannerTextError : false
property Models.PasswordRequestModel passwordRequest: Keysmith.passwordRequest()
ColumnLayout {
Kirigami.FormLayout {
Item {
Kirigami.FormData.isSection: true
Kirigami.FormData.label: i18n("Get started by choosing a password to protect your accounts")
}
Kirigami.PasswordField {
id: newPassword
text: ""
Kirigami.FormData.label: i18nc("@label:textbox", "New password:")
onAccepted: newPasswordCopy.forceActiveFocus()
}
Kirigami.PasswordField {
id: newPasswordCopy
text: ""
Kirigami.FormData.label: i18nc("@label:textbox", "Verify password:")
onAccepted: applyAction.trigger()
// HACK remove when depends on Kirigami 5.77
Component.onCompleted: {
for (var index in form.children[0].children) {
var item = form.children[0].children[index];
if (item instanceof Text) {
item.wrapMode = item.Text.Wrap
}
item.Layout.fillWidth = true;
}
}
Kirigami.FormLayout {
id: form
Item {
Kirigami.FormData.isSection: true
Kirigami.FormData.label: i18n("Get started by choosing a password to protect your accounts")
}
Kirigami.PasswordField {
id: newPassword
text: ""
Kirigami.FormData.label: i18nc("@label:textbox", "New password:")
onAccepted: newPasswordCopy.forceActiveFocus()
}
Kirigami.PasswordField {
id: newPasswordCopy
text: ""
Kirigami.FormData.label: i18nc("@label:textbox", "Verify password:")
onAccepted: applyAction.trigger()
}
}
@ -55,11 +65,14 @@ Kirigami.ScrollablePage {
}
}
footer: Kirigami.InlineMessage {
id: errorMessage
Layout.fillWidth: true
text: i18n("Failed to set up your password")
visible: bannerTextError
showCloseButton: true
footer: Controls.Control {
padding: Kirigami.Units.smallSpacing
Kirigami.InlineMessage {
id: errorMessage
Layout.fillWidth: true
text: i18n("Failed to set up your password")
visible: bannerTextError
showCloseButton: true
}
}
}