From 1e5af8228ecb6ac9ff98f2a7f753ed97eff3dc58 Mon Sep 17 00:00:00 2001 From: gaelle Date: Tue, 25 Mar 2025 16:16:06 +0100 Subject: [PATCH] fix #LINQT-1700 hide account devices if domain does not match default domain --- Linphone/core/setting/SettingsCore.cpp | 30 +++++++++++++++++++ Linphone/core/setting/SettingsCore.hpp | 11 +++++++ Linphone/model/setting/SettingsModel.cpp | 5 ++++ Linphone/model/setting/SettingsModel.hpp | 3 ++ .../Settings/AbstractSettingsLayout.qml | 2 ++ .../Settings/AccountSettingsGeneralLayout.qml | 3 +- 6 files changed, 53 insertions(+), 1 deletion(-) diff --git a/Linphone/core/setting/SettingsCore.cpp b/Linphone/core/setting/SettingsCore.cpp index 480f363a0..77a857d53 100644 --- a/Linphone/core/setting/SettingsCore.cpp +++ b/Linphone/core/setting/SettingsCore.cpp @@ -85,6 +85,13 @@ SettingsCore::SettingsCore(QObject *parent) : QObject(parent) { // DND mDndEnabled = settingsModel->dndEnabled(); + mDefaultDomain = settingsModel->getDefaultDomain(); + auto currentAccount = CoreModel::getInstance()->getCore()->getDefaultAccount(); + if (currentAccount) { + auto accountDomain = Utils::coreStringToAppString(currentAccount->getParams()->getDomain()); + mShowAccountDevices = (accountDomain == mDefaultDomain); + } + // Ui INIT_CORE_MEMBER(DisableChatFeature, settingsModel) INIT_CORE_MEMBER(DisableMeetingsFeature, settingsModel) @@ -185,6 +192,9 @@ SettingsCore::SettingsCore(const SettingsCore &settingsCore) { mShortcutCount = settingsCore.mShortcutCount; mShortcuts = settingsCore.mShortcuts; mCallToneIndicationsEnabled = settingsCore.mCallToneIndicationsEnabled; + + mDefaultDomain = settingsCore.mDefaultDomain; + mShowAccountDevices = settingsCore.mShowAccountDevices; } SettingsCore::~SettingsCore() { @@ -403,6 +413,16 @@ void SettingsCore::setSelf(QSharedPointer me) { } }); }); + coreModelConnection->makeConnectToModel(&CoreModel::defaultAccountChanged, [this] (const std::shared_ptr &core, + const std::shared_ptr &account) { + QString accountDomain; + if (account) { + accountDomain = Utils::coreStringToAppString(account->getParams()->getDomain()); + } + mSettingsModelConnection->invokeToCore([this, accountDomain]() { + setShowAccountDevices(accountDomain == mDefaultDomain); + }); + }); } void SettingsCore::reset(const SettingsCore &settingsCore) { @@ -837,6 +857,16 @@ void SettingsCore::setDndEnabled(bool enabled) { } } +bool SettingsCore::showAccountDevices() const { + return mShowAccountDevices; +} +void SettingsCore::setShowAccountDevices(bool show) { + if (mShowAccountDevices != show) { + mShowAccountDevices = show; + emit showAccountDevicesChanged(mShowAccountDevices); + } +} + bool SettingsCore::getAutoStart() const { return mAutoStart; } diff --git a/Linphone/core/setting/SettingsCore.hpp b/Linphone/core/setting/SettingsCore.hpp index d7080f093..9815c37b1 100644 --- a/Linphone/core/setting/SettingsCore.hpp +++ b/Linphone/core/setting/SettingsCore.hpp @@ -80,6 +80,8 @@ public: 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) + static QSharedPointer create(); SettingsCore(QObject *parent = Q_NULLPTR); SettingsCore(const SettingsCore &settingsCore); @@ -187,6 +189,9 @@ public: bool dndEnabled() const; void setDndEnabled(bool enabled); + bool showAccountDevices() const; + void setShowAccountDevices(bool show); + Q_INVOKABLE void save(); Q_INVOKABLE void undo(); @@ -285,6 +290,8 @@ signals: void lEnableDnd(bool value); + void showAccountDevicesChanged(bool show); + protected: void writeIntoModel(std::shared_ptr model) const; void writeFromModel(const std::shared_ptr &model); @@ -338,6 +345,10 @@ private: QSettings mAppSettings; QSharedPointer> mSettingsModelConnection; + //Account + QString mDefaultDomain; + bool mShowAccountDevices = false; + DECLARE_ABSTRACT_OBJECT }; #endif diff --git a/Linphone/model/setting/SettingsModel.cpp b/Linphone/model/setting/SettingsModel.cpp index 483eea38f..a53062a0d 100644 --- a/Linphone/model/setting/SettingsModel.cpp +++ b/Linphone/model/setting/SettingsModel.cpp @@ -31,6 +31,7 @@ DEFINE_ABSTRACT_OBJECT(SettingsModel) using namespace std; const std::string SettingsModel::UiSection("ui"); +const std::string SettingsModel::AppSection("app"); std::shared_ptr SettingsModel::gSettingsModel; SettingsModel::SettingsModel() { @@ -688,6 +689,10 @@ void SettingsModel::setShortcuts(QVariantList data) { } } +QString SettingsModel::getDefaultDomain() const { + return Utils::coreStringToAppString(mConfig->getString(SettingsModel::AppSection, "default_domain", "sip.linphone.org")); +} + // clang-format off void SettingsModel::notifyConfigReady(){ DEFINE_NOTIFY_CONFIG_READY(disableChatFeature, DisableChatFeature) diff --git a/Linphone/model/setting/SettingsModel.hpp b/Linphone/model/setting/SettingsModel.hpp index c3d320ae9..6e1116215 100644 --- a/Linphone/model/setting/SettingsModel.hpp +++ b/Linphone/model/setting/SettingsModel.hpp @@ -45,6 +45,7 @@ public: const std::string &name) const; // Return the full name of the entry : 'name/readonly' or 'name' static const std::string UiSection; + static const std::string AppSection; std::shared_ptr mConfig; bool getVfsEnabled() const; @@ -108,6 +109,8 @@ public: QString getVideoDevice() const; void setVideoDevice(QString device); + QString getDefaultDomain() const; + //------------------------------------------------------------------------------------------------------------ void startEchoCancellerCalibration(); diff --git a/Linphone/view/Page/Layout/Settings/AbstractSettingsLayout.qml b/Linphone/view/Page/Layout/Settings/AbstractSettingsLayout.qml index f0db99974..19c7bf0de 100644 --- a/Linphone/view/Page/Layout/Settings/AbstractSettingsLayout.qml +++ b/Linphone/view/Page/Layout/Settings/AbstractSettingsLayout.qml @@ -131,8 +131,10 @@ Rectangle { height: contentHeight spacing: Math.round(10 * DefaultStyle.dp) delegate: ColumnLayout { + visible: modelData.visible spacing: Math.round(16 * DefaultStyle.dp) width: contentListView.width + height: visible ? childrenRect.height: 0 Rectangle { visible: index !== 0 Layout.topMargin: Math.round((modelData.hideTopSeparator ? 0 : 16) * DefaultStyle.dp) diff --git a/Linphone/view/Page/Layout/Settings/AccountSettingsGeneralLayout.qml b/Linphone/view/Page/Layout/Settings/AccountSettingsGeneralLayout.qml index fda798321..0ef14bdfc 100644 --- a/Linphone/view/Page/Layout/Settings/AccountSettingsGeneralLayout.qml +++ b/Linphone/view/Page/Layout/Settings/AccountSettingsGeneralLayout.qml @@ -4,7 +4,7 @@ import QtQuick.Layouts import QtQuick.Controls.Basic as Control import QtQuick.Dialogs import Linphone -import SettingsCpp 1.0 +import SettingsCpp import UtilsCpp import 'qrc:/qt/qml/Linphone/view/Style/buttonStyle.js' as ButtonStyle @@ -22,6 +22,7 @@ AbstractSettingsLayout { contentComponent: accountParametersComponent }, { + visible: SettingsCpp.showAccountDevices, //: "Vos appareils" title: qsTr("manage_account_devices_title"), //: "La liste des appareils connectés à votre compte. Vous pouvez retirer les appareils que vous n’utilisez plus."