Commit 3839f917 authored by Ronan's avatar Ronan
Browse files

feat(ui/views/App/MainWindow/ContactEdit): display contact addresses

parent 534c5f0a
......@@ -112,11 +112,11 @@
</message>
<message>
<source>sipAccountsInput</source>
<translation type="unfinished">SIP Address</translation>
<translation type="obsolete">SIP Address</translation>
</message>
<message>
<source>address</source>
<translation type="obsolete">ADDRESS</translation>
<translation type="unfinished">ADDRESS</translation>
</message>
<message>
<source>addressInput</source>
......@@ -128,7 +128,7 @@
</message>
<message>
<source>emailsInput</source>
<translation type="unfinished">E-mail address</translation>
<translation type="obsolete">E-mail address</translation>
</message>
<message>
<source>webSites</source>
......@@ -136,7 +136,7 @@
</message>
<message>
<source>webSitesInput</source>
<translation type="unfinished">URL</translation>
<translation type="obsolete">URL</translation>
</message>
<message>
<source>avatarChooserTitle</source>
......@@ -144,7 +144,7 @@
</message>
<message>
<source>companiesInput</source>
<translation>Company</translation>
<translation type="vanished">Company</translation>
</message>
<message>
<source>companies</source>
......@@ -158,6 +158,38 @@
<source>cancel</source>
<translation>CANCEL</translation>
</message>
<message>
<source>sipAccountsPlaceholder</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>companiesPlaceholder</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>emailsPlaceholder</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>webSitesPlaceholder</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>street</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>postalCode</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>country</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>locality</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Contacts</name>
......
......@@ -104,11 +104,11 @@
</message>
<message>
<source>sipAccountsInput</source>
<translation type="unfinished">Adresse SIP</translation>
<translation type="obsolete">Adresse SIP</translation>
</message>
<message>
<source>address</source>
<translation type="obsolete">ADRESSE(S)</translation>
<translation type="unfinished">ADRESSE(S)</translation>
</message>
<message>
<source>addressInput</source>
......@@ -120,7 +120,7 @@
</message>
<message>
<source>emailsInput</source>
<translation type="unfinished">Adresse e-mail</translation>
<translation type="obsolete">Adresse e-mail</translation>
</message>
<message>
<source>webSites</source>
......@@ -128,16 +128,12 @@
</message>
<message>
<source>webSitesInput</source>
<translation type="unfinished">URL</translation>
<translation type="obsolete">URL</translation>
</message>
<message>
<source>avatarChooserTitle</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>companiesInput</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>companies</source>
<translation type="unfinished"></translation>
......@@ -150,6 +146,38 @@
<source>cancel</source>
<translation type="unfinished">ANNULER</translation>
</message>
<message>
<source>sipAccountsPlaceholder</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>companiesPlaceholder</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>emailsPlaceholder</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>webSitesPlaceholder</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>street</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>postalCode</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>country</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>locality</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Contacts</name>
......
......@@ -143,6 +143,7 @@
<file>ui/modules/Common/Form/ExclusiveButtons.qml</file>
<file>ui/modules/Common/Form/ListForm.qml</file>
<file>ui/modules/Common/Form/SmallButton.qml</file>
<file>ui/modules/Common/Form/StaticListForm.qml</file>
<file>ui/modules/Common/Form/TextButtonA.qml</file>
<file>ui/modules/Common/Form/TextButtonB.qml</file>
<file>ui/modules/Common/Form/TextField.qml</file>
......
import QtQuick 2.7
// ===================================================================
// =============================================================================
Item {
property alias useStates: actionButton.useStates
......@@ -10,7 +10,7 @@ Item {
signal clicked
// -----------------------------------------------------------------
// ---------------------------------------------------------------------------
height: iconSize || parent.iconSize || parent.height
width: iconSize || parent.iconSize || parent.height
......
......@@ -2,7 +2,7 @@ import QtQuick 2.7
import Common.Styles 1.0
// ===================================================================
// =============================================================================
Row {
id: item
......
import QtQuick 2.7
import QtQuick.Layouts 1.3
import Common.Styles 1.0
// =============================================================================
RowLayout {
id: form
property alias title: text.text
property bool readOnly: false
property var fields
// ---------------------------------------------------------------------------
spacing: 0
Text {
id: text
Layout.leftMargin: ListFormStyle.titleArea.iconSize + ListFormStyle.titleArea.spacing
Layout.preferredHeight: ListFormStyle.lineHeight
Layout.preferredWidth: ListFormStyle.titleArea.text.width
Layout.alignment: Qt.AlignTop
color: ListFormStyle.titleArea.text.color
elide: Text.ElideRight
font {
bold: true
pointSize: ListFormStyle.titleArea.text.fontSize
}
verticalAlignment: Text.AlignVCenter
}
ColumnLayout {
Layout.fillWidth: true
spacing: 0
Repeater {
model: form.fields
TransparentTextInput {
Layout.fillWidth: true
Layout.preferredHeight: ListFormStyle.lineHeight
placeholder: modelData.placeholder || ''
readOnly: form.readOnly
text: modelData.text || ''
}
}
}
}
......@@ -11,6 +11,7 @@ Item {
property alias color: textInput.color
property alias font: textInput.font
property alias inputMethodHints: textInput.inputMethodHints
property alias placeholder: placeholder.text
property alias readOnly: textInput.readOnly
property alias text: textInput.text
property bool forceFocus: false
......@@ -59,17 +60,37 @@ Item {
visible: parent.isInvalid
}
Text {
id: placeholder
anchors.centerIn: parent
color: TransparentTextInputStyle.placeholder.color
elide: Text.ElideRight
font {
italic: true
pointSize: TransparentTextInputStyle.placeholder.fontSize
}
height: textInput.height
width: textInput.width
verticalAlignment: Text.AlignVCenter
visible: textInput.text.length === 0 && !textInput.activeFocus && !textInput.readOnly
}
TextInput {
id: textInput
anchors.centerIn: parent
height: parent.height - parent.padding * 2
height: parent.height
width: parent.width - parent.padding * 2
clip: true
color: activeFocus && !readOnly
? TransparentTextInputStyle.textColor.focused
: TransparentTextInputStyle.textColor.normal
? TransparentTextInputStyle.text.color.focused
: TransparentTextInputStyle.text.color.normal
font.pointSize: TransparentTextInputStyle.text.fontSize
selectByMouse: true
verticalAlignment: TextInput.AlignVCenter
......
......@@ -10,8 +10,17 @@ QtObject {
property int iconSize: 12
property int padding: 10
property QtObject textColor: QtObject {
property color focused: Colors.l
property color normal: Colors.r
property QtObject placeholder: QtObject {
property color color: Colors.w
property int fontSize: 10
}
property QtObject text: QtObject {
property int fontSize: 10
property QtObject color: QtObject {
property color focused: Colors.l
property color normal: Colors.r
}
}
}
......@@ -38,6 +38,7 @@ CheckBoxText 1.0 Form/CheckBoxText.qml
ExclusiveButtons 1.0 Form/ExclusiveButtons.qml
LightButton 1.0 Form/LightButton.qml
ListForm 1.0 Form/ListForm.qml
StaticListForm 1.0 Form/StaticListForm.qml
TextButtonA 1.0 Form/TextButtonA.qml
TextButtonB 1.0 Form/TextButtonB.qml
TextField 1.0 Form/TextField.qml
......
......@@ -70,35 +70,6 @@ ColumnLayout {
usernameInput.text = _vcard.username
}
function _handleSipAddressChanged (index, defaultValue, newValue) {
if (!Utils.startsWith(newValue, 'sip:')) {
newValue = 'sip:' + newValue
if (newValue === defaultValue) {
return
}
}
var so_far_so_good = (defaultValue.length === 0)
? _vcard.addSipAddress(newValue)
: _vcard.updateSipAddress(defaultValue, newValue)
addresses.setInvalid(index, !so_far_so_good)
}
function _handleUrlChanged (index, defaultValue, newValue) {
var url = Utils.extractFirstUri(newValue)
if (url === defaultValue) {
return
}
var so_far_so_good = (defaultValue.length === 0)
? url && _vcard.addUrl(newValue)
: url && _vcard.updateUrl(defaultValue, newValue)
urls.setInvalid(index, !so_far_so_good)
}
// ---------------------------------------------------------------------------
spacing: 0
......@@ -218,140 +189,215 @@ ColumnLayout {
// Info list.
// ---------------------------------------------------------------------------
Flickable {
id: flick
Loader {
Layout.fillHeight: true
Layout.fillWidth: true
ScrollBar.vertical: ForceScrollBar {}
boundsBehavior: Flickable.StopAtBounds
clip: true
contentHeight: infoList.height
contentWidth: width - ScrollBar.vertical.width
flickableDirection: Flickable.VerticalFlick
active: _vcard != null
sourceComponent: Flickable {
id: flick
ColumnLayout {
id: infoList
width: flick.contentWidth
// -----------------------------------------------------------------------
ListForm {
id: addresses
function _handleSipAddressChanged (index, defaultValue, newValue) {
if (!Utils.startsWith(newValue, 'sip:')) {
newValue = 'sip:' + newValue
Layout.leftMargin: ContactEditStyle.values.leftMargin
Layout.rightMargin: ContactEditStyle.values.rightMargin
Layout.topMargin: ContactEditStyle.values.topMargin
if (newValue === defaultValue) {
return
}
}
defaultData: _vcard.sipAddresses
minValues: _contact ? 1 : 0
placeholder: qsTr('sipAccountsInput')
readOnly: !_edition
title: qsTr('sipAccounts')
var so_far_so_good = (defaultValue.length === 0)
? _vcard.addSipAddress(newValue)
: _vcard.updateSipAddress(defaultValue, newValue)
onChanged: _handleSipAddressChanged(index, defaultValue, newValue)
onRemoved: _vcard.removeSipAddress(value)
addresses.setInvalid(index, !so_far_so_good)
}
Rectangle {
Layout.fillWidth: true
Layout.preferredHeight: ContactEditStyle.values.separator.height
color: ContactEditStyle.values.separator.color
function _handleCompanyChanged (index, defaultValue, newValue) {
var so_far_so_good = (defaultValue.length === 0)
? _vcard.addCompany(newValue)
: _vcard.updateCompany(defaultValue, newValue)
companies.setInvalid(index, !so_far_so_good)
}
ListForm {
id: companies
function _handleEmailChanged (index, defaultValue, newValue) {
var so_far_so_good = (defaultValue.length === 0)
? _vcard.addEmail(newValue)
: _vcard.updateEmail(defaultValue, newValue)
Layout.leftMargin: ContactEditStyle.values.leftMargin
Layout.rightMargin: ContactEditStyle.values.rightMargin
emails.setInvalid(index, !so_far_so_good)
}
defaultData: _vcard.companies
placeholder: qsTr('companiesInput')
readOnly: !_edition
title: qsTr('companies')
function _handleUrlChanged (index, defaultValue, newValue) {
var url = Utils.extractFirstUri(newValue)
if (url === defaultValue) {
return
}
onChanged: defaultValue.length === 0
? _vcard.addCompany(newValue)
: _vcard.updateCompany(defaultValue, newValue)
onRemoved: _vcard.removeCompany(value)
}
var so_far_so_good = (defaultValue.length === 0)
? url && _vcard.addUrl(newValue)
: url && _vcard.updateUrl(defaultValue, newValue)
Rectangle {
Layout.fillWidth: true
Layout.preferredHeight: ContactEditStyle.values.separator.height
color: ContactEditStyle.values.separator.color
urls.setInvalid(index, !so_far_so_good)
}
ListForm {
id: emails
// -----------------------------------------------------------------------
Layout.leftMargin: ContactEditStyle.values.leftMargin
Layout.rightMargin: ContactEditStyle.values.rightMargin
ScrollBar.vertical: ForceScrollBar {}
defaultData: _vcard.emails
inputMethodHints: Qt.ImhEmailCharactersOnly
placeholder: qsTr('emailsInput')
readOnly: !_edition
title: qsTr('emails')
boundsBehavior: Flickable.StopAtBounds
clip: true
contentHeight: infoList.height
contentWidth: width - ScrollBar.vertical.width
flickableDirection: Flickable.VerticalFlick
onChanged: defaultValue.length === 0
? _vcard.addEmail(newValue)
: _vcard.updateEmail(defaultValue, newValue)
onRemoved: _vcard.removeEmail(value)
}
ColumnLayout {
id: infoList
Rectangle {
Layout.fillWidth: true
Layout.preferredHeight: ContactEditStyle.values.separator.height
color: ContactEditStyle.values.separator.color
}
width: flick.contentWidth
ListForm {
id: urls
ListForm {
id: addresses
Layout.leftMargin: ContactEditStyle.values.leftMargin
Layout.rightMargin: ContactEditStyle.values.rightMargin
Layout.leftMargin: ContactEditStyle.values.leftMargin
Layout.rightMargin: ContactEditStyle.values.rightMargin
Layout.topMargin: ContactEditStyle.values.topMargin
defaultData: _vcard.urls
inputMethodHints: Qt.ImhUrlCharactersOnly
placeholder: qsTr('webSitesInput')
readOnly: !_edition
title: qsTr('webSites')
defaultData: _vcard.sipAddresses
minValues: _contact ? 1 : 0
placeholder: qsTr('sipAccountsPlaceholder')
readOnly: !_edition
title: qsTr('sipAccounts')
onChanged: _handleUrlChanged(index, defaultValue, newValue)
onRemoved: _vcard.removeUrl(value)
}
onChanged: _handleSipAddressChanged(index, defaultValue, newValue)
onRemoved: _vcard.removeSipAddress(value)
}
Rectangle {
Layout.fillWidth: true
Layout.preferredHeight: ContactEditStyle.values.separator.height
color: ContactEditStyle.values.separator.color
}
Rectangle {
Layout.fillWidth: true
Layout.preferredHeight: ContactEditStyle.values.separator.height
color: ContactEditStyle.values.separator.color
}
// -----------------------------------------------------------------------
// Edition buttons.
// -----------------------------------------------------------------------
ListForm {
id: companies
Layout.leftMargin: ContactEditStyle.values.leftMargin
Layout.rightMargin: ContactEditStyle.values.rightMargin
Row {
Layout.alignment: Qt.AlignHCenter
Layout.topMargin: ContactEditStyle.buttons.topMargin
spacing: ContactEditStyle.buttons.spacing
visible: _edition
defaultData: _vcard.companies
placeholder: qsTr('companiesPlaceholder')
readOnly: !_edition
title: qsTr('companies')
TextButtonB {
enabled: usernameInput.text.length > 0 && _vcard.sipAddresses.length > 0
text: qsTr('save')
onClicked: _save()
onChanged: _handleCompanyChanged(index, defaultValue, newValue)
onRemoved: _vcard.removeCompany(value)
}
TextButtonA {
text: qsTr('cancel')
onClicked: _cancel()
Rectangle {
Layout.fillWidth: true
Layout.preferredHeight: ContactEditStyle.values.separator.height
color: ContactEditStyle.values.separator.color
}
}
Item {
Layout.bottomMargin: ContactEditStyle.values.bottomMargin
ListForm {
id: emails
Layout.leftMargin: ContactEditStyle.values.leftMargin
Layout.rightMargin: ContactEditStyle.values.rightMargin
defaultData: _vcard.emails
inputMethodHints: Qt.ImhEmailCharactersOnly
placeholder: qsTr('emailsPlaceholder')
readOnly: !_edition
title: qsTr('emails')
onChanged: _handleEmailChanged(index, defaultValue, newValue)