mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-17 19:38:09 +00:00
share friend
This commit is contained in:
parent
7a21e17c55
commit
035b9af8a9
8 changed files with 94 additions and 49 deletions
|
|
@ -194,6 +194,11 @@ QString Paths::getAvatarsDirPath() {
|
|||
Constants::PathAvatars);
|
||||
}
|
||||
|
||||
QString Paths::getVCardsPath() {
|
||||
return getWritableDirPath(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) +
|
||||
Constants::PathVCards);
|
||||
}
|
||||
|
||||
QString Paths::getCallHistoryFilePath() {
|
||||
return getWritableFilePath(getAppCallHistoryFilePath());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ bool filePathExists(const QString &path, const bool isWritable = false);
|
|||
QString getAppLocalDirPath();
|
||||
QString getAssistantConfigDirPath();
|
||||
QString getAvatarsDirPath();
|
||||
QString getVCardsPath();
|
||||
QString getCallHistoryFilePath();
|
||||
QString getCapturesDirPath();
|
||||
QString getCodecsDirPath();
|
||||
|
|
|
|||
|
|
@ -132,6 +132,7 @@ public:
|
|||
static constexpr char PathData[] = "/" EXECUTABLE_NAME;
|
||||
static constexpr char PathTools[] = "/tools/";
|
||||
static constexpr char PathLogs[] = "/logs/";
|
||||
static constexpr char PathVCards[] = "/vcards/";
|
||||
#ifdef APPLE
|
||||
static constexpr char PathPlugins[] = "/Plugins/";
|
||||
#else
|
||||
|
|
|
|||
|
|
@ -29,7 +29,9 @@
|
|||
#include "model/object/VariantObject.hpp"
|
||||
#include "model/tool/ToolModel.hpp"
|
||||
#include "tool/providers/AvatarProvider.hpp"
|
||||
|
||||
#include <QClipboard>
|
||||
#include <QDesktopServices>
|
||||
#include <QImageReader>
|
||||
#include <QQuickWindow>
|
||||
#include <QRandomGenerator>
|
||||
|
|
@ -378,6 +380,29 @@ bool Utils::copyToClipboard(const QString &text) {
|
|||
return !clipboardText.isEmpty();
|
||||
}
|
||||
|
||||
QString Utils::createVCardFile(const QString &username, const QString &vcardAsString) {
|
||||
auto filepath = Paths::getVCardsPath() + username + ".vcf";
|
||||
QFile file(filepath);
|
||||
if (file.open(QIODevice::ReadWrite)) {
|
||||
QTextStream stream(&file);
|
||||
stream << vcardAsString;
|
||||
return filepath;
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
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 Utils::getClipboardText() {
|
||||
QClipboard *clipboard = QApplication::clipboard();
|
||||
return clipboard->text();
|
||||
|
|
|
|||
|
|
@ -85,6 +85,11 @@ public:
|
|||
Q_INVOKABLE static QStringList generateSecurityLettersArray(int arraySize, int correctIndex, QString correctCode);
|
||||
Q_INVOKABLE static int getRandomIndex(int size);
|
||||
Q_INVOKABLE static bool copyToClipboard(const QString &text);
|
||||
Q_INVOKABLE static QString createVCardFile(const QString &username, const QString &vcardAsString);
|
||||
Q_INVOKABLE static void shareByEmail(const QString &subject,
|
||||
const QString &body = QString(),
|
||||
const QString &attachment = QString(),
|
||||
const QString &receiver = QString());
|
||||
Q_INVOKABLE static QString getClipboardText();
|
||||
Q_INVOKABLE static QString toDateString(QDateTime date, const QString &format = "");
|
||||
Q_INVOKABLE static QString toDateString(QDate date, const QString &format = "");
|
||||
|
|
|
|||
|
|
@ -205,52 +205,50 @@ ListView {
|
|||
|
||||
popup.contentItem: ColumnLayout {
|
||||
Button {
|
||||
text: modelData.core.starred ? qsTr("Enlever des favoris") : qsTr("Mettre en favori")
|
||||
background: Item{}
|
||||
contentItem: RowLayout {
|
||||
EffectImage {
|
||||
imageSource: modelData.core.starred ? AppIcons.heartFill : AppIcons.heart
|
||||
colorizationColor: modelData.core.starred ? DefaultStyle.danger_500main : DefaultStyle.main2_600
|
||||
fillMode: Image.PreserveAspectFit
|
||||
width: 24 * DefaultStyle.dp
|
||||
height: 24 * DefaultStyle.dp
|
||||
Layout.preferredWidth: 24 * DefaultStyle.dp
|
||||
Layout.preferredHeight: 24 * DefaultStyle.dp
|
||||
}
|
||||
Text {
|
||||
text: modelData.core.starred ? qsTr("Enlever des favoris") : qsTr("Mettre en favori")
|
||||
color: DefaultStyle.main2_500main
|
||||
font {
|
||||
pixelSize: 14 * DefaultStyle.dp
|
||||
weight: 400 * DefaultStyle.dp
|
||||
}
|
||||
}
|
||||
}
|
||||
icon.source: modelData.core.starred ? AppIcons.heartFill : AppIcons.heart
|
||||
icon.width: 24 * DefaultStyle.dp
|
||||
icon.height: 24 * DefaultStyle.dp
|
||||
spacing: 10 * DefaultStyle.dp
|
||||
textSize: 14 * DefaultStyle.dp
|
||||
textWeight: 400 * DefaultStyle.dp
|
||||
textColor: DefaultStyle.main2_500main
|
||||
contentImageColor: modelData.core.starred ? DefaultStyle.danger_500main : DefaultStyle.main2_600
|
||||
onClicked: {
|
||||
modelData.core.lSetStarred(!modelData.core.starred)
|
||||
friendPopup.close()
|
||||
}
|
||||
}
|
||||
Button {
|
||||
text: qsTr("Partager")
|
||||
background: Item{}
|
||||
contentItem: RowLayout {
|
||||
EffectImage {
|
||||
imageSource: AppIcons.trashCan
|
||||
width: 24 * DefaultStyle.dp
|
||||
height: 24 * DefaultStyle.dp
|
||||
Layout.preferredWidth: 24 * DefaultStyle.dp
|
||||
Layout.preferredHeight: 24 * DefaultStyle.dp
|
||||
fillMode: Image.PreserveAspectFit
|
||||
colorizationColor: DefaultStyle.danger_500main
|
||||
}
|
||||
Text {
|
||||
text: qsTr("Supprimer")
|
||||
color: DefaultStyle.danger_500main
|
||||
font {
|
||||
pixelSize: 14 * DefaultStyle.dp
|
||||
weight: 400 * DefaultStyle.dp
|
||||
}
|
||||
}
|
||||
icon.source: AppIcons.shareNetwork
|
||||
icon.width: 24 * DefaultStyle.dp
|
||||
icon.height: 24 * DefaultStyle.dp
|
||||
spacing: 10 * DefaultStyle.dp
|
||||
textSize: 14 * DefaultStyle.dp
|
||||
textWeight: 400 * DefaultStyle.dp
|
||||
textColor: DefaultStyle.main2_500main
|
||||
onClicked: {
|
||||
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é"))
|
||||
UtilsCpp.shareByEmail(qsTr("Partage de contact"), vcard, filepath)
|
||||
}
|
||||
}
|
||||
Button {
|
||||
text: qsTr("Supprimer")
|
||||
background: Item{}
|
||||
icon.source: AppIcons.trashCan
|
||||
icon.width: 24 * DefaultStyle.dp
|
||||
icon.height: 24 * DefaultStyle.dp
|
||||
spacing: 10 * DefaultStyle.dp
|
||||
textSize: 14 * DefaultStyle.dp
|
||||
textWeight: 400 * DefaultStyle.dp
|
||||
textColor: DefaultStyle.danger_500main
|
||||
contentImageColor: DefaultStyle.danger_500main
|
||||
onClicked: {
|
||||
mainItem.contactDeletionRequested(modelData)
|
||||
friendPopup.close()
|
||||
|
|
@ -267,6 +265,7 @@ ListView {
|
|||
hoverEnabled: mainItem.hoverEnabled
|
||||
anchors.fill: itemDelegate
|
||||
height: mainItem.height
|
||||
acceptedButtons: Qt.AllButtons
|
||||
z: -1
|
||||
Rectangle {
|
||||
anchors.fill: contactArea
|
||||
|
|
@ -274,16 +273,20 @@ ListView {
|
|||
color: DefaultStyle.main2_100
|
||||
visible: contactArea.containsMouse || friendPopup.hovered || (!mainItem.multiSelectionEnabled && mainItem.currentIndex === index)
|
||||
}
|
||||
onClicked: {
|
||||
mainItem.currentIndex = -1
|
||||
mainItem.currentIndex = index
|
||||
if (mainItem.multiSelectionEnabled) {
|
||||
var indexInSelection = mainItem.selectedContacts.indexOf(modelData.core.defaultAddress)
|
||||
if (indexInSelection == -1) {
|
||||
mainItem.addContactToSelection(modelData.core.defaultAddress)
|
||||
}
|
||||
else {
|
||||
mainItem.removeContactFromSelection(indexInSelection, 1)
|
||||
onClicked: (mouse) => {
|
||||
if (mouse.button == Qt.RightButton) {
|
||||
friendPopup.open()
|
||||
} else {
|
||||
mainItem.currentIndex = -1
|
||||
mainItem.currentIndex = index
|
||||
if (mainItem.multiSelectionEnabled) {
|
||||
var indexInSelection = mainItem.selectedContacts.indexOf(modelData.core.defaultAddress)
|
||||
if (indexInSelection == -1) {
|
||||
mainItem.addContactToSelection(modelData.core.defaultAddress)
|
||||
}
|
||||
else {
|
||||
mainItem.removeContactFromSelection(indexInSelection, 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,9 @@ Button {
|
|||
function close() {
|
||||
popup.close()
|
||||
}
|
||||
function open() {
|
||||
popup.open()
|
||||
}
|
||||
|
||||
background: Rectangle {
|
||||
anchors.fill: mainItem
|
||||
|
|
|
|||
|
|
@ -712,8 +712,10 @@ AbstractMainPage {
|
|||
onClicked: {
|
||||
if (mainItem.selectedContact) {
|
||||
var vcard = mainItem.selectedContact.core.getVCard()
|
||||
UtilsCpp.copyToClipboard(vcard)
|
||||
UtilsCpp.showInformationPopup(qsTr("Copié"), qsTr("VCard copiée dans le presse-papier"))
|
||||
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é"))
|
||||
UtilsCpp.shareByEmail(qsTr("Partage de contact"), vcard, filepath)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue