Skip to content
Snippets Groups Projects
Commit 417a0fe0 authored by Sébastien Blin's avatar Sébastien Blin
Browse files

generalsettings: add file transfer settings

+ Auto accept files from trusted sources (default: true)
+ Auto accept files from untrusted sources (default: false)
+ Size limit (default: 20Mb)

Change-Id: I0e1068e3996786b23ba9a7797d02b7f8bb0f89d1
GitLab: #160
parent 1e7c712a
No related branches found
No related tags found
No related merge requests found
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
<file>src/commoncomponents/SpinningAnimation.qml</file> <file>src/commoncomponents/SpinningAnimation.qml</file>
<file>src/settingsview/SettingsView.qml</file> <file>src/settingsview/SettingsView.qml</file>
<file>src/settingsview/components/ChatviewSettings.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/SettingsMenu.qml</file>
<file>src/settingsview/components/SettingsHeader.qml</file> <file>src/settingsview/components/SettingsHeader.qml</file>
<file>src/settingsview/components/SystemSettings.qml</file> <file>src/settingsview/components/SystemSettings.qml</file>
......
...@@ -36,6 +36,9 @@ const QString defaultDownloadPath = QStandardPaths::writableLocation( ...@@ -36,6 +36,9 @@ const QString defaultDownloadPath = QStandardPaths::writableLocation(
X(DownloadPath, defaultDownloadPath) \ X(DownloadPath, defaultDownloadPath) \
X(EnableNotifications, true) \ X(EnableNotifications, true) \
X(EnableTypingIndicator, true) \ X(EnableTypingIndicator, true) \
X(AllowFromUntrusted, false) \
X(AcceptTransferBelow, 20) \
X(AutoAcceptFiles, true) \
X(DisplayHyperlinkPreviews, true) \ X(DisplayHyperlinkPreviews, true) \
X(EnableDarkTheme, false) \ X(EnableDarkTheme, false) \
X(AutoUpdate, true) \ X(AutoUpdate, true) \
......
...@@ -321,6 +321,13 @@ Item { ...@@ -321,6 +321,13 @@ Item {
property string enableTypingIndicator: qsTr("Enable typing indicators") property string enableTypingIndicator: qsTr("Enable typing indicators")
property string displayHyperlinkPreviews: qsTr("Display hyperlink previews in the chatview") 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 // Updates
property string betaInstall: qsTr("Install beta version") property string betaInstall: qsTr("Install beta version")
property string checkForUpdates: qsTr("Check for updates now") property string checkForUpdates: qsTr("Check for updates now")
......
...@@ -263,7 +263,15 @@ MainApplication::init() ...@@ -263,7 +263,15 @@ MainApplication::init()
} }
auto downloadPath = settingsManager_->getValue(Settings::Key::DownloadPath); 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().downloadDirectory = downloadPath.toString() + "/";
lrcInstance_->accountModel().autoTransferFromUntrusted = allowTransferFromUntrusted;
lrcInstance_->accountModel().autoTransferFromTrusted = allowTransferFromTrusted;
lrcInstance_->accountModel().autoTransferSizeThreshold = acceptTransferBelow;
initQmlLayer(); initQmlLayer();
initSystray(); initSystray();
......
...@@ -897,6 +897,27 @@ SettingsAdapter::registrationExpirationTimeSpinBoxValueChanged(int value) ...@@ -897,6 +897,27 @@ SettingsAdapter::registrationExpirationTimeSpinBoxValueChanged(int value)
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); 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 void
SettingsAdapter::networkInterfaceSpinBoxValueChanged(int value) SettingsAdapter::networkInterfaceSpinBoxValueChanged(int value)
{ {
......
...@@ -202,6 +202,10 @@ public: ...@@ -202,6 +202,10 @@ public:
Q_INVOKABLE void videoRTPMinPortSpinBoxEditFinished(int value); Q_INVOKABLE void videoRTPMinPortSpinBoxEditFinished(int value);
Q_INVOKABLE void videoRTPMaxPortSpinBoxEditFinished(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 tlsProtocolComboBoxIndexChanged(const int& index);
Q_INVOKABLE void setDeviceName(QString text); Q_INVOKABLE void setDeviceName(QString text);
......
...@@ -61,6 +61,7 @@ Rectangle { ...@@ -61,6 +61,7 @@ Rectangle {
pageIdCurrentAccountSettings.updateAccountInfoDisplayed() pageIdCurrentAccountSettings.updateAccountInfoDisplayed()
break break
case SettingsView.General: case SettingsView.General:
generalSettings.updateValues()
AccountAdapter.stopPreviewing() AccountAdapter.stopPreviewing()
selectedMenu = sel selectedMenu = sel
break break
......
/*
* 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)
}
}
...@@ -39,6 +39,10 @@ Rectangle { ...@@ -39,6 +39,10 @@ Rectangle {
color: JamiTheme.secondaryBackgroundColor color: JamiTheme.secondaryBackgroundColor
function updateValues() {
fileTransferSettings.updateValues()
}
ColumnLayout { ColumnLayout {
id: generalSettingsColumnLayout id: generalSettingsColumnLayout
...@@ -66,6 +70,17 @@ Rectangle { ...@@ -66,6 +70,17 @@ Rectangle {
itemWidth: preferredColumnWidth 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 // call recording setting panel
RecordingSettings { RecordingSettings {
Layout.fillWidth: true Layout.fillWidth: true
......
...@@ -39,6 +39,7 @@ RowLayout { ...@@ -39,6 +39,7 @@ RowLayout {
property int topValue property int topValue
property int step property int step
property int valueField property int valueField
property string tooltipText: ""
signal newValue signal newValue
...@@ -87,5 +88,10 @@ RowLayout { ...@@ -87,5 +88,10 @@ RowLayout {
border.color: enabled? root.borderColor : "transparent" border.color: enabled? root.borderColor : "transparent"
color: JamiTheme.editBackgroundColor color: JamiTheme.editBackgroundColor
} }
hoverEnabled: true
ToolTip.delay: Qt.styleHints.mousePressAndHoldInterval
ToolTip.visible: hovered && (root.tooltipText.length > 0)
ToolTip.text: root.tooltipText
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment