diff --git a/qml.qrc b/qml.qrc index c6396fa303b51b2c6740cf9f6ec876a2a3d2c327..8f5835d1dc448dbe036d0aa2ade1ed49c1fd156a 100644 --- a/qml.qrc +++ b/qml.qrc @@ -65,6 +65,7 @@ <file>src/settingsview/components/AdvancedPublicAddressSettings.qml</file> <file>src/settingsview/components/AdvancedConnectivitySettings.qml</file> <file>src/settingsview/components/AdvancedCallSettings.qml</file> + <file>src/settingsview/components/AdvancedChatSettings.qml</file> <file>src/settingsview/components/SettingMaterialButton.qml</file> <file>src/settingsview/components/ToggleSwitch.qml</file> <file>src/settingsview/components/SettingSpinBox.qml</file> diff --git a/src/constant/JamiStrings.qml b/src/constant/JamiStrings.qml index e1ecee629bf8bd11679bb8fe067a8b84d054f6b2..d94a7ab39952055f279d67e628e9af17d5dfc01c 100644 --- a/src/constant/JamiStrings.qml +++ b/src/constant/JamiStrings.qml @@ -75,6 +75,11 @@ Item { property string addCustomRingtone: qsTr("Add a custom ringtone") property string selectNewRingtone: qsTr("Select a new ringtone") + // AdvancedChatSettings + property string chatSettings: qsTr("Chat Settings") + property string enableReadReceipts: qsTr("Enable read receipts") + property string enableReadReceiptsTooltip: qsTr("Send and receive receipts indicating that a message have been displayed") + // AdvancedVoiceMailSettings property string voiceMail: qsTr("Voicemail") property string voiceMailDialCode: qsTr("Voicemail dial code") diff --git a/src/settingsadapter.cpp b/src/settingsadapter.cpp index bc908bd4e3535353c8d4ff37047f5d6c5e42b2c4..7ec10f603c64641a866de80e0a2d89c0e4ba3b85 100644 --- a/src/settingsadapter.cpp +++ b/src/settingsadapter.cpp @@ -324,6 +324,12 @@ SettingsAdapter::getAccountConfig_DHT_PublicInCalls() return getAccountConfig().DHT.PublicInCalls; } +bool +SettingsAdapter::getAccountConfig_ReadReceipt() +{ + return getAccountConfig().sendReadReceipt; +} + bool SettingsAdapter::getAccountConfig_RendezVous() { @@ -632,6 +638,15 @@ SettingsAdapter::setAutoAnswerCalls(bool state) lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); } +void +SettingsAdapter::setSendReadReceipt(bool state) +{ + auto confProps = lrcInstance_->accountModel().getAccountConfig( + lrcInstance_->get_currentAccountId()); + confProps.sendReadReceipt = state; + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); +} + void SettingsAdapter::setEnableRingtone(bool state) { diff --git a/src/settingsadapter.h b/src/settingsadapter.h index 9f0e3fb847763cfcc950910f633962bc28fd6ff8..73ea02a76b3233c4a50df055fb396f20f1cef096 100644 --- a/src/settingsadapter.h +++ b/src/settingsadapter.h @@ -104,6 +104,7 @@ public: Q_INVOKABLE bool getAccountConfig_PeerDiscovery(); Q_INVOKABLE bool getAccountConfig_DHT_PublicInCalls(); + Q_INVOKABLE bool getAccountConfig_ReadReceipt(); Q_INVOKABLE bool getAccountConfig_RendezVous(); Q_INVOKABLE bool getAccountConfig_AutoAnswer(); @@ -164,6 +165,7 @@ public: Q_INVOKABLE void setCallsUntrusted(bool state); Q_INVOKABLE void setIsRendezVous(bool state); Q_INVOKABLE void setAutoAnswerCalls(bool state); + Q_INVOKABLE void setSendReadReceipt(bool state); Q_INVOKABLE void setEnableRingtone(bool state); Q_INVOKABLE void setEnableProxy(bool state); Q_INVOKABLE void setKeepAliveEnabled(bool state); diff --git a/src/settingsview/components/AdvancedChatSettings.qml b/src/settingsview/components/AdvancedChatSettings.qml new file mode 100644 index 0000000000000000000000000000000000000000..f403109a12b1dc2716824aa5eede4786a0383721 --- /dev/null +++ b/src/settingsview/components/AdvancedChatSettings.qml @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2021 by Savoir-faire Linux + * Author: Sébastien Blin <sebastien.blin@savoirfairelinux.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +import QtQuick 2.14 +import QtQuick.Layouts 1.14 +import QtQuick.Controls 2.14 + +import net.jami.Adapters 1.0 +import net.jami.Constants 1.0 + +import "../../commoncomponents" + +ColumnLayout { + id: root + + property int itemWidth + + function updateSettings() { + checkBoxSendDisplayed.checked = SettingsAdapter.getAccountConfig_ReadReceipt() + } + + ElidedTextLabel { + Layout.fillWidth: true + + eText: JamiStrings.chatSettings + fontSize: JamiTheme.headerFontSize + maxWidth: width + } + + ColumnLayout { + Layout.fillWidth: true + Layout.leftMargin: JamiTheme.preferredMarginSize + + ToggleSwitch { + id: checkBoxSendDisplayed + + tooltipText: JamiStrings.enableReadReceiptsTooltip + labelText: JamiStrings.enableReadReceipts + fontPointSize: JamiTheme.settingsFontSize + + onSwitchToggled: { + SettingsAdapter.setSendReadReceipt(checked) + } + } + } +} diff --git a/src/settingsview/components/AdvancedSettings.qml b/src/settingsview/components/AdvancedSettings.qml index b9cb3c450941cb623a8fef3f42234e3439d10704..f251097af9ec5240abec188f751e9e42e746a940 100644 --- a/src/settingsview/components/AdvancedSettings.qml +++ b/src/settingsview/components/AdvancedSettings.qml @@ -39,6 +39,7 @@ ColumnLayout { function updateAdvancedAccountInfos() { advancedCallSettings.updateCallSettingsInfos() + advancedChatSettings.updateSettings() advancedVoiceMailSettings.updateVoiceMailSettingsInfos() advancedSIPSecuritySettings.updateSecurityAccountInfos() advancedNameServerSettings.updateNameServerInfos() @@ -104,7 +105,16 @@ ColumnLayout { Layout.fillWidth: true - isSIP: root.isSIP + isSIP: LRCInstance.currentAccountType === Profile.Type.SIP + itemWidth: root.itemWidth + } + + AdvancedChatSettings { + id: advancedChatSettings + + Layout.fillWidth: true + + visible: LRCInstance.currentAccountType === Profile.Type.JAMI itemWidth: root.itemWidth } @@ -113,7 +123,7 @@ ColumnLayout { Layout.fillWidth: true - visible: root.isSIP + visible: LRCInstance.currentAccountType === Profile.Type.SIP itemWidth: root.itemWidth } @@ -122,7 +132,7 @@ ColumnLayout { Layout.fillWidth: true - visible: root.isSIP + visible: LRCInstance.currentAccountType === Profile.Type.SIP itemWidth: root.itemWidth } @@ -131,7 +141,7 @@ ColumnLayout { Layout.fillWidth: true - visible: !root.isSIP + visible: LRCInstance.currentAccountType === Profile.Type.JAMI itemWidth: root.itemWidth } @@ -140,7 +150,7 @@ ColumnLayout { Layout.fillWidth: true - visible: !root.isSIP + visible: LRCInstance.currentAccountType === Profile.Type.JAMI itemWidth: root.itemWidth } @@ -149,7 +159,7 @@ ColumnLayout { Layout.fillWidth: true - visible: !root.isSIP + visible: LRCInstance.currentAccountType === Profile.Type.JAMI itemWidth: root.itemWidth } @@ -159,7 +169,7 @@ ColumnLayout { Layout.fillWidth: true itemWidth: root.itemWidth - isSIP: root.isSIP + isSIP: LRCInstance.currentAccountType === Profile.Type.SIP } AdvancedPublicAddressSettings {