Commit 0ce9a5d5 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(views/App/MainWindow/ContactEdit): view in progress, use better lists

parent f4c56c99
<?xml version="1.0" encoding="UTF-8"?>
<svg width="18px" height="18px" viewBox="0 0 18 18" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 41.2 (35397) - http://www.bohemiancoding.com/sketch -->
<title>add_disabled</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="Symbols" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" stroke-linecap="round">
<g id="add_disabled" stroke="#D0D8DE">
<path d="M9,17.5 C4.305875,17.5 0.5,13.694125 0.5,9 C0.5,4.3056625 4.305875,0.5 9,0.5 C13.694975,0.5 17.5,4.3056625 17.5,9 C17.5,13.694125 13.694975,17.5 9,17.5 Z" stroke-linejoin="round"></path>
<path d="M9.01666657,6 L9.01666657,11.8333333"></path>
<path d="M6.0999999,8.91666667 L11.9333332,8.91666667"></path>
</g>
</g>
</svg>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<svg width="18px" height="18px" viewBox="0 0 18 18" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 41.2 (35397) - http://www.bohemiancoding.com/sketch -->
<title>add_over</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="Symbols" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" stroke-linecap="round">
<g id="add_over" stroke="#4B5964">
<path d="M9,17.5 C4.305875,17.5 0.5,13.694125 0.5,9 C0.5,4.3056625 4.305875,0.5 9,0.5 C13.694975,0.5 17.5,4.3056625 17.5,9 C17.5,13.694125 13.694975,17.5 9,17.5 Z" stroke-linejoin="round"></path>
<path d="M9.01666657,6 L9.01666657,11.8333333"></path>
<path d="M6.0999999,8.91666667 L11.9333332,8.91666667"></path>
</g>
</g>
</svg>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<svg width="18px" height="18px" viewBox="0 0 18 18" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 41.2 (35397) - http://www.bohemiancoding.com/sketch -->
<title>add_default</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="Symbols" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" stroke-linecap="round">
<g id="add_default" stroke="#96A6B1">
<path d="M9,17.5 C4.305875,17.5 0.5,13.694125 0.5,9 C0.5,4.3056625 4.305875,0.5 9,0.5 C13.694975,0.5 17.5,4.3056625 17.5,9 C17.5,13.694125 13.694975,17.5 9,17.5 Z" stroke-linejoin="round"></path>
<path d="M9.01666657,6 L9.01666657,11.8333333"></path>
<path d="M6.0999999,8.91666667 L11.9333332,8.91666667"></path>
</g>
</g>
</svg>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<svg width="18px" height="18px" viewBox="0 0 18 18" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 41.2 (35397) - http://www.bohemiancoding.com/sketch -->
<title>add_clic</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="Symbols" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" stroke-linecap="round">
<g id="add_clic" stroke="#FF5E00">
<path d="M17.5,9 C17.5,13.694125 13.694975,17.5 9,17.5 C4.305875,17.5 0.5,13.694125 0.5,9 C0.5,4.3056625 4.305875,0.5 9,0.5 C13.694975,0.5 17.5,4.3056625 17.5,9 L17.5,9 Z" stroke-linejoin="round"></path>
<path d="M9.01666657,6 L9.01666657,11.8333333"></path>
<path d="M6.0999999,8.91666667 L11.9333332,8.91666667"></path>
</g>
</g>
</svg>
\ No newline at end of file
<!DOCTYPE RCC><RCC version="1.0"> <!DOCTYPE RCC><RCC version="1.0">
<qresource prefix="/"> <qresource prefix="/">
<file>assets/images/add_disabled.svg</file>
<file>assets/images/add_hovered.svg</file>
<file>assets/images/add_normal.svg</file>
<file>assets/images/add_pressed.svg</file>
<file>assets/images/attachment_hovered.svg</file> <file>assets/images/attachment_hovered.svg</file>
<file>assets/images/attachment_normal.svg</file> <file>assets/images/attachment_normal.svg</file>
<file>assets/images/attachment_pressed.svg</file> <file>assets/images/attachment_pressed.svg</file>
......
...@@ -31,6 +31,15 @@ QString ContactModel::getUsername () const { ...@@ -31,6 +31,15 @@ QString ContactModel::getUsername () const {
); );
} }
bool ContactModel::setUsername (const QString &username) {
if (username.length() == 0)
return false;
return !m_linphone_friend->setName(
Utils::qStringToLinphoneString(username)
);
}
QString ContactModel::getAvatar () const { QString ContactModel::getAvatar () const {
// Find desktop avatar. // Find desktop avatar.
list<shared_ptr<belcard::BelCardPhoto> > photos = list<shared_ptr<belcard::BelCardPhoto> > photos =
......
...@@ -17,6 +17,7 @@ class ContactModel : public QObject { ...@@ -17,6 +17,7 @@ class ContactModel : public QObject {
Q_PROPERTY( Q_PROPERTY(
QString username QString username
READ getUsername READ getUsername
WRITE setUsername
NOTIFY contactUpdated NOTIFY contactUpdated
); );
...@@ -56,6 +57,7 @@ signals: ...@@ -56,6 +57,7 @@ signals:
private: private:
QString getUsername () const; QString getUsername () const;
bool setUsername (const QString &username);
QString getAvatar () const; QString getAvatar () const;
bool setAvatar (const QString &path); bool setAvatar (const QString &path);
......
...@@ -7,24 +7,32 @@ import Common 1.0 ...@@ -7,24 +7,32 @@ import Common 1.0
// An animated (or not) button with image(s). // An animated (or not) button with image(s).
// =================================================================== // ===================================================================
Button { Item {
id: button id: wrappedButton
property bool enabled: true
property bool useStates: true property bool useStates: true
property int iconSize // Optionnal. property int iconSize // Optionnal.
readonly property alias hovered: button.hovered
// If `useStates` = true, the used icons are: // If `useStates` = true, the used icons are:
// `icon`_pressed, `icon`_hovered and `icon`_normal. // `icon`_pressed, `icon`_hovered and `icon`_normal.
property string icon property string icon
signal clicked
// ----------------------------------------------------------------- // -----------------------------------------------------------------
function _getIcon () { function _getIcon () {
if (!useStates) { if (!useStates) {
return button.icon return wrappedButton.icon
}
if (!wrappedButton.enabled) {
return wrappedButton.icon + '_disabled'
} }
return button.icon + ( return wrappedButton.icon + (
button.down button.down
? '_pressed' ? '_pressed'
: (button.hovered ? '_hovered' : '_normal') : (button.hovered ? '_hovered' : '_normal')
...@@ -33,21 +41,28 @@ Button { ...@@ -33,21 +41,28 @@ Button {
// ----------------------------------------------------------------- // -----------------------------------------------------------------
background: Rectangle {
color: 'transparent'
}
hoverEnabled: true
height: iconSize || parent.iconSize || parent.height height: iconSize || parent.iconSize || parent.height
width: iconSize || parent.iconSize || parent.height width: iconSize || parent.iconSize || parent.height
Icon { Button {
id: icon id: button
anchors.centerIn: parent anchors.fill: parent
icon: _getIcon() background: Rectangle {
iconSize: parent.iconSize || ( color: 'transparent'
parent.width > parent.height ? parent.height : parent.width }
) hoverEnabled: true
onClicked: wrappedButton.enabled && wrappedButton.clicked()
Icon {
id: icon
anchors.centerIn: parent
icon: _getIcon()
iconSize: parent.iconSize || (
parent.width > parent.height ? parent.height : parent.width
)
}
} }
} }
...@@ -4,11 +4,10 @@ import QtQuick 2.7 ...@@ -4,11 +4,10 @@ import QtQuick 2.7
Item { Item {
property alias useStates: actionButton.useStates property alias useStates: actionButton.useStates
property bool enabled: true
property int iconSize // Optionnal. property int iconSize // Optionnal.
property string icon property string icon
property bool enabled: true
signal clicked signal clicked
// ----------------------------------------------------------------- // -----------------------------------------------------------------
......
...@@ -10,15 +10,16 @@ RowLayout { ...@@ -10,15 +10,16 @@ RowLayout {
id: listForm id: listForm
property alias model: values.model property alias model: values.model
property alias placeholder: placeholder.text
property alias title: text.text property alias title: text.text
property string placeholder
// -----------------------------------------------------------------
function _addValue (value) { function _addValue (value) {
if ( model.append({ $value: value })
model.count === 0 ||
model.get(model.count - 1).$value.length !== 0 if (value.length === 0) {
) { addButton.enabled = false
model.append({ $value: value })
} }
} }
...@@ -28,86 +29,102 @@ RowLayout { ...@@ -28,86 +29,102 @@ RowLayout {
} else { } else {
model.set(index, { $value: text }) model.set(index, { $value: text })
} }
addButton.enabled = true
} }
// -----------------------------------------------------------------
spacing: 0 spacing: 0
// -----------------------------------------------------------------
// Title area. // Title area.
// -----------------------------------------------------------------
RowLayout { RowLayout {
Layout.alignment: Qt.AlignTop Layout.alignment: Qt.AlignTop
Layout.preferredHeight: ListFormStyle.lineHeight Layout.preferredHeight: ListFormStyle.lineHeight
spacing: ListFormStyle.titleArea.spacing spacing: ListFormStyle.titleArea.spacing
// Button: Add item in list.
ActionButton { ActionButton {
Layout.preferredHeight: ListFormStyle.titleArea.iconSize id: addButton
Layout.preferredWidth: ListFormStyle.titleArea.iconSize
icon: 'add_field' icon: 'add'
iconSize: ListFormStyle.titleArea.iconSize
onClicked: _addValue('') onClicked: _addValue('')
} }
// Title text.
Text { Text {
id: text id: text
Layout.preferredWidth: ListFormStyle.titleArea.text.width Layout.preferredWidth: ListFormStyle.titleArea.text.width
color: ListFormStyle.titleArea.text.color color: ListFormStyle.titleArea.text.color
font.pointSize: ListFormStyle.titleArea.text.fontSize elide: Text.ElideRight
font {
bold: true
pointSize: ListFormStyle.titleArea.text.fontSize
}
}
}
// -----------------------------------------------------------------
// Placeholder.
// -----------------------------------------------------------------
Text {
id: placeholder
Layout.fillWidth: true
Layout.preferredHeight: ListFormStyle.lineHeight
color: ListFormStyle.value.placeholder.color
font {
italic: true
pointSize: ListFormStyle.value.placeholder.fontSize
} }
padding: ListFormStyle.value.text.padding
visible: model.count === 0
verticalAlignment: Text.AlignVCenter
} }
// -----------------------------------------------------------------
// Values. // Values.
// -----------------------------------------------------------------
ListView { ListView {
id: values id: values
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: count * ListFormStyle.lineHeight Layout.preferredHeight: count * ListFormStyle.lineHeight
interactive: false interactive: false
visible: count > 0
delegate: Item { delegate: Item {
implicitHeight: textEdit.height implicitHeight: textEdit.height
width: parent.width width: parent.width
// Background.
Rectangle { Rectangle {
color: textEdit.activeFocus color: textEdit.activeFocus
? ListFormStyle.value.backgroundColor.focused ? ListFormStyle.value.backgroundColor.focused
: ListFormStyle.value.backgroundColor.normal : ListFormStyle.value.backgroundColor.normal
implicitHeight: textEdit.height
implicitWidth: textEdit.width
}
// Placeholder.
Text {
anchors.fill: textEdit anchors.fill: textEdit
color: ListFormStyle.value.placeholder.color
font {
italic: true
pointSize: ListFormStyle.value.placeholder.fontSize
}
padding: textEdit.padding
text: textEdit.text.length === 0 && !textEdit.activeFocus
? listForm.placeholder
: ''
verticalAlignment: Text.AlignVCenter
} }
// Input.
TextEdit { TextEdit {
id: textEdit id: textEdit
color: activeFocus color: activeFocus
? ListFormStyle.value.text.color.focused ? ListFormStyle.value.text.color.focused
: ListFormStyle.value.text.color.normal : ListFormStyle.value.text.color.normal
font.bold: !activeFocus
height: ListFormStyle.lineHeight
padding: ListFormStyle.value.text.padding padding: ListFormStyle.value.text.padding
selectByMouse: true selectByMouse: true
text: $value text: $value
verticalAlignment: TextEdit.AlignVCenter verticalAlignment: TextEdit.AlignVCenter
height: ListFormStyle.lineHeight
width: !activeFocus width: !activeFocus
? parent.width ? parent.width
: contentWidth + padding * 2 : contentWidth + padding * 2
...@@ -116,15 +133,18 @@ RowLayout { ...@@ -116,15 +133,18 @@ RowLayout {
Keys.onReturnPressed: focus = false Keys.onReturnPressed: focus = false
onEditingFinished: _handleEditionFinished(index, text) onEditingFinished: _handleEditionFinished(index, text)
}
// Handle click outside `TextEdit` instance. InvertedMouseArea {
InvertedMouseArea { anchors.fill: parent
enabled: textEdit.activeFocus enabled: textEdit.activeFocus
height: textEdit.height onPressed: textEdit.focus = false
width: textEdit.width }
}
onPressed: textEdit.focus = false Component.onCompleted: {
if ($value.length === 0) {
textEdit.forceActiveFocus()
}
} }
} }
} }
......
...@@ -6,9 +6,9 @@ Item { ...@@ -6,9 +6,9 @@ Item {
id: item id: item
property alias source: image.source property alias source: image.source
property alias status: image.status // READONLY!!!
property color backgroundColor: '#00000000' property color backgroundColor: '#00000000'
property color foregroundColor: '#00000000' property color foregroundColor: '#00000000'
readonly property alias status: image.status
Item { Item {
id: imageContainer id: imageContainer
......
...@@ -15,7 +15,7 @@ QtObject { ...@@ -15,7 +15,7 @@ QtObject {
} }
property QtObject placeholder: QtObject { property QtObject placeholder: QtObject {
property color color: Colors.d property color color: Colors.w
property int fontSize: 10 property int fontSize: 10
} }
...@@ -24,18 +24,18 @@ QtObject { ...@@ -24,18 +24,18 @@ QtObject {
property QtObject color: QtObject { property QtObject color: QtObject {
property color focused: Colors.l property color focused: Colors.l
property color normal: Colors.d property color normal: Colors.r
} }
} }
} }
property QtObject titleArea: QtObject { property QtObject titleArea: QtObject {
property int spacing: 10 property int spacing: 10
property int iconSize: 16 property int iconSize: 18
property QtObject text: QtObject { property QtObject text: QtObject {
property color color: Colors.l property color color: Colors.j
property int fontSize: 10 property int fontSize: 9
property int width: 130 property int width: 130
} }
} }
......
...@@ -21,8 +21,6 @@ ColumnLayout { ...@@ -21,8 +21,6 @@ ColumnLayout {
sipAddress sipAddress
) || sipAddress ) || sipAddress
property var _info: {}
// ----------------------------------------------------------------- // -----------------------------------------------------------------
function _removeContact () { function _removeContact () {
...@@ -82,10 +80,8 @@ ColumnLayout { ...@@ -82,10 +80,8 @@ ColumnLayout {
spacing: ContactEditStyle.infoBar.spacing spacing: ContactEditStyle.infoBar.spacing
ActionButton { ActionButton {
Layout.preferredHeight: ContactEditStyle.infoBar.avatarSize
Layout.preferredWidth: ContactEditStyle.infoBar.avatarSize
icon: 'contact_card_photo' icon: 'contact_card_photo'
iconSize: ContactEditStyle.infoBar.avatarSize
onClicked: avatarChooser.open() onClicked: avatarChooser.open()
...@@ -141,6 +137,7 @@ ColumnLayout { ...@@ -141,6 +137,7 @@ ColumnLayout {
Flickable { Flickable {
Layout.fillHeight: true Layout.fillHeight: true
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 40
ScrollBar.vertical: ForceScrollBar {} ScrollBar.vertical: ForceScrollBar {}
boundsBehavior: Flickable.StopAtBounds boundsBehavior: Flickable.StopAtBounds
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment