fix share friend (not every platform supports attachment file)

This commit is contained in:
Gaelle Braud 2024-07-10 17:41:43 +02:00
parent b71664fd5b
commit 80a9c6d969
4 changed files with 10 additions and 9 deletions

View file

@ -395,12 +395,10 @@ void Utils::shareByEmail(const QString &subject,
const QString &body, const QString &body,
const QString &attachment, const QString &attachment,
const QString &receiver) { const QString &receiver) {
QString url = QString("mailto:?to=%1&subject=%2&body=%3&attachment=%4") // QString attach = attachment;
.arg(receiver) // attach.prepend("file:///");
.arg(subject) QUrl url(QString("mailto:?to=%1&subject=%2&body=%3").arg(receiver).arg(subject).arg(body));
.arg(body) QDesktopServices::openUrl(url);
.arg("/home/gaelle/ligneconsolevscode");
QDesktopServices::openUrl(QUrl(url, QUrl::TolerantMode));
} }
QString Utils::getClipboardText() { QString Utils::getClipboardText() {

View file

@ -178,6 +178,7 @@ ApplicationWindow {
popupLayout.popupList.splice(index, 1) popupLayout.popupList.splice(index, 1)
} }
function showInformationPopup(title, description, isSuccess) { function showInformationPopup(title, description, isSuccess) {
if (isSuccess == undefined) isSuccess = true
var infoPopup = popupComp.createObject(popupLayout, {"title": title, "description": description, "isSuccess": isSuccess}) var infoPopup = popupComp.createObject(popupLayout, {"title": title, "description": description, "isSuccess": isSuccess})
infoPopup.index = popupLayout.popupList.length infoPopup.index = popupLayout.popupList.length
popupLayout.popupList.push(infoPopup) popupLayout.popupList.push(infoPopup)

View file

@ -234,7 +234,8 @@ ListView {
var vcard = modelData.core.getVCard() var vcard = modelData.core.getVCard()
var username = modelData.core.givenName + modelData.core.familyName var username = modelData.core.givenName + modelData.core.familyName
var filepath = UtilsCpp.createVCardFile(username, vcard) var filepath = UtilsCpp.createVCardFile(username, vcard)
if (filepath == "") UtilsCpp.showInformationPopup(qsTr("Erreur"), qsTr("La création du fichier vcard a échoué")) if (filepath == "") UtilsCpp.showInformationPopup(qsTr("Erreur"), qsTr("La création du fichier vcard a échoué"), false)
else mainWindow.showInformationPopup(qsTr("VCard créée"), qsTr("VCard du contact enregistrée dans %1").arg(filepath))
UtilsCpp.shareByEmail(qsTr("Partage de contact"), vcard, filepath) UtilsCpp.shareByEmail(qsTr("Partage de contact"), vcard, filepath)
} }
} }

View file

@ -708,13 +708,14 @@ AbstractMainPage {
Layout.preferredHeight: 50 * DefaultStyle.dp Layout.preferredHeight: 50 * DefaultStyle.dp
iconSize: 24 * DefaultStyle.dp iconSize: 24 * DefaultStyle.dp
iconSource: AppIcons.shareNetwork iconSource: AppIcons.shareNetwork
text: qsTr("Share") text: qsTr("Partager")
onClicked: { onClicked: {
if (mainItem.selectedContact) { if (mainItem.selectedContact) {
var vcard = mainItem.selectedContact.core.getVCard() var vcard = mainItem.selectedContact.core.getVCard()
var username = mainItem.selectedContact.core.givenName + mainItem.selectedContact.core.familyName var username = mainItem.selectedContact.core.givenName + mainItem.selectedContact.core.familyName
var filepath = UtilsCpp.createVCardFile(username, vcard) var filepath = UtilsCpp.createVCardFile(username, vcard)
if (filepath == "") UtilsCpp.showInformationPopup(qsTr("Erreur"), qsTr("La création du fichier vcard a échoué")) if (filepath == "") UtilsCpp.showInformationPopup(qsTr("Erreur"), qsTr("La création du fichier vcard a échoué"), false)
else mainWindow.showInformationPopup(qsTr("VCard créée"), qsTr("VCard du contact enregistrée dans %1").arg(filepath))
UtilsCpp.shareByEmail(qsTr("Partage de contact"), vcard, filepath) UtilsCpp.shareByEmail(qsTr("Partage de contact"), vcard, filepath)
} }
} }