mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-23 22:58:15 +00:00
feat(Contact/Avatar): better _computeInitials function
This commit is contained in:
parent
5640d2d410
commit
0813eda3b4
5 changed files with 25 additions and 14 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue