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