This commit is contained in:
Gaelle Braud 2024-07-04 10:29:37 +02:00
parent 9240207ef5
commit bbc409f4b1
8 changed files with 131 additions and 138 deletions

View file

@ -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;
}

View file

@ -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);

View file

@ -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)
}

View file

@ -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()
}
}

View file

@ -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 {

View file

@ -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) {

View file

@ -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)
}
}
}

View file

@ -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)