From 16757d0a85c3cd93004b9c3d2e14a2a7c40d773b Mon Sep 17 00:00:00 2001 From: Gaelle Braud Date: Tue, 25 Jun 2024 16:09:35 +0200 Subject: [PATCH] add popup before calling device --- Linphone/core/setting/SettingsCore.cpp | 14 ++++ Linphone/core/setting/SettingsCore.hpp | 6 ++ Linphone/view/Item/Popup.qml | 2 +- Linphone/view/Page/Main/ContactPage.qml | 93 ++++++++++++++++++++++++- 4 files changed, 111 insertions(+), 4 deletions(-) diff --git a/Linphone/core/setting/SettingsCore.cpp b/Linphone/core/setting/SettingsCore.cpp index 9dc9ced04..89e6f61fa 100644 --- a/Linphone/core/setting/SettingsCore.cpp +++ b/Linphone/core/setting/SettingsCore.cpp @@ -319,9 +319,23 @@ void Settings::setFirstLaunch(bool first) { if (firstLaunch != first) { mAppSettings.setValue("firstLaunch", (int)first); mAppSettings.sync(); + emit firstLaunchChanged(first); } } +void Settings::setDisplayDeviceCheckConfirmation(bool display) { + if (getDisplayDeviceCheckConfirmation() != display) { + mAppSettings.setValue("displayDeviceCheckConfirmation", display); + mAppSettings.sync(); + emit showVerifyDeviceConfirmationChanged(display); + } +} + +bool Settings::getDisplayDeviceCheckConfirmation() const { + auto val = mAppSettings.value("displayDeviceCheckConfirmation", 1).toInt(); + return val; +} + void Settings::startEchoCancellerCalibration() { mSettingsModelConnection->invokeToModel([this]() { mSettingsModel->startEchoCancellerCalibration(); }); } diff --git a/Linphone/core/setting/SettingsCore.hpp b/Linphone/core/setting/SettingsCore.hpp index 8c879cd5d..96839f981 100644 --- a/Linphone/core/setting/SettingsCore.hpp +++ b/Linphone/core/setting/SettingsCore.hpp @@ -79,6 +79,9 @@ public: Q_INVOKABLE void setFirstLaunch(bool first); Q_INVOKABLE bool getFirstLaunch() const; + Q_INVOKABLE void setDisplayDeviceCheckConfirmation(bool display); + Q_INVOKABLE bool getDisplayDeviceCheckConfirmation() const; + // Security. -------------------------------------------------------------------- bool getVfsEnabled() { return mVfsEnabled; @@ -184,6 +187,9 @@ signals: void logsEmailChanged(const QString &email); void logsFolderChanged(const QString &folder); + void firstLaunchChanged(bool firstLaunch); + void showVerifyDeviceConfirmationChanged(bool showVerifyDeviceConfirmation); + private: std::shared_ptr mSettingsModel; diff --git a/Linphone/view/Item/Popup.qml b/Linphone/view/Item/Popup.qml index 43afa0d08..71d36f635 100644 --- a/Linphone/view/Item/Popup.qml +++ b/Linphone/view/Item/Popup.qml @@ -6,7 +6,7 @@ import Linphone Control.Popup{ id: mainItem padding: 0 - property color underlineColor + property color underlineColor : DefaultStyle.main1_500_main property int radius: 16 * DefaultStyle.dp property bool hovered: mouseArea.containsMouse background: Item{ diff --git a/Linphone/view/Page/Main/ContactPage.qml b/Linphone/view/Page/Main/ContactPage.qml index 9f5a58645..a3d114c9a 100644 --- a/Linphone/view/Page/Main/ContactPage.qml +++ b/Linphone/view/Page/Main/ContactPage.qml @@ -62,6 +62,84 @@ AbstractMainPage { onAccepted: contact.core.remove() } + Popup { + id: verifyDevicePopup + property string deviceName + property string deviceAddress + padding: 30 * DefaultStyle.dp + anchors.centerIn: parent + closePolicy: Control.Popup.CloseOnEscape + modal: true + onAboutToHide: neverDisplayAgainCheckbox.checked = false + contentItem: ColumnLayout { + spacing: 45 * DefaultStyle.dp + ColumnLayout { + spacing: 10 * DefaultStyle.dp + Text { + text: qsTr("Augmenter la confiance") + font { + pixelSize: 22 * DefaultStyle.dp + weight: 800 * DefaultStyle.dp + } + } + ColumnLayout { + spacing: 24 * DefaultStyle.dp + Text { + Layout.preferredWidth: 529 * DefaultStyle.dp + text: qsTr("Pour augmenter le niveau de confiance vous devez appeler les différents appareils de votre contact et valider un code.") + font.pixelSize: 14 * DefaultStyle.dp + } + Text { + Layout.preferredWidth: 529 * DefaultStyle.dp + text: qsTr("Vous êtes sur le point d’appeler “%1” voulez vous continuer ?").arg(verifyDevicePopup.deviceName) + font.pixelSize: 14 * DefaultStyle.dp + } + } + } + RowLayout { + RowLayout { + spacing: 7 * DefaultStyle.dp + CheckBox{ + id: neverDisplayAgainCheckbox + } + Text { + text: qsTr("Ne plus afficher") + font.pixelSize: 14 * DefaultStyle.dp + MouseArea { + anchors.fill: parent + onClicked: neverDisplayAgainCheckbox.toggle() + } + } + } + Item{Layout.fillWidth: true} + RowLayout { + spacing: 15 * DefaultStyle.dp + Button { + inversedColors: true + text: qsTr("Annuler") + leftPadding: 20 * DefaultStyle.dp + rightPadding: 20 * DefaultStyle.dp + topPadding: 11 * DefaultStyle.dp + bottomPadding: 11 * DefaultStyle.dp + onClicked: verifyDevicePopup.close() + } + Button { + text: qsTr("Appeler") + leftPadding: 20 * DefaultStyle.dp + rightPadding: 20 * DefaultStyle.dp + topPadding: 11 * DefaultStyle.dp + bottomPadding: 11 * DefaultStyle.dp + onClicked: { + SettingsCpp.setDisplayDeviceCheckConfirmation(!neverDisplayAgainCheckbox.checked) + UtilsCpp.createCall(verifyDevicePopup.deviceAddress, {}, LinphoneEnums.MediaEncryption.Zrtp) + onClicked: verifyDevicePopup.close() + } + } + } + } + } + } + leftPanelContent: Item { id: leftPanel property int leftMargin: 45 * DefaultStyle.dp @@ -518,8 +596,9 @@ AbstractMainPage { height: 30 * DefaultStyle.dp property var callObj property CallGui deviceCall: callObj ? callObj.value : null + property string deviceName: modelData.name.length != 0 ? modelData.name : qsTr("Appareil sans nom") Text { - text: modelData.name.length != 0 ? modelData.name : qsTr("Appareil sans nom") + text: deviceDelegate.deviceName font.pixelSize: 14 * DefaultStyle.dp } Item{Layout.fillWidth: true} @@ -529,6 +608,7 @@ AbstractMainPage { width: 22 * DefaultStyle.dp height: 22 * DefaultStyle.dp } + Button { visible: modelData.securityLevel != LinphoneEnums.SecurityLevel.EndToEndEncryptedAndVerified color: DefaultStyle.main1_100 @@ -542,8 +622,15 @@ AbstractMainPage { topPadding: 6 * DefaultStyle.dp bottomPadding: 6 * DefaultStyle.dp onClicked: { - UtilsCpp.createCall(modelData.address, {}, LinphoneEnums.MediaEncryption.Zrtp) - parent.callObj = UtilsCpp.getCallByAddress(modelData.address) + if (SettingsCpp.getDisplayDeviceCheckConfirmation()) { + verifyDevicePopup.deviceName = deviceDelegate.deviceName + verifyDevicePopup.deviceAddress = modelData.address + verifyDevicePopup.open() + } + else { + UtilsCpp.createCall(modelData.address, {}, LinphoneEnums.MediaEncryption.Zrtp) + parent.callObj = UtilsCpp.getCallByAddress(modelData.address) + } } } }