diff --git a/Linphone/core/setting/SettingsCore.cpp b/Linphone/core/setting/SettingsCore.cpp index f94e49489..6fedae0a3 100644 --- a/Linphone/core/setting/SettingsCore.cpp +++ b/Linphone/core/setting/SettingsCore.cpp @@ -409,6 +409,11 @@ void SettingsCore::setSelf(QSharedPointer me) { mSettingsModelConnection->invokeToCore([this, enabled]() { setDisplayNotificationContent(enabled); }); }); + // Download folder + mSettingsModelConnection->makeConnectToModel(&SettingsModel::downloadFolderChanged, [this](const QString &folder) { + mSettingsModelConnection->invokeToCore([this, folder]() { setDownloadFolder(folder); }); + }); + // Auto recording mSettingsModelConnection->makeConnectToModel( &SettingsModel::automaticallyRecordCallsEnabledChanged, [this](const bool enabled) { @@ -1246,6 +1251,14 @@ QString SettingsCore::getDownloadFolder() const { return cleanPath; } +void SettingsCore::setDownloadFolder(QString folder) { + if (mDownloadFolder != folder) { + mDownloadFolder = folder; + emit downloadFolderChanged(); + setIsSaved(false); + } +} + void SettingsCore::writeIntoModel(std::shared_ptr model) const { mustBeInLinphoneThread(getClassName() + Q_FUNC_INFO); // Security diff --git a/Linphone/core/setting/SettingsCore.hpp b/Linphone/core/setting/SettingsCore.hpp index 85f159908..aec2115f4 100644 --- a/Linphone/core/setting/SettingsCore.hpp +++ b/Linphone/core/setting/SettingsCore.hpp @@ -42,6 +42,7 @@ public: echoCancellationEnabledChanged) Q_PROPERTY(bool autoDownloadReceivedFiles READ getAutoDownloadReceivedFiles WRITE setAutoDownloadReceivedFiles NOTIFY autoDownloadReceivedFilesChanged) + Q_PROPERTY(QString downloadFolder READ getDownloadFolder WRITE setDownloadFolder NOTIFY downloadFolderChanged) Q_PROPERTY(bool displayNotificationContent READ getDisplayNotificationContent WRITE setDisplayNotificationContent NOTIFY displayNotificationContentChanged) Q_PROPERTY( @@ -95,17 +96,18 @@ public: Q_PROPERTY(bool fullLogsEnabled READ getFullLogsEnabled WRITE setFullLogsEnabled NOTIFY fullLogsEnabledChanged) Q_PROPERTY(bool crashReporterEnabled READ getCrashReporterEnabled WRITE setCrashReporterEnabled NOTIFY crashReporterEnabledChanged) - Q_PROPERTY(QString logsEmail READ getLogsEmail) Q_PROPERTY(QString logsFolder READ getLogsFolder) - Q_PROPERTY(QString ringtoneName READ getRingtoneFileName NOTIFY ringtoneChanged) - Q_PROPERTY(QString ringtonePath READ getRingtonePath WRITE setRingtone NOTIFY ringtoneChanged) - Q_PROPERTY(QString ringtoneFolder MEMBER mRingtoneFolder NOTIFY ringtoneChanged) - Q_PROPERTY(bool dnd READ dndEnabled WRITE lEnableDnd NOTIFY dndChanged) - Q_PROPERTY(bool isSaved READ isSaved WRITE setIsSaved NOTIFY isSavedChanged) + Q_PROPERTY(QString logsEmail READ getLogsEmail) + Q_PROPERTY(QString logsFolder READ getLogsFolder) + Q_PROPERTY(QString ringtoneName READ getRingtoneFileName NOTIFY ringtoneChanged) + Q_PROPERTY(QString ringtonePath READ getRingtonePath WRITE setRingtone NOTIFY ringtoneChanged) + Q_PROPERTY(QString ringtoneFolder MEMBER mRingtoneFolder NOTIFY ringtoneChanged) + Q_PROPERTY(bool dnd READ dndEnabled WRITE lEnableDnd NOTIFY dndChanged) + Q_PROPERTY(bool isSaved READ isSaved WRITE setIsSaved NOTIFY isSavedChanged) - Q_PROPERTY(bool showAccountDevices READ showAccountDevices WRITE setShowAccountDevices - NOTIFY showAccountDevicesChanged) + Q_PROPERTY( + bool showAccountDevices READ showAccountDevices WRITE setShowAccountDevices NOTIFY showAccountDevicesChanged) - static QSharedPointer create(); + static QSharedPointer create(); SettingsCore(QObject *parent = Q_NULLPTR); SettingsCore(const SettingsCore &settingsCore); virtual ~SettingsCore(); @@ -153,6 +155,9 @@ public: } void setAutoDownloadReceivedFiles(bool enabled); + QString getDownloadFolder() const; + void setDownloadFolder(QString folder); + bool getDisplayNotificationContent() { return mDisplayNotificationContent; } @@ -292,7 +297,6 @@ public: DECLARE_CORE_GETSET(bool, exitOnClose, ExitOnClose) DECLARE_CORE_GETSET(bool, syncLdapContacts, SyncLdapContacts) DECLARE_CORE_GETSET(QString, configLocale, ConfigLocale) - DECLARE_CORE_GETSET(QString, downloadFolder, DownloadFolder) // Read-only DECLARE_CORE_MEMBER(int, shortcutCount, ShortcutCount) DECLARE_CORE_MEMBER(QVariantList, shortcuts, Shortcuts) @@ -315,6 +319,7 @@ signals: void echoCancellationEnabledChanged(); void autoDownloadReceivedFilesChanged(); + void downloadFolderChanged(); void displayNotificationContentChanged(); void automaticallyRecordCallsEnabledChanged(); @@ -413,6 +418,7 @@ private: bool mVideoEnabled; bool mEchoCancellationEnabled; bool mAutoDownloadReceivedFiles; + QString mDownloadFolder; bool mDisplayNotificationContent; bool mAutomaticallyRecordCallsEnabled; diff --git a/Linphone/data/languages/de.ts b/Linphone/data/languages/de.ts index d779ee270..86be81e01 100644 --- a/Linphone/data/languages/de.ts +++ b/Linphone/data/languages/de.ts @@ -2685,37 +2685,49 @@ Error ChatSettingsLayout - + settings_chat_attached_files_title Attached files - + settings_chat_notifications_title Notifications - + settings_chat_attached_files_auto_download_title "Automatic download" - + settings_chat_attached_files_auto_download_subtitle "Automatically download transferred or received files in conversations" - + + settings_chat_download_folder_title + "Dossier de téléchargement des fichiers" + + + + + settings_chat_download_folder_browse_button + Browse folders + + + + settings_chat_display_notification_content_title "Display notification content" - + settings_chat_display_notification_content_subtitle "Display the content of the received message" @@ -3731,13 +3743,13 @@ Error DecoratedTextField - + textfield_error_message_cannot_be_empty "ne peut être vide" darf nicht leer sein - + textfield_error_message_unknown_format "Format non reconnu" Unbekanntes Format @@ -6107,13 +6119,25 @@ Pour les activer dans un projet commercial, merci de nous contacter. TextField - + show_accessible_name Show %1 - + + textfield_custom_button_accessible_name + %1 button on %2 + + + + + + %1 button on %2 + von %1 zu %2 (UTC%3) + + + hide_accessible_name Hide %1 diff --git a/Linphone/data/languages/en.ts b/Linphone/data/languages/en.ts index ea9cf54d9..db50ecaf2 100644 --- a/Linphone/data/languages/en.ts +++ b/Linphone/data/languages/en.ts @@ -2670,37 +2670,49 @@ Only your correspondent can decrypt them. ChatSettingsLayout - + settings_chat_attached_files_title Attached files Attached files - + settings_chat_notifications_title Notifications - + settings_chat_attached_files_auto_download_title "Automatic download" Automatic download - + settings_chat_attached_files_auto_download_subtitle "Automatically download transferred or received files in conversations" Automatically download transferred or received files in conversations - + + settings_chat_download_folder_title + "Dossier de téléchargement des fichiers" + Files download folder + + + + settings_chat_download_folder_browse_button + Browse folders + Browse folders + + + settings_chat_display_notification_content_title "Display notification content" - + settings_chat_display_notification_content_subtitle "Display the content of the received message" @@ -3666,13 +3678,13 @@ Only your correspondent can decrypt them. DecoratedTextField - + textfield_error_message_cannot_be_empty "ne peut être vide" can not be empty - + textfield_error_message_unknown_format "Format non reconnu" Unknown format @@ -6006,13 +6018,25 @@ To enable them in a commercial project, please contact us. TextField - + show_accessible_name Show %1 Show %1 - + + textfield_custom_button_accessible_name + %1 button on %2 + %1 button on %2 + + + + + %1 button on %2 + from %1 to %2 (UTC%3) + + + hide_accessible_name Hide %1 Hide %1 diff --git a/Linphone/view/Control/Input/DecoratedTextField.qml b/Linphone/view/Control/Input/DecoratedTextField.qml index 636dd993e..ddb2945dd 100644 --- a/Linphone/view/Control/Input/DecoratedTextField.qml +++ b/Linphone/view/Control/Input/DecoratedTextField.qml @@ -15,7 +15,7 @@ FormItemLayout { property var propertyOwner: new Array property var propertyOwnerGui property var title - property var placeHolder + property var placeHolder: "" property bool useTitleAsPlaceHolder: true property bool canBeEmpty: true property bool toValidate: false @@ -30,6 +30,10 @@ FormItemLayout { property alias hidden: textField.hidden property alias validator: textField.validator + property alias customButtonIcon: textField.customButtonIcon + property alias customCallback: textField.customCallback + property alias customButtonAccessibleName: textField.customButtonAccessibleName + property var isValid: function(text) { return true } diff --git a/Linphone/view/Control/Input/TextField.qml b/Linphone/view/Control/Input/TextField.qml index d74079d83..334aa0be0 100644 --- a/Linphone/view/Control/Input/TextField.qml +++ b/Linphone/view/Control/Input/TextField.qml @@ -57,6 +57,11 @@ Control.TextField { property real pixelSize: Typography.p1.pixelSize property real weight: Typography.p1.weight + // Custom button on the right + property string customButtonIcon + property var customCallback + property string customButtonAccessibleName + // fill propertyName and propertyOwner to check text validity property string propertyName property var propertyOwner @@ -208,4 +213,22 @@ Control.TextField { qsTr("show_accessible_name") ).arg(mainItem.Accessible.name) } + Button { + id: customButton + KeyNavigation.left: mainItem + z: 1 + visible: mainItem.customButtonIcon !== undefined && mainItem.customButtonIcon !== "" + style: ButtonStyle.noBackground + icon.source: mainItem.customButtonIcon + width: visible ? Utils.getSizeWithScreenRatio(20) : 0 + height: Utils.getSizeWithScreenRatio(20) + icon.width: width + icon.height: height + anchors.verticalCenter: parent.verticalCenter + anchors.right: parent.right + anchors.rightMargin: Utils.getSizeWithScreenRatio(15) + onClicked: mainItem.customCallback() + //: %1 button on %2 + Accessible.name: qsTr("textfield_custom_button_accessible_name").arg(mainItem.customButtonAccessibleName).arg(mainItem.Accessible.name) + } } diff --git a/Linphone/view/Page/Layout/Settings/ChatSettingsLayout.qml b/Linphone/view/Page/Layout/Settings/ChatSettingsLayout.qml index 7c841f31f..46884fc1b 100644 --- a/Linphone/view/Page/Layout/Settings/ChatSettingsLayout.qml +++ b/Linphone/view/Page/Layout/Settings/ChatSettingsLayout.qml @@ -1,9 +1,11 @@ import QtQuick import QtQuick.Layouts +import QtQuick.Dialogs import QtQuick.Controls.Basic as Control import SettingsCpp import Linphone +import "qrc:/qt/qml/Linphone/view/Control/Tool/Helper/utils.js" as Utils AbstractSettingsLayout { id: mainItem @@ -25,22 +27,50 @@ AbstractSettingsLayout { } ] + onSave: SettingsCpp.save() + onUndo: SettingsCpp.undo() + + FolderDialog { + id: folderDialog + currentFolder: SettingsCpp.downloadFolder + options: FolderDialog.DontResolveSymlinks + onAccepted: { + SettingsCpp.downloadFolder = Utils.getSystemPathFromUri(selectedFolder) + } + } + Component { id: attachedFilesParamComp - SwitchSetting { - //: "Automatic download" - titleText: qsTr("settings_chat_attached_files_auto_download_title") - //: "Automatically download transferred or received files in conversations" - subTitleText: qsTr("settings_chat_attached_files_auto_download_subtitle") - propertyName: "autoDownloadReceivedFiles" - propertyOwner: SettingsCpp - - Connections { - target: mainItem - function onSave() { - SettingsCpp.save() - } + ColumnLayout { + spacing: Utils.getSizeWithScreenRatio(20) + SwitchSetting { + //: "Automatic download" + titleText: qsTr("settings_chat_attached_files_auto_download_title") + //: "Automatically download transferred or received files in conversations" + subTitleText: qsTr("settings_chat_attached_files_auto_download_subtitle") + propertyName: "autoDownloadReceivedFiles" + propertyOwner: SettingsCpp } + DecoratedTextField { + id: downloadFolderTextField + //: "Dossier de téléchargement des fichiers" + title: qsTr("settings_chat_download_folder_title") + propertyName: "downloadFolder" + propertyOwner: SettingsCpp + customButtonIcon: AppIcons.arrowSquareOut + customCallback: function() {folderDialog.open()} + toValidate: true + //: Browse folders + customButtonAccessibleName: qsTr("settings_chat_download_folder_browse_button") + Connections { + target: SettingsCpp + function onDownloadFolderChanged() { + if (downloadFolderTextField.text != downloadFolderTextField.propertyOwner[downloadFolderTextField.propertyName]) + downloadFolderTextField.text = downloadFolderTextField.propertyOwner[downloadFolderTextField.propertyName] + } + } + } + } } Component { @@ -52,13 +82,6 @@ AbstractSettingsLayout { subTitleText: qsTr("settings_chat_display_notification_content_subtitle") propertyName: "displayNotificationContent" propertyOwner: SettingsCpp - - Connections { - target: mainItem - function onSave() { - SettingsCpp.save() - } - } } } } \ No newline at end of file