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 &attachment,
const QString &receiver) {
QString url = QString("mailto:?to=%1&subject=%2&body=%3&attachment=%4")
.arg(receiver)
.arg(subject)
.arg(body)
.arg("/home/gaelle/ligneconsolevscode");
QDesktopServices::openUrl(QUrl(url, QUrl::TolerantMode));
// QString attach = attachment;
// attach.prepend("file:///");
QUrl url(QString("mailto:?to=%1&subject=%2&body=%3").arg(receiver).arg(subject).arg(body));
QDesktopServices::openUrl(url);
}
QString Utils::getClipboardText() {

View file

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

View file

@ -234,7 +234,8 @@ ListView {
var vcard = modelData.core.getVCard()
var username = modelData.core.givenName + modelData.core.familyName
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)
}
}

View file

@ -708,13 +708,14 @@ AbstractMainPage {
Layout.preferredHeight: 50 * DefaultStyle.dp
iconSize: 24 * DefaultStyle.dp
iconSource: AppIcons.shareNetwork
text: qsTr("Share")
text: qsTr("Partager")
onClicked: {
if (mainItem.selectedContact) {
var vcard = mainItem.selectedContact.core.getVCard()
var username = mainItem.selectedContact.core.givenName + mainItem.selectedContact.core.familyName
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)
}
}