From bbc409f4b186b0dbac77e64935655adcb63a9835 Mon Sep 17 00:00:00 2001 From: Gaelle Braud Date: Thu, 4 Jul 2024 10:29:37 +0200 Subject: [PATCH] fixes --- Linphone/model/tool/ToolModel.cpp | 5 +- Linphone/tool/Utils.cpp | 3 +- Linphone/view/App/AppWindow.qml | 117 +++++++++++++++++ Linphone/view/App/CallsWindow.qml | 2 +- Linphone/view/Item/Call/CallContactsLists.qml | 124 +----------------- Linphone/view/Item/Contact/ContactsList.qml | 5 +- .../view/Layout/Contact/ContactLayout.qml | 6 +- Linphone/view/Page/Main/CallPage.qml | 7 +- 8 files changed, 131 insertions(+), 138 deletions(-) diff --git a/Linphone/model/tool/ToolModel.cpp b/Linphone/model/tool/ToolModel.cpp index 81d6d243d..1b64e28fb 100644 --- a/Linphone/model/tool/ToolModel.cpp +++ b/Linphone/model/tool/ToolModel.cpp @@ -124,14 +124,13 @@ bool ToolModel::createCall(const QString &sipAddress, lCritical() << "[" + QString(gClassName) + "] The calling address is not an interpretable SIP address: " << sipAddress; if (errorMessage) { - *errorMessage = tr("The calling address is not an interpretable SIP address : "); - errorMessage->append(sipAddress); + *errorMessage = tr("The calling address is not an interpretable SIP address : %1").arg(sipAddress); } return false; } for (auto &account : core->getAccountList()) { if (account->getContactAddress() && account->getContactAddress()->weakEqual(address)) { - *errorMessage = "The calling address is a connected account."; + if (errorMessage) *errorMessage = "The calling address is a connected account."; lDebug() << "[" + QString(gClassName) + "]" + *errorMessage; return false; } diff --git a/Linphone/tool/Utils.cpp b/Linphone/tool/Utils.cpp index a9626c39c..eea7c3dd9 100644 --- a/Linphone/tool/Utils.cpp +++ b/Linphone/tool/Utils.cpp @@ -52,7 +52,8 @@ char *Utils::rstrstr(const char *a, const char *b) { VariantObject *Utils::getDisplayName(const QString &address) { QStringList splitted = address.split(":"); if (splitted.size() > 0 && splitted[0] == "sip") splitted.removeFirst(); - VariantObject *data = new VariantObject(splitted.first().split("@").first()); // Scope : GUI + VariantObject *data = nullptr; + if (splitted.size() != 0) data = new VariantObject(splitted.first().split("@").first()); // Scope : GUI if (!data) return nullptr; data->makeRequest([address]() { QString displayName = ToolModel::getDisplayName(address); diff --git a/Linphone/view/App/AppWindow.qml b/Linphone/view/App/AppWindow.qml index 3aaa2dda4..f29dc185f 100644 --- a/Linphone/view/App/AppWindow.qml +++ b/Linphone/view/App/AppWindow.qml @@ -30,6 +30,123 @@ ApplicationWindow { } } + Popup { + id: startCallPopup + property FriendGui contact + property bool videoEnabled + onContactChanged: { + console.log("contact changed", contact) + } + underlineColor: DefaultStyle.main1_500_main + anchors.centerIn: parent + width: 370 * DefaultStyle.dp + modal: true + leftPadding: 15 * DefaultStyle.dp + rightPadding: 15 * DefaultStyle.dp + topPadding: 20 * DefaultStyle.dp + bottomPadding: 25 * DefaultStyle.dp + contentItem: ColumnLayout { + spacing: 16 * DefaultStyle.dp + RowLayout { + spacing: 0 + Text { + text: qsTr("Which channel do you choose?") + font { + pixelSize: 16 * DefaultStyle.dp + weight: 800 * DefaultStyle.dp + } + } + Item{Layout.fillWidth: true} + Button { + Layout.preferredWidth: 24 * DefaultStyle.dp + Layout.preferredHeight: 24 * DefaultStyle.dp + Layout.alignment: Qt.AlignVCenter + background: Item{} + icon.source:AppIcons.closeX + width: 24 * DefaultStyle.dp + height: 24 * DefaultStyle.dp + icon.width: 24 * DefaultStyle.dp + icon.height: 24 * DefaultStyle.dp + contentItem: Image { + anchors.fill: parent + source: AppIcons.closeX + } + onClicked: startCallPopup.close() + } + } + ListView { + id: popuplist + model: VariantList { + model: startCallPopup.contact && startCallPopup.contact.core.allAddresses || [] + } + Layout.fillWidth: true + Layout.preferredHeight: contentHeight + spacing: 10 * DefaultStyle.dp + delegate: Item { + width: popuplist.width + height: 56 * DefaultStyle.dp + ColumnLayout { + width: popuplist.width + anchors.verticalCenter: parent.verticalCenter + spacing: 10 * DefaultStyle.dp + ColumnLayout { + spacing: 7 * DefaultStyle.dp + Text { + Layout.leftMargin: 5 * DefaultStyle.dp + text: modelData.label + " :" + font { + pixelSize: 13 * DefaultStyle.dp + weight: 700 * DefaultStyle.dp + } + } + Text { + Layout.leftMargin: 5 * DefaultStyle.dp + text: modelData.address + font { + pixelSize: 14 * DefaultStyle.dp + weight: 400 * DefaultStyle.dp + } + } + } + Rectangle { + visible: index != popuplist.model.count - 1 + Layout.fillWidth: true + Layout.preferredHeight: 1 * DefaultStyle.dp + color: DefaultStyle.main2_200 + } + } + MouseArea { + anchors.fill: parent + hoverEnabled: true + cursorShape: containsMouse ? Qt.PointingHandCursor : Qt.ArrowCursor + onClicked: UtilsCpp.createCall(modelData.address, {'localVideoEnabled': startCallPopup.videoEnabled}) + } + } + } + } + } + + function startCallWithContact(contact, videoEnabled, parentItem) { + if (parentItem == undefined) parentItem = mainWindow + startCallPopup.parent = parentItem + if (contact) { + console.log("START CALL WITH", contact.core.displayName, "addresses count", contact.core.allAddresses.length) + if (contact.core.allAddresses.length > 1) { + startCallPopup.contact = contact + startCallPopup.videoEnabled = videoEnabled + startCallPopup.open() + + } else { + var addressToCall = contact.core.defaultAddress.length === 0 + ? contact.core.phoneNumbers.length === 0 + ? "" + : contact.core.phoneNumbers[0].address + : contact.core.defaultAddress + if (addressToCall.length != 0) UtilsCpp.createCall(addressToCall, {'localVideoEnabled':videoEnabled}) + } + } + } + function removeFromPopupLayout(index) { popupLayout.popupList.splice(index, 1) } diff --git a/Linphone/view/App/CallsWindow.qml b/Linphone/view/App/CallsWindow.qml index 0523bc1c7..7c7e95aae 100644 --- a/Linphone/view/App/CallsWindow.qml +++ b/Linphone/view/App/CallsWindow.qml @@ -126,7 +126,7 @@ AppWindow { } Component.onCompleted: { - if(call.core.encryption === LinphoneEnums.MediaEncryption.Zrtp && (!call.core.tokenVerified || call.core.isMismatch)) { + if(call && call.core.encryption === LinphoneEnums.MediaEncryption.Zrtp && (!call.core.tokenVerified || call.core.isMismatch)) { zrtpValidation.open() } } diff --git a/Linphone/view/Item/Call/CallContactsLists.qml b/Linphone/view/Item/Call/CallContactsLists.qml index ecf7fe839..c300184cd 100644 --- a/Linphone/view/Item/Call/CallContactsLists.qml +++ b/Linphone/view/Item/Call/CallContactsLists.qml @@ -17,101 +17,6 @@ Item { property NumericPad numPad clip: true - Popup { - id: startCallPopup - property FriendGui contact - onContactChanged: { - console.log("contact changed", contact) - } - underlineColor: DefaultStyle.main1_500_main - anchors.centerIn: parent - width: parent.width - modal: true - leftPadding: 15 * DefaultStyle.dp - rightPadding: 15 * DefaultStyle.dp - topPadding: 20 * DefaultStyle.dp - bottomPadding: 25 * DefaultStyle.dp - contentItem: ColumnLayout { - spacing: 16 * DefaultStyle.dp - RowLayout { - spacing: 0 - Text { - text: qsTr("Which channel do you choose?") - font { - pixelSize: 16 * DefaultStyle.dp - weight: 800 * DefaultStyle.dp - } - } - Item{Layout.fillWidth: true} - Button { - Layout.preferredWidth: 24 * DefaultStyle.dp - Layout.preferredHeight: 24 * DefaultStyle.dp - Layout.alignment: Qt.AlignVCenter - background: Item{} - icon.source:AppIcons.closeX - width: 24 * DefaultStyle.dp - height: 24 * DefaultStyle.dp - icon.width: 24 * DefaultStyle.dp - icon.height: 24 * DefaultStyle.dp - contentItem: Image { - anchors.fill: parent - source: AppIcons.closeX - } - onClicked: startCallPopup.close() - } - } - ListView { - id: popuplist - model: VariantList { - model: startCallPopup.contact && startCallPopup.contact.core.allAddresses || [] - } - Layout.fillWidth: true - Layout.preferredHeight: contentHeight - spacing: 10 * DefaultStyle.dp - delegate: Item { - width: parent.width - height: 56 * DefaultStyle.dp - ColumnLayout { - width: parent.width - anchors.verticalCenter: parent.verticalCenter - spacing: 10 * DefaultStyle.dp - ColumnLayout { - spacing: 7 * DefaultStyle.dp - Text { - Layout.leftMargin: 5 * DefaultStyle.dp - text: modelData.label + " :" - font { - pixelSize: 13 * DefaultStyle.dp - weight: 700 * DefaultStyle.dp - } - } - Text { - Layout.leftMargin: 5 * DefaultStyle.dp - text: modelData.address - font { - pixelSize: 14 * DefaultStyle.dp - weight: 400 * DefaultStyle.dp - } - } - } - Rectangle { - visible: index != popuplist.model.count - 1 - Layout.fillWidth: true - Layout.preferredHeight: 1 * DefaultStyle.dp - color: DefaultStyle.main2_200 - } - } - MouseArea { - anchors.fill: parent - hoverEnabled: true - cursorShape: containsMouse ? Qt.PointingHandCursor : Qt.ArrowCursor - onClicked: mainItem.callButtonPressed(modelData.address) - } - } - } - } - } - Control.Control { id: listLayout anchors.fill: parent @@ -212,17 +117,7 @@ Item { model: MagicSearchProxy { searchText: searchBar.text.length === 0 ? "*" : searchBar.text } - onContactClicked: (contact) => { - if (contact) { - if (contact.core.allAddresses.length > 1) { - startCallPopup.contact = contact - startCallPopup.open() - - } else { - mainItem.callButtonPressed(contact.core.defaultAddress) - } - } - } + onSelectedContactChanged: mainWindow.startCallWithContact(selectedContact, false, mainItem.parent) } } ColumnLayout { @@ -247,22 +142,7 @@ Item { sourceFlags: LinphoneEnums.MagicSearchSource.All aggregationFlag: LinphoneEnums.MagicSearchAggregation.Friend } - onSelectedContactChanged: { - if (selectedContact) { - if (selectedContact.core.allAddresses.length > 1) { - startCallPopup.contact = selectedContact - startCallPopup.open() - - } else { - var addressToCall = selectedContact.core.defaultAddress.length === 0 - ? selectedContact.core.phoneNumbers.length === 0 - ? "" - : selectedContact.core.phoneNumbers[0].address - : selectedContact.core.defaultAddress - if (addressToCall.length != 0) mainItem.callButtonPressed(addressToCall) - } - } - } + onSelectedContactChanged: mainWindow.startCallWithContact(selectedContact, false, mainItem.parent) } } Item { diff --git a/Linphone/view/Item/Contact/ContactsList.qml b/Linphone/view/Item/Contact/ContactsList.qml index bca3e345a..6a9da9596 100644 --- a/Linphone/view/Item/Contact/ContactsList.qml +++ b/Linphone/view/Item/Contact/ContactsList.qml @@ -46,7 +46,6 @@ ListView { signal contactStarredChanged() signal contactDeletionRequested(FriendGui contact) signal contactAddedToSelection() - signal contactClicked(FriendGui contact) function addContactToSelection(address) { if (multiSelectionEnabled) { @@ -63,6 +62,8 @@ ListView { } } + + model: MagicSearchProxy { searchText: searchBarText.length === 0 ? "*" : searchBarText onFriendCreated: (index) => { @@ -265,8 +266,8 @@ ListView { visible: contactArea.containsMouse || friendPopup.hovered || (!mainItem.multiSelectionEnabled && mainItem.currentIndex === index) } onClicked: { + mainItem.currentIndex = -1 mainItem.currentIndex = index - mainItem.contactClicked(modelData) if (mainItem.multiSelectionEnabled) { var indexInSelection = mainItem.selectedContacts.indexOf(modelData.core.defaultAddress) if (indexInSelection == -1) { diff --git a/Linphone/view/Layout/Contact/ContactLayout.qml b/Linphone/view/Layout/Contact/ContactLayout.qml index bd6bdae98..04568a95c 100644 --- a/Linphone/view/Layout/Contact/ContactLayout.qml +++ b/Linphone/view/Layout/Contact/ContactLayout.qml @@ -149,7 +149,7 @@ ColumnLayout { button.icon.source: AppIcons.phone label: qsTr("Appel") button.onClicked: { - UtilsCpp.createCall(mainItem.contactAddress) + mainWindow.startCallWithContact(contact, false, mainItem) } } LabelButton { @@ -160,7 +160,7 @@ ColumnLayout { button.icon.height: 24 * DefaultStyle.dp button.icon.source: AppIcons.chatTeardropText label: qsTr("Message") - button.onClicked: console.debug("[CallPage.qml] TODO : open conversation") + button.onClicked: console.debug("[ContactLayout.qml] TODO : open conversation") } LabelButton { visible: !mainItem.isConference @@ -171,7 +171,7 @@ ColumnLayout { button.icon.source: AppIcons.videoCamera label: qsTr("Appel Video") button.onClicked: { - UtilsCpp.createCall(mainItem.contactAddress, {'localVideoEnabled':true}) + mainWindow.startCallWithContact(contact, true, mainItem) } } } diff --git a/Linphone/view/Page/Main/CallPage.qml b/Linphone/view/Page/Main/CallPage.qml index 23bae3541..21e9283b0 100644 --- a/Linphone/view/Page/Main/CallPage.qml +++ b/Linphone/view/Page/Main/CallPage.qml @@ -79,9 +79,9 @@ AbstractMainPage { anchors.top: titleLoader.bottom anchors.topMargin: 18 * DefaultStyle.dp anchors.left: parent.left + anchors.leftMargin: 45 * DefaultStyle.dp anchors.right: parent.right anchors.bottom: parent.bottom - anchors.leftMargin: 45 * DefaultStyle.dp } Item { @@ -413,11 +413,6 @@ AbstractMainPage { numPad: numericPad groupCallVisible: true searchBarColor: DefaultStyle.grey_100 - - onCallButtonPressed: (address) => { - UtilsCpp.createCall(address) - // var window = UtilsCpp.getCallsWindow() - } onGroupCallCreationRequested: { console.log("groupe call requetsed") listStackView.push(groupCallItem)