From ac528fc05ccded2b4537752474aa3f823c87a56e Mon Sep 17 00:00:00 2001 From: Gaelle Braud Date: Wed, 31 Jan 2024 10:45:32 +0100 Subject: [PATCH] friends presence --- Linphone/model/core/CoreModel.cpp | 2 +- Linphone/model/friend/FriendModel.hpp | 4 +- Linphone/view/App/Layout/ContactLayout.qml | 22 +++- Linphone/view/Item/Contact/Avatar.qml | 34 ++++- Linphone/view/Item/Contact/ContactsList.qml | 130 +++++++++---------- Linphone/view/Page/Main/AbstractMainPage.qml | 6 +- Linphone/view/Page/Main/CallPage.qml | 87 ++++++------- Linphone/view/Page/Main/ContactPage.qml | 17 +-- 8 files changed, 171 insertions(+), 131 deletions(-) diff --git a/Linphone/model/core/CoreModel.cpp b/Linphone/model/core/CoreModel.cpp index 04919aea5..726df3f9d 100644 --- a/Linphone/model/core/CoreModel.cpp +++ b/Linphone/model/core/CoreModel.cpp @@ -76,7 +76,6 @@ void CoreModel::start() { Utils::appStringToCoreString(Paths::getFactoryConfigFilePath()), nullptr); setMonitor(mCore); setPathsAfterCreation(); - mCore->enableFriendListSubscription(true); mCore->enableRecordAware(true); mCore->setVideoDisplayFilter("MSQOGL"); mCore->usePreviewWindow(true); @@ -92,6 +91,7 @@ void CoreModel::start() { config->setInt("video", "show_local", 0); // So : write ourself to turn off camera before starting the core. mCore->start(); setPathAfterStart(); + mCore->enableFriendListSubscription(true); auto videoPolicy = mCore->getVideoActivationPolicy(); videoPolicy->setAutomaticallyAccept(true); videoPolicy->setAutomaticallyInitiate(false); diff --git a/Linphone/model/friend/FriendModel.hpp b/Linphone/model/friend/FriendModel.hpp index 8b2bfafdd..8b85ba088 100644 --- a/Linphone/model/friend/FriendModel.hpp +++ b/Linphone/model/friend/FriendModel.hpp @@ -88,6 +88,7 @@ signals: void familyNameChanged(const QString &name); void organizationChanged(const QString &orga); void jobChanged(const QString &job); + void presenceReceived(LinphoneEnums::ConsolidatedPresence consolidatedPresence, QDateTime presenceTimestamp); private: DECLARE_ABSTRACT_OBJECT @@ -96,9 +97,6 @@ private: // LINPHONE //-------------------------------------------------------------------------------- virtual void onPresenceReceived(const std::shared_ptr &contact) override; - -signals: - void presenceReceived(LinphoneEnums::ConsolidatedPresence consolidatedPresence, QDateTime presenceTimestamp); }; #endif diff --git a/Linphone/view/App/Layout/ContactLayout.qml b/Linphone/view/App/Layout/ContactLayout.qml index a1cd99fc9..0cf068ef6 100644 --- a/Linphone/view/App/Layout/ContactLayout.qml +++ b/Linphone/view/App/Layout/ContactLayout.qml @@ -77,18 +77,34 @@ ColumnLayout { // Layout.fillWidth: true Text { Layout.alignment: Qt.AlignHCenter - text: mainItem.contactName horizontalAlignment: Text.AlignHCenter + text: mainItem.contactName font { pixelSize: 14 * DefaultStyle.dp weight: 400 * DefaultStyle.dp + capitalization: Font.Capitalize } } Text { id: contactAddress - visible: mainItem.addressVisible - text: mainItem.contactAddress + property var mode : contact ? contact.core.consolidatedPresence : -1 + Layout.alignment: Qt.AlignHCenter horizontalAlignment: Text.AlignHCenter + visible: mainItem.addressVisible + text: mode === LinphoneEnums.ConsolidatedPresence.Online + ? qsTr("En ligne") + : mode === LinphoneEnums.ConsolidatedPresence.Busy + ? qsTr("Occupé") + : mode === LinphoneEnums.ConsolidatedPresence.DoNotDisturb + ? qsTr("Ne pas déranger") + : qsTr("Hors ligne") + color: mode === LinphoneEnums.ConsolidatedPresence.Online + ? DefaultStyle.success_500main + : mode === LinphoneEnums.ConsolidatedPresence.Busy + ? DefaultStyle.warning_600 + : mode === LinphoneEnums.ConsolidatedPresence.DoNotDisturb + ? DefaultStyle.danger_500main + : DefaultStyle.main2_500main font { pixelSize: 12 * DefaultStyle.dp weight: 300 * DefaultStyle.dp diff --git a/Linphone/view/Item/Contact/Avatar.qml b/Linphone/view/Item/Contact/Avatar.qml index 80ddb34ed..55e1fae6d 100644 --- a/Linphone/view/Item/Contact/Avatar.qml +++ b/Linphone/view/Item/Contact/Avatar.qml @@ -26,7 +26,7 @@ StackView { property string displayNameVal: displayNameObj ? displayNameObj.value : "" property bool haveAvatar: (account && account.core.pictureUri ) || (contact && contact.core.pictureUri) - + onHaveAvatarChanged: replace(haveAvatar ? avatar : initials, StackView.Immediate) property bool secured: false @@ -54,6 +54,38 @@ StackView { anchors.bottom: parent.bottom } } + Rectangle { + visible: (account || contact) && (account + ? account.core.registrationState != LinphoneEnums.RegistrationState.Progress && account.core.registrationState != LinphoneEnums.RegistrationState.Refreshing + : contact.core.consolidatedPresence != LinphoneEnums.ConsolidatedPresence.Offline) + width: mainItem.width/4.5 + height: width + radius: width / 2 + x: 2 * mainItem.width / 3 + y: 6 * mainItem.height / 7 + z: 1 + color: account + ? account.core.registrationState == LinphoneEnums.RegistrationState.Ok + ? DefaultStyle.success_500main + : account.core.registrationState == LinphoneEnums.RegistrationState.Cleared || account.core.registrationState == LinphoneEnums.RegistrationState.None + ? DefaultStyle.warning_600 + : account.core.registrationState == LinphoneEnums.RegistrationState.Progress || account.core.registrationState == LinphoneEnums.RegistrationState.Refreshing + ? DefaultStyle.main2_500main + : DefaultStyle.danger_500main + : contact + ? contact.core.consolidatedPresence === LinphoneEnums.ConsolidatedPresence.Online + ? DefaultStyle.success_500main + : contact.core.consolidatedPresence === LinphoneEnums.ConsolidatedPresence.Busy + ? DefaultStyle.warning_600 + : contact.core.consolidatedPresence === LinphoneEnums.ConsolidatedPresence.DoNotDisturb + ? DefaultStyle.danger_500main + : DefaultStyle.main2_500main + : "transparent" + border { + width: 2 * DefaultStyle.dp + color: DefaultStyle.grey_0 + } + } Component{ id: initials Rectangle { diff --git a/Linphone/view/Item/Contact/ContactsList.qml b/Linphone/view/Item/Contact/ContactsList.qml index 1870db26a..e4037bf9d 100644 --- a/Linphone/view/Item/Contact/ContactsList.qml +++ b/Linphone/view/Item/Contact/ContactsList.qml @@ -84,81 +84,75 @@ ListView { text: itemDelegate.displayName font.pixelSize: 14 * DefaultStyle.dp font.capitalization: mainItem.displayNameCapitalization ? Font.Capitalize : Font.MixedCase - } - Item { + maximumLineCount: 1 Layout.fillWidth: true } - } + RowLayout { + id: buttonsLayout + z: 1 + height: parent.height + children: mainItem.delegateButtons || [] + } - RowLayout { - z: 1 - height: parent.height - anchors.right: parent.right - anchors.rightMargin: 5 * DefaultStyle.dp - anchors.verticalCenter: parent.verticalCenter - children: mainItem.delegateButtons || [] - } - - PopupButton { - id: friendPopup - z: 1 - hoverEnabled: mainItem.hoverEnabled - visible: mainItem.contactMenuVisible && (contactArea.containsMouse || hovered || popup.opened) && (!delegateButtons || delegateButtons.children.length === 0) - popup.x: 0 - popup.padding: 10 * DefaultStyle.dp - anchors.right: parent.right - anchors.rightMargin: 5 * DefaultStyle.dp - anchors.verticalCenter: parent.verticalCenter - popup.contentItem: ColumnLayout { - Button { - background: Item{} - contentItem: RowLayout { - Image { - source: modelData.core.starred ? AppIcons.heartFill : AppIcons.heart - fillMode: Image.PreserveAspectFit - width: 24 * DefaultStyle.dp - height: 24 * DefaultStyle.dp - Layout.preferredWidth: 24 * DefaultStyle.dp - Layout.preferredHeight: 24 * DefaultStyle.dp - } - Text { - text: modelData.core.starred ? qsTr("Enlever des favoris") : qsTr("Mettre en favori") - color: DefaultStyle.main2_500main - font { - pixelSize: 14 * DefaultStyle.dp - weight: 400 * DefaultStyle.dp + PopupButton { + id: friendPopup + z: 1 + hoverEnabled: mainItem.hoverEnabled + visible: mainItem.contactMenuVisible && (contactArea.containsMouse || hovered || popup.opened) && (!delegateButtons || delegateButtons.children.length === 0) + popup.x: 0 + popup.padding: 10 * DefaultStyle.dp + Layout.rightMargin: 5 * DefaultStyle.dp + popup.contentItem: ColumnLayout { + Button { + background: Item{} + contentItem: RowLayout { + Image { + source: modelData.core.starred ? AppIcons.heartFill : AppIcons.heart + fillMode: Image.PreserveAspectFit + width: 24 * DefaultStyle.dp + height: 24 * DefaultStyle.dp + Layout.preferredWidth: 24 * DefaultStyle.dp + Layout.preferredHeight: 24 * DefaultStyle.dp + } + Text { + text: modelData.core.starred ? qsTr("Enlever des favoris") : qsTr("Mettre en favori") + color: DefaultStyle.main2_500main + font { + pixelSize: 14 * DefaultStyle.dp + weight: 400 * DefaultStyle.dp + } } } - } - onClicked: { - modelData.core.lSetStarred(!modelData.core.starred) - friendPopup.close() - } - } - Button { - background: Item{} - contentItem: RowLayout { - EffectImage { - source: AppIcons.trashCan - width: 24 * DefaultStyle.dp - height: 24 * DefaultStyle.dp - Layout.preferredWidth: 24 * DefaultStyle.dp - Layout.preferredHeight: 24 * DefaultStyle.dp - fillMode: Image.PreserveAspectFit - colorizationColor: DefaultStyle.danger_500main + onClicked: { + modelData.core.lSetStarred(!modelData.core.starred) + friendPopup.close() } - Text { - text: qsTr("Supprimer") - color: DefaultStyle.danger_500main - font { - pixelSize: 14 * DefaultStyle.dp - weight: 400 * DefaultStyle.dp + } + Button { + background: Item{} + contentItem: RowLayout { + EffectImage { + source: AppIcons.trashCan + width: 24 * DefaultStyle.dp + height: 24 * DefaultStyle.dp + Layout.preferredWidth: 24 * DefaultStyle.dp + Layout.preferredHeight: 24 * DefaultStyle.dp + fillMode: Image.PreserveAspectFit + colorizationColor: DefaultStyle.danger_500main + } + Text { + text: qsTr("Supprimer") + color: DefaultStyle.danger_500main + font { + pixelSize: 14 * DefaultStyle.dp + weight: 400 * DefaultStyle.dp + } } } - } - onClicked: { - mainItem.contactDeletionRequested(modelData) - friendPopup.close() + onClicked: { + mainItem.contactDeletionRequested(modelData) + friendPopup.close() + } } } } @@ -167,7 +161,7 @@ ListView { MouseArea { id: contactArea hoverEnabled: mainItem.hoverEnabled - anchors.fill: initial.visible ? contactDelegate : parent + anchors.fill: contactDelegate height: mainItem.height Rectangle { anchors.fill: contactArea diff --git a/Linphone/view/Page/Main/AbstractMainPage.qml b/Linphone/view/Page/Main/AbstractMainPage.qml index 7899c1a42..dcc2ff40f 100644 --- a/Linphone/view/Page/Main/AbstractMainPage.qml +++ b/Linphone/view/Page/Main/AbstractMainPage.qml @@ -190,10 +190,14 @@ Item { } Button { Layout.alignment: Qt.AlignHCenter + topPadding: 11 * DefaultStyle.dp + bottomPadding: 11 * DefaultStyle.dp + leftPadding: 20 * DefaultStyle.dp + rightPadding: 20 * DefaultStyle.dp contentItem: RowLayout { Layout.alignment: Qt.AlignVCenter EffectImage { - colorizationColor: "red"// DefaultStyle.grey_0 + colorizationColor: DefaultStyle.grey_0 source: mainItem.newItemIconSource width: 24 * DefaultStyle.dp height: 24 * DefaultStyle.dp diff --git a/Linphone/view/Page/Main/CallPage.qml b/Linphone/view/Page/Main/CallPage.qml index 1870e7268..ac319f068 100644 --- a/Linphone/view/Page/Main/CallPage.qml +++ b/Linphone/view/Page/Main/CallPage.qml @@ -194,58 +194,53 @@ AbstractMainPage { height: 45 * DefaultStyle.dp } } - Item { - Layout.fillWidth: true + ColumnLayout { Layout.fillHeight: true - ColumnLayout { - spacing: 5 * DefaultStyle.dp - anchors.verticalCenter: parent.verticalCenter - Text { - id: friendAddress - property var remoteAddress: modelData ? UtilsCpp.getDisplayName(modelData.core.remoteAddress) : null - text: remoteAddress ? remoteAddress.value : "" - font { - pixelSize: 14 * DefaultStyle.dp - weight: 400 * DefaultStyle.dp - } + Layout.fillWidth: true + spacing: 5 * DefaultStyle.dp + Text { + id: friendAddress + Layout.fillWidth: true + maximumLineCount: 1 + property var remoteAddress: modelData ? UtilsCpp.getDisplayName(modelData.core.remoteAddress) : null + text: remoteAddress ? remoteAddress.value : "" + font { + pixelSize: 14 * DefaultStyle.dp + weight: 400 * DefaultStyle.dp } - RowLayout { - spacing: 3 * DefaultStyle.dp - Image { - source: modelData.core.status === LinphoneEnums.CallStatus.Declined - || modelData.core.status === LinphoneEnums.CallStatus.DeclinedElsewhere - || modelData.core.status === LinphoneEnums.CallStatus.Aborted - || modelData.core.status === LinphoneEnums.CallStatus.EarlyAborted - ? modelData.core.isOutgoing - ? AppIcons.outgoingCallRejected - : AppIcons.incomingCallRejected - : modelData.core.status === LinphoneEnums.CallStatus.Missed - ? modelData.core.isOutgoing - ? AppIcons.outgoingCallMissed - : AppIcons.incomingCallMissed - : modelData.core.isOutgoing - ? AppIcons.outgoingCall - : AppIcons.incomingCall - Layout.preferredWidth: 5 * DefaultStyle.dp - Layout.preferredHeight: 5 * DefaultStyle.dp - sourceSize.width: 5 * DefaultStyle.dp - sourceSize.height: 5 * DefaultStyle.dp - RectangleTest{anchors.fill: parent} - } - Text { - // text: modelData.core.date - text: UtilsCpp.formatDateElapsedTime(modelData.core.date) - font { - pixelSize: 12 * DefaultStyle.dp - weight: 300 * DefaultStyle.dp - } + } + RowLayout { + spacing: 3 * DefaultStyle.dp + Image { + source: modelData.core.status === LinphoneEnums.CallStatus.Declined + || modelData.core.status === LinphoneEnums.CallStatus.DeclinedElsewhere + || modelData.core.status === LinphoneEnums.CallStatus.Aborted + || modelData.core.status === LinphoneEnums.CallStatus.EarlyAborted + ? modelData.core.isOutgoing + ? AppIcons.outgoingCallRejected + : AppIcons.incomingCallRejected + : modelData.core.status === LinphoneEnums.CallStatus.Missed + ? modelData.core.isOutgoing + ? AppIcons.outgoingCallMissed + : AppIcons.incomingCallMissed + : modelData.core.isOutgoing + ? AppIcons.outgoingCall + : AppIcons.incomingCall + Layout.preferredWidth: 5 * DefaultStyle.dp + Layout.preferredHeight: 5 * DefaultStyle.dp + sourceSize.width: 5 * DefaultStyle.dp + sourceSize.height: 5 * DefaultStyle.dp + } + Text { + // text: modelData.core.date + text: UtilsCpp.formatDateElapsedTime(modelData.core.date) + font { + pixelSize: 12 * DefaultStyle.dp + weight: 300 * DefaultStyle.dp } } } } - // Item { - // Layout.fillWidth: true - // } Button { Layout.rightMargin: 5 * DefaultStyle.dp padding: 0 diff --git a/Linphone/view/Page/Main/ContactPage.qml b/Linphone/view/Page/Main/ContactPage.qml index 7f4c14a65..5931a4903 100644 --- a/Linphone/view/Page/Main/ContactPage.qml +++ b/Linphone/view/Page/Main/ContactPage.qml @@ -9,7 +9,7 @@ AbstractMainPage { id: mainItem noItemButtonText: qsTr("Ajouter un contact") emptyListText: qsTr("Aucun contact pour le moment") - newItemIconSource: AppIcons.newCall + newItemIconSource: AppIcons.plusCircle // disable left panel contact list interaction while a contact is being edited property bool leftPanelEnabled: true @@ -154,8 +154,8 @@ AbstractMainPage { Button { background: Item{} icon.source: favoriteList.visible ? AppIcons.upArrow : AppIcons.downArrow - width: 24 * DefaultStyle.dp - height: 24 * DefaultStyle.dp + Layout.preferredWidth: 24 * DefaultStyle.dp + Layout.preferredHeight: 24 * DefaultStyle.dp onClicked: favoriteList.visible = !favoriteList.visible } } @@ -190,6 +190,7 @@ AbstractMainPage { ColumnLayout { visible: contactList.count > 0 RowLayout { + Layout.fillWidth: true Text { text: qsTr("All contacts") font { @@ -201,11 +202,11 @@ AbstractMainPage { Layout.fillWidth: true } Button { - background: Item{} - icon.source: favoriteList.visible ? AppIcons.upArrow : AppIcons.downArrow - width: 24 * DefaultStyle.dp - height: 24 * DefaultStyle.dp - onClicked: contactList.visible = !contactList.visible + background: Item{} + icon.source: contactList.visible ? AppIcons.upArrow : AppIcons.downArrow + Layout.preferredWidth: 24 * DefaultStyle.dp + Layout.preferredHeight: 24 * DefaultStyle.dp + onClicked: contactList.visible = !contactList.visible } } ContactsList{