From 0813eda3b4ab00f8cfdfa9e65061adabb625dabd Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Mon, 31 Oct 2016 12:21:21 +0100 Subject: [PATCH] feat(Contact/Avatar): better `_computeInitials` function --- tests/src/main.cpp | 2 +- .../Linphone/Account/AccountStatus.qml | 3 ++- tests/ui/modules/Linphone/Contact/Avatar.qml | 20 +++++++++++++------ tests/ui/modules/Linphone/Contact/Contact.qml | 12 ++++++----- tests/ui/modules/Linphone/Timeline.qml | 2 +- 5 files changed, 25 insertions(+), 14 deletions(-) diff --git a/tests/src/main.cpp b/tests/src/main.cpp index b49b3340d..7d237deca 100644 --- a/tests/src/main.cpp +++ b/tests/src/main.cpp @@ -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. diff --git a/tests/ui/modules/Linphone/Account/AccountStatus.qml b/tests/ui/modules/Linphone/Account/AccountStatus.qml index a0c0a5463..a6bf8623c 100644 --- a/tests/ui/modules/Linphone/Account/AccountStatus.qml +++ b/tests/ui/modules/Linphone/Account/AccountStatus.qml @@ -50,10 +50,11 @@ Item { MouseArea { anchors.fill: parent - hoverEnabled: true cursorShape: containsMouse ? Qt.PointingHandCursor : Qt.ArrowCursor + hoverEnabled: true + onClicked: Utils.openWindow('ManageAccounts', this) } } diff --git a/tests/ui/modules/Linphone/Contact/Avatar.qml b/tests/ui/modules/Linphone/Contact/Avatar.qml index f305cd915..7387da57a 100644 --- a/tests/ui/modules/Linphone/Contact/Avatar.qml +++ b/tests/ui/modules/Linphone/Contact/Avatar.qml @@ -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) diff --git a/tests/ui/modules/Linphone/Contact/Contact.qml b/tests/ui/modules/Linphone/Contact/Contact.qml index 558930811..0ff05d0a4 100644 --- a/tests/ui/modules/Linphone/Contact/Contact.qml +++ b/tests/ui/modules/Linphone/Contact/Contact.qml @@ -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 } diff --git a/tests/ui/modules/Linphone/Timeline.qml b/tests/ui/modules/Linphone/Timeline.qml index 858a15fd5..8459a2da1 100644 --- a/tests/ui/modules/Linphone/Timeline.qml +++ b/tests/ui/modules/Linphone/Timeline.qml @@ -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 {