fix #LINQT-1705 allow adding ldap friend in app contacts

This commit is contained in:
gaelle 2025-03-28 10:41:11 +01:00 committed by Gaelle Braud
parent 62884832c4
commit fb009fa17a
2 changed files with 139 additions and 148 deletions

View file

@ -103,154 +103,145 @@ FocusScope {
Item { Item {
Layout.fillWidth: true Layout.fillWidth: true
} }
Loader { RowLayout {
id: buttonsLayoutLoader id: actionsRow
asynchronous: true z: 1
active: mainItem.showActions || mainItem.showContactMenu visible: mainItem.showActions || actionButtons.visible || mainItem.showContactMenu || mainItem.multiSelectionEnabled
|| mainItem.multiSelectionEnabled spacing: visible ? Math.round(16 * DefaultStyle.dp) : 0
Layout.rightMargin: active ? Math.round(10 * DefaultStyle.dp) : 0 enabled: visible
sourceComponent: RowLayout { Layout.rightMargin: Math.round(5 * DefaultStyle.dp)
id: actionsRow EffectImage {
id: isSelectedCheck
visible: mainItem.multiSelectionEnabled
&& (mainItem.selectedContacts.indexOf(
searchResultItem.core.defaultAddress) != -1)
Layout.preferredWidth: Math.round(24 * DefaultStyle.dp)
Layout.preferredHeight: Math.round(24 * DefaultStyle.dp)
imageSource: AppIcons.check
colorizationColor: DefaultStyle.main1_500_main
}
RowLayout {
id: actionButtons
visible: mainItem.showActions
spacing: visible ? Math.round(10 * DefaultStyle.dp) : 0
IconButton {
id: callButton
Layout.preferredWidth: Math.round(45 * DefaultStyle.dp)
Layout.preferredHeight: Math.round(45 * DefaultStyle.dp)
icon.width: Math.round(24 * DefaultStyle.dp)
icon.height: Math.round(24 * DefaultStyle.dp)
icon.source: AppIcons.phone
focus: visible
radius: Math.round(40 * DefaultStyle.dp)
style: ButtonStyle.grey
onClicked: UtilsCpp.createCall(
searchResultItem.core.defaultFullAddress)
KeyNavigation.left: chatButton
KeyNavigation.right: videoCallButton
}
IconButton {
id: videoCallButton
visible: SettingsCpp.videoEnabled
Layout.preferredWidth: Math.round(45 * DefaultStyle.dp)
Layout.preferredHeight: Math.round(45 * DefaultStyle.dp)
icon.width: Math.round(24 * DefaultStyle.dp)
icon.height: Math.round(24 * DefaultStyle.dp)
icon.source: AppIcons.videoCamera
focus: visible && !callButton.visible
radius: Math.round(40 * DefaultStyle.dp)
style: ButtonStyle.grey
onClicked: UtilsCpp.createCall(
searchResultItem.core.defaultFullAddress,
{
"localVideoEnabled": true
})
KeyNavigation.left: callButton
KeyNavigation.right: chatButton
}
IconButton {
id: chatButton
visible: actionButtons.visible
&& !SettingsCpp.disableChatFeature
Layout.preferredWidth: Math.round(45 * DefaultStyle.dp)
Layout.preferredHeight: Math.round(45 * DefaultStyle.dp)
icon.width: Math.round(24 * DefaultStyle.dp)
icon.height: Math.round(24 * DefaultStyle.dp)
icon.source: AppIcons.chatTeardropText
focus: visible && !callButton.visible
&& !videoCallButton.visible
radius: Math.round(40 * DefaultStyle.dp)
style: ButtonStyle.grey
KeyNavigation.left: videoCallButton
KeyNavigation.right: callButton
}
}
PopupButton {
id: friendPopup
z: 1 z: 1
visible: actionButtons.visible || friendPopup.visible popup.x: 0
|| mainItem.multiSelectionEnabled popup.padding: Math.round(10 * DefaultStyle.dp)
spacing: visible ? Math.round(16 * DefaultStyle.dp) : 0 visible: mainItem.showContactMenu && (contactArea.containsMouse || mainItem.isLastHovered || hovered || popup.opened)
enabled: visible enabled: visible
EffectImage {
id: isSelectedCheck
visible: mainItem.multiSelectionEnabled
&& (mainItem.selectedContacts.indexOf(
searchResultItem.core.defaultAddress) != -1)
Layout.preferredWidth: Math.round(24 * DefaultStyle.dp)
Layout.preferredHeight: Math.round(24 * DefaultStyle.dp)
imageSource: AppIcons.check
colorizationColor: DefaultStyle.main1_500_main
}
RowLayout {
id: actionButtons
visible: mainItem.showActions
spacing: visible ? Math.round(10 * DefaultStyle.dp) : 0
IconButton {
id: callButton
Layout.preferredWidth: Math.round(45 * DefaultStyle.dp)
Layout.preferredHeight: Math.round(45 * DefaultStyle.dp)
icon.width: Math.round(24 * DefaultStyle.dp)
icon.height: Math.round(24 * DefaultStyle.dp)
icon.source: AppIcons.phone
focus: visible
radius: Math.round(40 * DefaultStyle.dp)
style: ButtonStyle.grey
onClicked: UtilsCpp.createCall(
searchResultItem.core.defaultFullAddress)
KeyNavigation.left: chatButton
KeyNavigation.right: videoCallButton
}
IconButton {
id: videoCallButton
visible: SettingsCpp.videoEnabled
Layout.preferredWidth: Math.round(45 * DefaultStyle.dp)
Layout.preferredHeight: Math.round(45 * DefaultStyle.dp)
icon.width: Math.round(24 * DefaultStyle.dp)
icon.height: Math.round(24 * DefaultStyle.dp)
icon.source: AppIcons.videoCamera
focus: visible && !callButton.visible
radius: Math.round(40 * DefaultStyle.dp)
style: ButtonStyle.grey
onClicked: UtilsCpp.createCall(
searchResultItem.core.defaultFullAddress,
{
"localVideoEnabled": true
})
KeyNavigation.left: callButton
KeyNavigation.right: chatButton
}
IconButton {
id: chatButton
visible: actionButtons.visible
&& !SettingsCpp.disableChatFeature
Layout.preferredWidth: Math.round(45 * DefaultStyle.dp)
Layout.preferredHeight: Math.round(45 * DefaultStyle.dp)
icon.width: Math.round(24 * DefaultStyle.dp)
icon.height: Math.round(24 * DefaultStyle.dp)
icon.source: AppIcons.chatTeardropText
focus: visible && !callButton.visible
&& !videoCallButton.visible
radius: Math.round(40 * DefaultStyle.dp)
style: ButtonStyle.grey
KeyNavigation.left: videoCallButton
KeyNavigation.right: callButton
}
}
PopupButton {
id: friendPopup
z: 1
popup.x: 0
popup.padding: Math.round(10 * DefaultStyle.dp)
visible: mainItem.showContactMenu
&& (contactArea.containsMouse || hovered
|| popup.opened)
enabled: visible
popup.contentItem: ColumnLayout { popup.contentItem: ColumnLayout {
IconLabelButton { IconLabelButton {
visible: searchResultItem.core.isStored visible: searchResultItem.core.isStored
&& !searchResultItem.core.readOnly && !searchResultItem.core.readOnly
//: "Enlever des favoris" //: "Enlever des favoris"
text: searchResultItem.core.starred ? qsTr("contact_details_remove_from_favourites") text: searchResultItem.core.starred ? qsTr("contact_details_remove_from_favourites")
//: "Ajouter aux favoris" //: "Ajouter aux favoris"
: qsTr("contact_details_add_to_favourites") : qsTr("contact_details_add_to_favourites")
icon.source: searchResultItem.core.starred ? AppIcons.heartFill : AppIcons.heart icon.source: searchResultItem.core.starred ? AppIcons.heartFill : AppIcons.heart
spacing: Math.round(10 * DefaultStyle.dp) spacing: Math.round(10 * DefaultStyle.dp)
textColor: DefaultStyle.main2_500main textColor: DefaultStyle.main2_500main
hoveredImageColor: searchResultItem.core.starred ? DefaultStyle.main1_700 : DefaultStyle.danger_700 hoveredImageColor: searchResultItem.core.starred ? DefaultStyle.main1_700 : DefaultStyle.danger_700
contentImageColor: searchResultItem.core.starred ? DefaultStyle.danger_500main : DefaultStyle.main2_600 contentImageColor: searchResultItem.core.starred ? DefaultStyle.danger_500main : DefaultStyle.main2_600
onClicked: { onClicked: {
searchResultItem.core.lSetStarred( searchResultItem.core.lSetStarred(
!searchResultItem.core.starred) !searchResultItem.core.starred)
friendPopup.close() friendPopup.close()
}
style: ButtonStyle.noBackground
} }
IconLabelButton { style: ButtonStyle.noBackground
text: qsTr("Partager") }
icon.source: AppIcons.shareNetwork IconLabelButton {
spacing: Math.round(10 * DefaultStyle.dp) text: qsTr("Partager")
textColor: DefaultStyle.main2_500main icon.source: AppIcons.shareNetwork
onClicked: { spacing: Math.round(10 * DefaultStyle.dp)
var vcard = searchResultItem.core.getVCard() textColor: DefaultStyle.main2_500main
var username = searchResultItem.core.givenName onClicked: {
+ searchResultItem.core.familyName var vcard = searchResultItem.core.getVCard()
var filepath = UtilsCpp.createVCardFile( var username = searchResultItem.core.givenName
username, vcard) + searchResultItem.core.familyName
if (filepath == "") var filepath = UtilsCpp.createVCardFile(
UtilsCpp.showInformationPopup( username, vcard)
qsTr("information_popup_error_title"), if (filepath == "")
//: La création du fichier vcard a échoué UtilsCpp.showInformationPopup(
qsTr("information_popup_vcard_creation_error"), qsTr("information_popup_error_title"),
false) //: La création du fichier vcard a échoué
else qsTr("information_popup_vcard_creation_error"),
//: VCard créée false)
mainWindow.showInformationPopup(qsTr("information_popup_vcard_creation_title"), else
//: "VCard du contact enregistrée dans %1" //: VCard créée
qsTr("information_popup_vcard_creation_success").arg(filepath)) mainWindow.showInformationPopup(qsTr("information_popup_vcard_creation_title"),
//: Partage de contact //: "VCard du contact enregistrée dans %1"
UtilsCpp.shareByEmail(qsTr("contact_sharing_email_title"),vcard, filepath) qsTr("information_popup_vcard_creation_success").arg(filepath))
} //: Partage de contact
style: ButtonStyle.noBackground UtilsCpp.shareByEmail(qsTr("contact_sharing_email_title"),vcard, filepath)
} }
IconLabelButton { style: ButtonStyle.noBackground
//: "Supprimer" }
text: qsTr("contact_details_delete") IconLabelButton {
icon.source: AppIcons.trashCan //: "Supprimer"
spacing: Math.round(10 * DefaultStyle.dp) text: qsTr("contact_details_delete")
visible: !searchResultItem.core.readOnly icon.source: AppIcons.trashCan
onClicked: { spacing: Math.round(10 * DefaultStyle.dp)
mainItem.contactDeletionRequested( visible: !searchResultItem.core.readOnly
searchResultItem) onClicked: {
friendPopup.close() mainItem.contactDeletionRequested(
} searchResultItem)
style: ButtonStyle.noBackgroundRed friendPopup.close()
} }
style: ButtonStyle.noBackgroundRed
} }
} }
} }
@ -265,7 +256,7 @@ FocusScope {
hoverEnabled: true hoverEnabled: true
acceptedButtons: Qt.AllButtons acceptedButtons: Qt.AllButtons
z: -1 z: -1
focus: !buttonsLayoutLoader.active focus: !actionButtons.visible
onContainsMouseChanged: { onContainsMouseChanged: {
mainItem.containsMouseChanged(containsMouse) mainItem.containsMouseChanged(containsMouse)
} }
@ -274,7 +265,7 @@ FocusScope {
radius: Math.round(8 * DefaultStyle.dp) radius: Math.round(8 * DefaultStyle.dp)
opacity: 0.7 opacity: 0.7
color: mainItem.isSelected ? DefaultStyle.main2_200 : DefaultStyle.main2_100 color: mainItem.isSelected ? DefaultStyle.main2_200 : DefaultStyle.main2_100
visible: mainItem.isLastHovered || mainItem.isSelected visible: mainItem.isLastHovered || mainItem.isSelected || friendPopup.hovered
} }
Keys.onPressed: event => { Keys.onPressed: event => {
if (event.key == Qt.Key_Space if (event.key == Qt.Key_Space
@ -288,7 +279,7 @@ FocusScope {
forceActiveFocus() forceActiveFocus()
if (mouse && mouse.button == Qt.RightButton if (mouse && mouse.button == Qt.RightButton
&& mainItem.showContactMenu) { && mainItem.showContactMenu) {
friendPopup.open() if (friendPopup) friendPopup.open()
} else { } else {
mainItem.clicked(mouse) mainItem.clicked(mouse)
} }

View file

@ -533,17 +533,17 @@ ConferenceInfoGui{
|| false || false
property bool isCardDAV: contactDetail.contact?.core?.isCardDAV property bool isCardDAV: contactDetail.contact?.core?.isCardDAV
|| false || false
property bool isLocalFriend: contactDetail.contact && !isLdap && !isCardDAV
//: "Voir le contact" //: "Voir le contact"
text: contactDetail.contact ? qsTr("menu_see_existing_contact") : text: isLocalFriend ? qsTr("menu_see_existing_contact") :
//: "Ajouter aux contacts" //: "Ajouter aux contacts"
qsTr("menu_add_address_to_contacts") qsTr("menu_add_address_to_contacts")
icon.source: AppIcons.plusCircle icon.source: AppIcons.plusCircle
icon.width: Math.round(32 * DefaultStyle.dp) icon.width: Math.round(32 * DefaultStyle.dp)
icon.height: Math.round(32 * DefaultStyle.dp) icon.height: Math.round(32 * DefaultStyle.dp)
visible: !isLdap && !isCardDAV
onClicked: { onClicked: {
detailOptions.close() detailOptions.close()
if (contactDetail.contact) if (isLocalFriend)
mainWindow.displayContactPage( mainWindow.displayContactPage(
contactDetail.contactAddress) contactDetail.contactAddress)
else else