Commit 0813eda3 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(Contact/Avatar): better `_computeInitials` function

parent 5640d2d4
...@@ -65,7 +65,7 @@ void addContextProperties (QQmlApplicationEngine &engine) { ...@@ -65,7 +65,7 @@ void addContextProperties (QQmlApplicationEngine &engine) {
if (component.isError()) { if (component.isError()) {
qWarning() << component.errors(); qWarning() << component.errors();
} else { } else {
context->setContextProperty("CallsWindow", component.create()); // context->setContextProperty("CallsWindow", component.create());
} }
// Models. // Models.
......
...@@ -50,10 +50,11 @@ Item { ...@@ -50,10 +50,11 @@ Item {
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
hoverEnabled: true
cursorShape: containsMouse cursorShape: containsMouse
? Qt.PointingHandCursor ? Qt.PointingHandCursor
: Qt.ArrowCursor : Qt.ArrowCursor
hoverEnabled: true
onClicked: Utils.openWindow('ManageAccounts', this) onClicked: Utils.openWindow('ManageAccounts', this)
} }
} }
...@@ -3,6 +3,7 @@ import QtGraphicalEffects 1.0 ...@@ -3,6 +3,7 @@ import QtGraphicalEffects 1.0
import Linphone 1.0 import Linphone 1.0
import Linphone.Styles 1.0 import Linphone.Styles 1.0
import Utils 1.0
// =================================================================== // ===================================================================
...@@ -11,15 +12,22 @@ Item { ...@@ -11,15 +12,22 @@ Item {
property alias presenceLevel: presenceLevel.level property alias presenceLevel: presenceLevel.level
property string username property string username
property var _initialsRegex: /^\s*([^\s]+)(?:\s+([^\s]+))?/
function _computeInitials () { function _computeInitials () {
var spaceIndex = username.indexOf(' ') var result = username.match(_initialsRegex)
var firstLetter = username.charAt(0)
if (spaceIndex === -1) { Utils.assert(
return firstLetter result != null,
} 'Unable to get initials of: \'' + username + '\''
)
return firstLetter + username.charAt(spaceIndex + 1) return result[1].charAt(0).toUpperCase() +
(
result[2] != null
? result[2].charAt(0).toUpperCase()
: ''
)
} }
// Image mask. (Circle) // Image mask. (Circle)
......
...@@ -17,9 +17,11 @@ Item { ...@@ -17,9 +17,11 @@ Item {
height: ContactStyle.height height: ContactStyle.height
RowLayout { RowLayout {
anchors.fill: parent anchors {
anchors.leftMargin: ContactStyle.leftMargin fill: parent
anchors.rightMargin: ContactStyle.rightMargin leftMargin: ContactStyle.leftMargin
rightMargin: ContactStyle.rightMargin
}
spacing: ContactStyle.spacing spacing: ContactStyle.spacing
Avatar { Avatar {
...@@ -27,7 +29,7 @@ Item { ...@@ -27,7 +29,7 @@ Item {
Layout.preferredHeight: ContactStyle.contentHeight Layout.preferredHeight: ContactStyle.contentHeight
Layout.preferredWidth: ContactStyle.contentHeight Layout.preferredWidth: ContactStyle.contentHeight
image: contact.image image: contact.avatar
presenceLevel: contact.presenceLevel presenceLevel: contact.presenceLevel
username: contact.username username: contact.username
} }
...@@ -37,7 +39,7 @@ Item { ...@@ -37,7 +39,7 @@ Item {
Layout.fillHeight: true Layout.fillHeight: true
Layout.fillWidth: true Layout.fillWidth: true
sipAddress: contact.sipAddress sipAddress: contact.sipAddresses[0]
username: avatar.username username: avatar.username
} }
......
...@@ -25,9 +25,9 @@ ColumnLayout { ...@@ -25,9 +25,9 @@ ColumnLayout {
spacing: TimelineStyle.legend.spacing spacing: TimelineStyle.legend.spacing
Icon { Icon {
anchors.verticalCenter: parent.verticalCenter
icon: 'history' icon: 'history'
iconSize: TimelineStyle.legend.iconSize iconSize: TimelineStyle.legend.iconSize
anchors.verticalCenter: parent.verticalCenter
} }
Text { Text {
......
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