diff --git a/qml.qrc b/qml.qrc index c33ffabbe6b55472fbd2098a9e93c32673a65dff..233a6e2f4e1d9bc632325c4b0bca04e0703f4f88 100644 --- a/qml.qrc +++ b/qml.qrc @@ -33,6 +33,7 @@ <file>src/commoncomponents/SpinningAnimation.qml</file> <file>src/settingsview/SettingsView.qml</file> <file>src/settingsview/components/ChatviewSettings.qml</file> + <file>src/settingsview/components/FileTransferSettings.qml</file> <file>src/settingsview/components/SettingsMenu.qml</file> <file>src/settingsview/components/SettingsHeader.qml</file> <file>src/settingsview/components/SystemSettings.qml</file> diff --git a/src/appsettingsmanager.h b/src/appsettingsmanager.h index d3b08111095f22d4ed8ef3d3553423ca48acbc6d..6ff083ff161e8d0672bda9aaa56e15dc90ee2ee8 100644 --- a/src/appsettingsmanager.h +++ b/src/appsettingsmanager.h @@ -36,6 +36,9 @@ const QString defaultDownloadPath = QStandardPaths::writableLocation( X(DownloadPath, defaultDownloadPath) \ X(EnableNotifications, true) \ X(EnableTypingIndicator, true) \ + X(AllowFromUntrusted, false) \ + X(AcceptTransferBelow, 20) \ + X(AutoAcceptFiles, true) \ X(DisplayHyperlinkPreviews, true) \ X(EnableDarkTheme, false) \ X(AutoUpdate, true) \ diff --git a/src/constant/JamiStrings.qml b/src/constant/JamiStrings.qml index b6223327916abd88b23e85f650d4963c9eddcf6f..dfc4c83d69471cc21064d431f66d332500096252 100644 --- a/src/constant/JamiStrings.qml +++ b/src/constant/JamiStrings.qml @@ -321,6 +321,13 @@ Item { property string enableTypingIndicator: qsTr("Enable typing indicators") property string displayHyperlinkPreviews: qsTr("Display hyperlink previews in the chatview") + // File transfer settings + property string fileTransfer: qsTr("File transfer") + property string allowFromUntrusted: qsTr("Allow incoming files from unknown contacts") + property string autoAcceptFiles: qsTr("Automatically accept incoming files") + property string acceptTransferBelow: qsTr("Accept transfer limit") + property string acceptTransferTooltip: qsTr("in MB, 0 = unlimited") + // Updates property string betaInstall: qsTr("Install beta version") property string checkForUpdates: qsTr("Check for updates now") diff --git a/src/mainapplication.cpp b/src/mainapplication.cpp index 2e07c911b522abc22f9ed7cb5ff5ce5428a8cff0..26d8200c973b96e53c5aae4b408d8767b64bbaa4 100644 --- a/src/mainapplication.cpp +++ b/src/mainapplication.cpp @@ -263,7 +263,15 @@ MainApplication::init() } auto downloadPath = settingsManager_->getValue(Settings::Key::DownloadPath); + auto allowTransferFromUntrusted = settingsManager_->getValue(Settings::Key::AllowFromUntrusted) + .toBool(); + auto allowTransferFromTrusted = settingsManager_->getValue(Settings::Key::AutoAcceptFiles) + .toBool(); + auto acceptTransferBelow = settingsManager_->getValue(Settings::Key::AcceptTransferBelow).toInt(); lrcInstance_->accountModel().downloadDirectory = downloadPath.toString() + "/"; + lrcInstance_->accountModel().autoTransferFromUntrusted = allowTransferFromUntrusted; + lrcInstance_->accountModel().autoTransferFromTrusted = allowTransferFromTrusted; + lrcInstance_->accountModel().autoTransferSizeThreshold = acceptTransferBelow; initQmlLayer(); initSystray(); diff --git a/src/settingsadapter.cpp b/src/settingsadapter.cpp index 1702aaeed93f2d84566d2e8a6bf03ccdb9e5612e..3c60c2435a699e57b28f265221bd9371e770fe2c 100644 --- a/src/settingsadapter.cpp +++ b/src/settingsadapter.cpp @@ -897,6 +897,27 @@ SettingsAdapter::registrationExpirationTimeSpinBoxValueChanged(int value) lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); } +void +SettingsAdapter::autoAcceptFiles(bool value) +{ + lrcInstance_->accountModel().autoTransferFromTrusted = value; + setAppValue(Settings::Key::AutoAcceptFiles, value); +} + +void +SettingsAdapter::allowFromUntrusted(bool value) +{ + lrcInstance_->accountModel().autoTransferFromUntrusted = value; + setAppValue(Settings::Key::AllowFromUntrusted, value); +} + +void +SettingsAdapter::acceptTransferBelow(int value) +{ + lrcInstance_->accountModel().autoTransferSizeThreshold = value; + setAppValue(Settings::Key::AcceptTransferBelow, value); +} + void SettingsAdapter::networkInterfaceSpinBoxValueChanged(int value) { diff --git a/src/settingsadapter.h b/src/settingsadapter.h index cc06b307041885bc8550f34d1df0bc96cf664ade..7b5d9efca26e5f753c70a1da3d710aa033a98dc3 100644 --- a/src/settingsadapter.h +++ b/src/settingsadapter.h @@ -202,6 +202,10 @@ public: Q_INVOKABLE void videoRTPMinPortSpinBoxEditFinished(int value); Q_INVOKABLE void videoRTPMaxPortSpinBoxEditFinished(int value); + Q_INVOKABLE void autoAcceptFiles(bool value); + Q_INVOKABLE void allowFromUntrusted(bool value); + Q_INVOKABLE void acceptTransferBelow(int value); + Q_INVOKABLE void tlsProtocolComboBoxIndexChanged(const int& index); Q_INVOKABLE void setDeviceName(QString text); diff --git a/src/settingsview/SettingsView.qml b/src/settingsview/SettingsView.qml index 75e783acdefa07f51d648dc85bae799bbd65bde2..1c11c5ea8d42738895ba2fd102688d4426b95c1c 100644 --- a/src/settingsview/SettingsView.qml +++ b/src/settingsview/SettingsView.qml @@ -61,6 +61,7 @@ Rectangle { pageIdCurrentAccountSettings.updateAccountInfoDisplayed() break case SettingsView.General: + generalSettings.updateValues() AccountAdapter.stopPreviewing() selectedMenu = sel break diff --git a/src/settingsview/components/FileTransferSettings.qml b/src/settingsview/components/FileTransferSettings.qml new file mode 100644 index 0000000000000000000000000000000000000000..894e28b51de57220365070965f495eba50ad2464 --- /dev/null +++ b/src/settingsview/components/FileTransferSettings.qml @@ -0,0 +1,94 @@ +/* + * 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.Controls 2.14 +import QtQuick.Layouts 1.14 + +import net.jami.Adapters 1.0 +import net.jami.Enums 1.0 +import net.jami.Constants 1.0 + +ColumnLayout { + id:root + + property int itemWidth + + function updateValues() { + acceptTransferBelowSpinBox.setValue(SettingsAdapter.getAppValue(Settings.AcceptTransferBelow)) + allowFromUntrustedCheckbox.checked = SettingsAdapter.getAppValue(Settings.AllowFromUntrusted) + autoAcceptFilesCheckbox.checked = SettingsAdapter.getAppValue(Settings.AutoAcceptFiles) + } + + Label { + Layout.fillWidth: true + + text: JamiStrings.fileTransfer + font.pointSize: JamiTheme.headerFontSize + font.kerning: true + color: JamiTheme.textColor + + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter + } + + ToggleSwitch { + id: allowFromUntrustedCheckbox + Layout.fillWidth: true + Layout.leftMargin: JamiTheme.preferredMarginSize + + checked: SettingsAdapter.getAppValue(Settings.AllowFromUntrusted) + + labelText: JamiStrings.allowFromUntrusted + fontPointSize: JamiTheme.settingsFontSize + + tooltipText: JamiStrings.allowFromUntrusted + + onSwitchToggled: SettingsAdapter.allowFromUntrusted(checked) + } + + ToggleSwitch { + id: autoAcceptFilesCheckbox + Layout.fillWidth: true + Layout.leftMargin: JamiTheme.preferredMarginSize + + checked: SettingsAdapter.getAppValue(Settings.AutoAcceptFiles) + + labelText: JamiStrings.autoAcceptFiles + fontPointSize: JamiTheme.settingsFontSize + + tooltipText: JamiStrings.autoAcceptFiles + + onSwitchToggled: SettingsAdapter.autoAcceptFiles(checked) + } + + SettingSpinBox { + id: acceptTransferBelowSpinBox + Layout.fillWidth: true + Layout.leftMargin: JamiTheme.preferredMarginSize + + title: JamiStrings.acceptTransferBelow + tooltipText: JamiStrings.acceptTransferTooltip + itemWidth: root.itemWidth + bottomValue: 0 + topValue: 99999999 + step: 1 + + onNewValue: SettingsAdapter.acceptTransferBelow(valueField) + } +} diff --git a/src/settingsview/components/GeneralSettingsPage.qml b/src/settingsview/components/GeneralSettingsPage.qml index b14be3899006dd4a4d15246ec7c9a622c591899a..de6328b7fc94a54b531b1eddd40ea9b1f27fd8a1 100644 --- a/src/settingsview/components/GeneralSettingsPage.qml +++ b/src/settingsview/components/GeneralSettingsPage.qml @@ -39,6 +39,10 @@ Rectangle { color: JamiTheme.secondaryBackgroundColor + function updateValues() { + fileTransferSettings.updateValues() + } + ColumnLayout { id: generalSettingsColumnLayout @@ -66,6 +70,17 @@ Rectangle { itemWidth: preferredColumnWidth } + // file transfer setting panel + FileTransferSettings { + id: fileTransferSettings + Layout.fillWidth: true + Layout.topMargin: JamiTheme.preferredMarginSize + Layout.leftMargin: JamiTheme.preferredMarginSize + Layout.rightMargin: JamiTheme.preferredMarginSize + + itemWidth: preferredColumnWidth + } + // call recording setting panel RecordingSettings { Layout.fillWidth: true diff --git a/src/settingsview/components/SettingSpinBox.qml b/src/settingsview/components/SettingSpinBox.qml index 58d4d67c8a46fa2ed8c1a92bc4916f29dc103856..e749e728d38375b1604493a63f70e3bc70871112 100644 --- a/src/settingsview/components/SettingSpinBox.qml +++ b/src/settingsview/components/SettingSpinBox.qml @@ -39,6 +39,7 @@ RowLayout { property int topValue property int step property int valueField + property string tooltipText: "" signal newValue @@ -87,5 +88,10 @@ RowLayout { border.color: enabled? root.borderColor : "transparent" color: JamiTheme.editBackgroundColor } + + hoverEnabled: true + ToolTip.delay: Qt.styleHints.mousePressAndHoldInterval + ToolTip.visible: hovered && (root.tooltipText.length > 0) + ToolTip.text: root.tooltipText } }