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
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: [
Text {
anchors.left: parent.left
@ -49,9 +59,7 @@ RightPanelLayout {
icon.width: 24 * DefaultStyle.dp
icon.height: 24 * DefaultStyle.dp
onClicked: {
// contact.core.pictureUri = mainItem.oldPictureUri
mainItem.contact.core.undo()
mainItem.closeEdition()
confirmDialog.open()
}
}
]
@ -119,11 +127,15 @@ RightPanelLayout {
ColumnLayout {
spacing: 20 * DefaultStyle.dp
FormItemLayout {
id: givenName
enableErrorText: true
label: qsTr("Prénom")
contentItem: TextField {
id: givenNameEdit
initialText: contact.core.givenName
onEditingFinished: contact.core.givenName = text
backgroundColor: DefaultStyle.grey_0
backgroundBorderColor: givenName.errorTextItem.opacity != 0 ? DefaultStyle.danger_500main : DefaultStyle.grey_200
}
}
FormItemLayout {
@ -160,6 +172,7 @@ RightPanelLayout {
anchors.rightMargin: 10 * DefaultStyle.dp
spacing: 20 * DefaultStyle.dp
Repeater {
id: addressesList
model: VariantList {
model: mainItem.contact && mainItem.contact.core.addresses || []
}
@ -200,6 +213,10 @@ RightPanelLayout {
if (text.length != 0) mainItem.contact.core.appendAddress(text)
text = ""
}
onFocusChanged: if (!focus && text.length != 0) {
mainItem.contact.core.appendAddress(text)
text = ""
}
}
}
Item {
@ -253,6 +270,12 @@ RightPanelLayout {
Layout.preferredHeight: 24 * DefaultStyle.dp
}
}
ErrorText {
id: addressesErrorText
wrapMode: Qt.WordWrap
elide: Text.ElideRight
Layout.fillWidth: true
}
Item{Layout.fillHeight: true}
}
Control.ScrollBar.vertical: Control.ScrollBar{
@ -275,13 +298,21 @@ RightPanelLayout {
Layout.bottomMargin: 100 * DefaultStyle.dp
Layout.preferredWidth: 165 * DefaultStyle.dp
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
leftPadding: 20 * DefaultStyle.dp
rightPadding: 20 * DefaultStyle.dp
topPadding: 11 * DefaultStyle.dp
bottomPadding: 11 * DefaultStyle.dp
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.closeEdition()
}

View file

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

View file

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

View file

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

View file

@ -59,7 +59,11 @@ AbstractMainPage {
id: dialog
property var contact
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 {
@ -188,6 +192,7 @@ AbstractMainPage {
spacing: 38 * DefaultStyle.dp
SearchBar {
id: searchBar
visible: contactList.count > 0
Layout.leftMargin: leftPanel.leftMargin
Layout.rightMargin: leftPanel.rightMargin
Layout.topMargin: 18 * DefaultStyle.dp
@ -213,16 +218,18 @@ AbstractMainPage {
// anchors.fill: parent
spacing: 15 * DefaultStyle.dp
Text {
visible: contactList.count === 0 && favoriteList.count === 0
Layout.alignment: Qt.AlignHCenter
Layout.topMargin: 137 * DefaultStyle.dp
text: qsTr("Aucun contact")
font {
pixelSize: 16 * DefaultStyle.dp
weight: 800 * DefaultStyle.dp
}
visible: contactList.count === 0 && favoriteList.count === 0
Layout.alignment: Qt.AlignHCenter
}
ColumnLayout {
visible: favoriteList.contentHeight > 0
onVisibleChanged: if (visible && !favoriteList.visible) favoriteList.visible = true
Layout.leftMargin: leftPanel.leftMargin
Layout.rightMargin: leftPanel.rightMargin
spacing: 18 * DefaultStyle.dp
@ -271,6 +278,7 @@ AbstractMainPage {
}
ColumnLayout {
visible: contactList.count > 0
onVisibleChanged: if (visible && !contactList.visible) contactList.visible = true
Layout.leftMargin: leftPanel.leftMargin
Layout.rightMargin: leftPanel.rightMargin
spacing: 16 * DefaultStyle.dp