This commit is contained in:
Gaelle Braud 2024-07-03 15:51:23 +02:00
parent 5381f59bf4
commit 9240207ef5
5 changed files with 63 additions and 14 deletions

View file

@ -27,6 +27,16 @@ RightPanelLayout {
property string oldPictureUri property string oldPictureUri
signal closeEdition() signal closeEdition()
Dialog {
id: confirmDialog
onAccepted: {
mainItem.contact.core.undo()
mainItem.closeEdition()
}
width: 278 * DefaultStyle.dp
text: qsTr("Les changements seront annulés. Souhaitez-vous continuer ?")
}
headerContent: [ headerContent: [
Text { Text {
anchors.left: parent.left anchors.left: parent.left
@ -49,9 +59,7 @@ RightPanelLayout {
icon.width: 24 * DefaultStyle.dp icon.width: 24 * DefaultStyle.dp
icon.height: 24 * DefaultStyle.dp icon.height: 24 * DefaultStyle.dp
onClicked: { onClicked: {
// contact.core.pictureUri = mainItem.oldPictureUri confirmDialog.open()
mainItem.contact.core.undo()
mainItem.closeEdition()
} }
} }
] ]
@ -119,11 +127,15 @@ RightPanelLayout {
ColumnLayout { ColumnLayout {
spacing: 20 * DefaultStyle.dp spacing: 20 * DefaultStyle.dp
FormItemLayout { FormItemLayout {
id: givenName
enableErrorText: true
label: qsTr("Prénom") label: qsTr("Prénom")
contentItem: TextField { contentItem: TextField {
id: givenNameEdit
initialText: contact.core.givenName initialText: contact.core.givenName
onEditingFinished: contact.core.givenName = text onEditingFinished: contact.core.givenName = text
backgroundColor: DefaultStyle.grey_0 backgroundColor: DefaultStyle.grey_0
backgroundBorderColor: givenName.errorTextItem.opacity != 0 ? DefaultStyle.danger_500main : DefaultStyle.grey_200
} }
} }
FormItemLayout { FormItemLayout {
@ -160,6 +172,7 @@ RightPanelLayout {
anchors.rightMargin: 10 * DefaultStyle.dp anchors.rightMargin: 10 * DefaultStyle.dp
spacing: 20 * DefaultStyle.dp spacing: 20 * DefaultStyle.dp
Repeater { Repeater {
id: addressesList
model: VariantList { model: VariantList {
model: mainItem.contact && mainItem.contact.core.addresses || [] model: mainItem.contact && mainItem.contact.core.addresses || []
} }
@ -200,6 +213,10 @@ RightPanelLayout {
if (text.length != 0) mainItem.contact.core.appendAddress(text) if (text.length != 0) mainItem.contact.core.appendAddress(text)
text = "" text = ""
} }
onFocusChanged: if (!focus && text.length != 0) {
mainItem.contact.core.appendAddress(text)
text = ""
}
} }
} }
Item { Item {
@ -253,6 +270,12 @@ RightPanelLayout {
Layout.preferredHeight: 24 * DefaultStyle.dp Layout.preferredHeight: 24 * DefaultStyle.dp
} }
} }
ErrorText {
id: addressesErrorText
wrapMode: Qt.WordWrap
elide: Text.ElideRight
Layout.fillWidth: true
}
Item{Layout.fillHeight: true} Item{Layout.fillHeight: true}
} }
Control.ScrollBar.vertical: Control.ScrollBar{ Control.ScrollBar.vertical: Control.ScrollBar{
@ -275,13 +298,21 @@ RightPanelLayout {
Layout.bottomMargin: 100 * DefaultStyle.dp Layout.bottomMargin: 100 * DefaultStyle.dp
Layout.preferredWidth: 165 * DefaultStyle.dp Layout.preferredWidth: 165 * DefaultStyle.dp
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
enabled: mainItem.contact && mainItem.contact.core.givenName.length > 0 && mainItem.contact.core.allAddresses.length > 0 enabled: mainItem.contact && mainItem.contact.core.allAddresses.length > 0
text: mainItem.saveButtonText text: mainItem.saveButtonText
leftPadding: 20 * DefaultStyle.dp leftPadding: 20 * DefaultStyle.dp
rightPadding: 20 * DefaultStyle.dp rightPadding: 20 * DefaultStyle.dp
topPadding: 11 * DefaultStyle.dp topPadding: 11 * DefaultStyle.dp
bottomPadding: 11 * DefaultStyle.dp bottomPadding: 11 * DefaultStyle.dp
onClicked: { onClicked: {
if (givenNameEdit.text.length === 0) {
givenName.errorMessage = qsTr("Veuillez saisir un prénom")
return
}
if (addressesList.count === 0) {
addressesErrorText.text = qsTr("Veuillez saisir une adresse ou un numéro de téléphone")
return
}
mainItem.contact.core.save() mainItem.contact.core.save()
mainItem.closeEdition() mainItem.closeEdition()
} }

View file

@ -197,8 +197,9 @@ ListView {
Button { Button {
background: Item{} background: Item{}
contentItem: RowLayout { contentItem: RowLayout {
Image { EffectImage {
source: modelData.core.starred ? AppIcons.heartFill : AppIcons.heart imageSource: modelData.core.starred ? AppIcons.heartFill : AppIcons.heart
colorizationColor: modelData.core.starred ? DefaultStyle.danger_500main : DefaultStyle.main2_600
fillMode: Image.PreserveAspectFit fillMode: Image.PreserveAspectFit
width: 24 * DefaultStyle.dp width: 24 * DefaultStyle.dp
height: 24 * DefaultStyle.dp height: 24 * DefaultStyle.dp

View file

@ -11,7 +11,7 @@ ColumnLayout {
FormItemLayout { FormItemLayout {
id: username id: username
label: "Username" label: qsTr("Nom d'utilisateur")
mandatory: true mandatory: true
enableErrorText: true enableErrorText: true
contentItem: TextField { contentItem: TextField {
@ -22,6 +22,10 @@ ColumnLayout {
when: errorText.opacity != 0 when: errorText.opacity != 0
value: DefaultStyle.danger_500main value: DefaultStyle.danger_500main
} }
Binding on backgroundBorderColor {
when: username.errorTextItem.opacity != 0
value: DefaultStyle.danger_500main
}
Binding on color { Binding on color {
when: errorText.opacity != 0 when: errorText.opacity != 0
value: DefaultStyle.danger_500main value: DefaultStyle.danger_500main
@ -32,7 +36,7 @@ ColumnLayout {
Layout.preferredHeight: password.implicitHeight Layout.preferredHeight: password.implicitHeight
FormItemLayout { FormItemLayout {
id: password id: password
label: "Password" label: qsTr("Mot de passe")
mandatory: true mandatory: true
enableErrorText: true enableErrorText: true
contentItem: TextField { contentItem: TextField {
@ -44,6 +48,10 @@ ColumnLayout {
when: errorText.opacity != 0 when: errorText.opacity != 0
value: DefaultStyle.danger_500main value: DefaultStyle.danger_500main
} }
Binding on backgroundBorderColor {
when: password.errorTextItem.opacity != 0
value: DefaultStyle.danger_500main
}
Binding on color { Binding on color {
when: errorText.opacity != 0 when: errorText.opacity != 0
value: DefaultStyle.danger_500main value: DefaultStyle.danger_500main
@ -119,9 +127,9 @@ ColumnLayout {
if (usernameEdit.text.length == 0 || passwordEdit.text.length == 0) { if (usernameEdit.text.length == 0 || passwordEdit.text.length == 0) {
if (usernameEdit.text.length == 0) if (usernameEdit.text.length == 0)
username.errorMessage = qsTr("You must enter a username") username.errorMessage = qsTr("Veuillez saisir un nom d'utilisateur")
if (passwordEdit.text.length == 0) if (passwordEdit.text.length == 0)
password.errorMessage = qsTr("You must enter a password") password.errorMessage = qsTr("Veuillez saisir un mot de passe")
return return
} }
LoginPageCpp.login(usernameEdit.text, passwordEdit.text) LoginPageCpp.login(usernameEdit.text, passwordEdit.text)
@ -141,7 +149,7 @@ ColumnLayout {
} }
contentItem: Text { contentItem: Text {
color: DefaultStyle.main2_500main color: DefaultStyle.main2_500main
text: "Forgotten password?" text: qsTr("Mot de passe oublié ?")
font{ font{
underline: true underline: true
pixelSize: 13 * DefaultStyle.dp pixelSize: 13 * DefaultStyle.dp

View file

@ -10,6 +10,7 @@ ColumnLayout {
property string label: "" property string label: ""
property bool mandatory: false property bool mandatory: false
property alias errorTextItem: errorText
property alias errorMessage: errorText.text property alias errorMessage: errorText.text
property bool enableErrorText: false property bool enableErrorText: false
property bool errorTextVisible: errorText.opacity > 0 property bool errorTextVisible: errorText.opacity > 0

View file

@ -59,7 +59,11 @@ AbstractMainPage {
id: dialog id: dialog
property var contact property var contact
text: (contact ? contact.core.displayName : "Contact") + " is about to be deleted. Do you want to continue ?" text: (contact ? contact.core.displayName : "Contact") + " is about to be deleted. Do you want to continue ?"
onAccepted: contact.core.remove() onAccepted: {
var name = contact.core.displayName
contact.core.remove()
UtilsCpp.showInformationPopup(qsTr("Supprimé"), qsTr("%1 a été supprimé").arg(name))
}
} }
Popup { Popup {
@ -188,6 +192,7 @@ AbstractMainPage {
spacing: 38 * DefaultStyle.dp spacing: 38 * DefaultStyle.dp
SearchBar { SearchBar {
id: searchBar id: searchBar
visible: contactList.count > 0
Layout.leftMargin: leftPanel.leftMargin Layout.leftMargin: leftPanel.leftMargin
Layout.rightMargin: leftPanel.rightMargin Layout.rightMargin: leftPanel.rightMargin
Layout.topMargin: 18 * DefaultStyle.dp Layout.topMargin: 18 * DefaultStyle.dp
@ -213,16 +218,18 @@ AbstractMainPage {
// anchors.fill: parent // anchors.fill: parent
spacing: 15 * DefaultStyle.dp spacing: 15 * DefaultStyle.dp
Text { Text {
visible: contactList.count === 0 && favoriteList.count === 0
Layout.alignment: Qt.AlignHCenter
Layout.topMargin: 137 * DefaultStyle.dp
text: qsTr("Aucun contact") text: qsTr("Aucun contact")
font { font {
pixelSize: 16 * DefaultStyle.dp pixelSize: 16 * DefaultStyle.dp
weight: 800 * DefaultStyle.dp weight: 800 * DefaultStyle.dp
} }
visible: contactList.count === 0 && favoriteList.count === 0
Layout.alignment: Qt.AlignHCenter
} }
ColumnLayout { ColumnLayout {
visible: favoriteList.contentHeight > 0 visible: favoriteList.contentHeight > 0
onVisibleChanged: if (visible && !favoriteList.visible) favoriteList.visible = true
Layout.leftMargin: leftPanel.leftMargin Layout.leftMargin: leftPanel.leftMargin
Layout.rightMargin: leftPanel.rightMargin Layout.rightMargin: leftPanel.rightMargin
spacing: 18 * DefaultStyle.dp spacing: 18 * DefaultStyle.dp
@ -271,6 +278,7 @@ AbstractMainPage {
} }
ColumnLayout { ColumnLayout {
visible: contactList.count > 0 visible: contactList.count > 0
onVisibleChanged: if (visible && !contactList.visible) contactList.visible = true
Layout.leftMargin: leftPanel.leftMargin Layout.leftMargin: leftPanel.leftMargin
Layout.rightMargin: leftPanel.rightMargin Layout.rightMargin: leftPanel.rightMargin
spacing: 16 * DefaultStyle.dp spacing: 16 * DefaultStyle.dp