fix #LINQT-1700 hide account devices if domain does not match default domain

This commit is contained in:
gaelle 2025-03-25 16:16:06 +01:00
parent 37fd7f586e
commit 1e5af8228e
6 changed files with 53 additions and 1 deletions

View file

@ -85,6 +85,13 @@ SettingsCore::SettingsCore(QObject *parent) : QObject(parent) {
// DND // DND
mDndEnabled = settingsModel->dndEnabled(); 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 // Ui
INIT_CORE_MEMBER(DisableChatFeature, settingsModel) INIT_CORE_MEMBER(DisableChatFeature, settingsModel)
INIT_CORE_MEMBER(DisableMeetingsFeature, settingsModel) INIT_CORE_MEMBER(DisableMeetingsFeature, settingsModel)
@ -185,6 +192,9 @@ SettingsCore::SettingsCore(const SettingsCore &settingsCore) {
mShortcutCount = settingsCore.mShortcutCount; mShortcutCount = settingsCore.mShortcutCount;
mShortcuts = settingsCore.mShortcuts; mShortcuts = settingsCore.mShortcuts;
mCallToneIndicationsEnabled = settingsCore.mCallToneIndicationsEnabled; mCallToneIndicationsEnabled = settingsCore.mCallToneIndicationsEnabled;
mDefaultDomain = settingsCore.mDefaultDomain;
mShowAccountDevices = settingsCore.mShowAccountDevices;
} }
SettingsCore::~SettingsCore() { SettingsCore::~SettingsCore() {
@ -403,6 +413,16 @@ void SettingsCore::setSelf(QSharedPointer<SettingsCore> me) {
} }
}); });
}); });
coreModelConnection->makeConnectToModel(&CoreModel::defaultAccountChanged, [this] (const std::shared_ptr<linphone::Core> &core,
const std::shared_ptr<linphone::Account> &account) {
QString accountDomain;
if (account) {
accountDomain = Utils::coreStringToAppString(account->getParams()->getDomain());
}
mSettingsModelConnection->invokeToCore([this, accountDomain]() {
setShowAccountDevices(accountDomain == mDefaultDomain);
});
});
} }
void SettingsCore::reset(const SettingsCore &settingsCore) { 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 { bool SettingsCore::getAutoStart() const {
return mAutoStart; return mAutoStart;
} }

View file

@ -80,6 +80,8 @@ public:
Q_PROPERTY(bool dnd READ dndEnabled WRITE lEnableDnd NOTIFY dndChanged) Q_PROPERTY(bool dnd READ dndEnabled WRITE lEnableDnd NOTIFY dndChanged)
Q_PROPERTY(bool isSaved READ isSaved WRITE setIsSaved NOTIFY isSavedChanged) Q_PROPERTY(bool isSaved READ isSaved WRITE setIsSaved NOTIFY isSavedChanged)
Q_PROPERTY(bool showAccountDevices READ showAccountDevices WRITE setShowAccountDevices NOTIFY showAccountDevicesChanged)
static QSharedPointer<SettingsCore> create(); static QSharedPointer<SettingsCore> create();
SettingsCore(QObject *parent = Q_NULLPTR); SettingsCore(QObject *parent = Q_NULLPTR);
SettingsCore(const SettingsCore &settingsCore); SettingsCore(const SettingsCore &settingsCore);
@ -187,6 +189,9 @@ public:
bool dndEnabled() const; bool dndEnabled() const;
void setDndEnabled(bool enabled); void setDndEnabled(bool enabled);
bool showAccountDevices() const;
void setShowAccountDevices(bool show);
Q_INVOKABLE void save(); Q_INVOKABLE void save();
Q_INVOKABLE void undo(); Q_INVOKABLE void undo();
@ -285,6 +290,8 @@ signals:
void lEnableDnd(bool value); void lEnableDnd(bool value);
void showAccountDevicesChanged(bool show);
protected: protected:
void writeIntoModel(std::shared_ptr<SettingsModel> model) const; void writeIntoModel(std::shared_ptr<SettingsModel> model) const;
void writeFromModel(const std::shared_ptr<SettingsModel> &model); void writeFromModel(const std::shared_ptr<SettingsModel> &model);
@ -338,6 +345,10 @@ private:
QSettings mAppSettings; QSettings mAppSettings;
QSharedPointer<SafeConnection<SettingsCore, SettingsModel>> mSettingsModelConnection; QSharedPointer<SafeConnection<SettingsCore, SettingsModel>> mSettingsModelConnection;
//Account
QString mDefaultDomain;
bool mShowAccountDevices = false;
DECLARE_ABSTRACT_OBJECT DECLARE_ABSTRACT_OBJECT
}; };
#endif #endif

View file

@ -31,6 +31,7 @@ DEFINE_ABSTRACT_OBJECT(SettingsModel)
using namespace std; using namespace std;
const std::string SettingsModel::UiSection("ui"); const std::string SettingsModel::UiSection("ui");
const std::string SettingsModel::AppSection("app");
std::shared_ptr<SettingsModel> SettingsModel::gSettingsModel; std::shared_ptr<SettingsModel> SettingsModel::gSettingsModel;
SettingsModel::SettingsModel() { 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 // clang-format off
void SettingsModel::notifyConfigReady(){ void SettingsModel::notifyConfigReady(){
DEFINE_NOTIFY_CONFIG_READY(disableChatFeature, DisableChatFeature) DEFINE_NOTIFY_CONFIG_READY(disableChatFeature, DisableChatFeature)

View file

@ -45,6 +45,7 @@ public:
const std::string &name) const; // Return the full name of the entry : 'name/readonly' or 'name' 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 UiSection;
static const std::string AppSection;
std::shared_ptr<linphone::Config> mConfig; std::shared_ptr<linphone::Config> mConfig;
bool getVfsEnabled() const; bool getVfsEnabled() const;
@ -108,6 +109,8 @@ public:
QString getVideoDevice() const; QString getVideoDevice() const;
void setVideoDevice(QString device); void setVideoDevice(QString device);
QString getDefaultDomain() const;
//------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------
void startEchoCancellerCalibration(); void startEchoCancellerCalibration();

View file

@ -131,8 +131,10 @@ Rectangle {
height: contentHeight height: contentHeight
spacing: Math.round(10 * DefaultStyle.dp) spacing: Math.round(10 * DefaultStyle.dp)
delegate: ColumnLayout { delegate: ColumnLayout {
visible: modelData.visible
spacing: Math.round(16 * DefaultStyle.dp) spacing: Math.round(16 * DefaultStyle.dp)
width: contentListView.width width: contentListView.width
height: visible ? childrenRect.height: 0
Rectangle { Rectangle {
visible: index !== 0 visible: index !== 0
Layout.topMargin: Math.round((modelData.hideTopSeparator ? 0 : 16) * DefaultStyle.dp) Layout.topMargin: Math.round((modelData.hideTopSeparator ? 0 : 16) * DefaultStyle.dp)

View file

@ -4,7 +4,7 @@ import QtQuick.Layouts
import QtQuick.Controls.Basic as Control import QtQuick.Controls.Basic as Control
import QtQuick.Dialogs import QtQuick.Dialogs
import Linphone import Linphone
import SettingsCpp 1.0 import SettingsCpp
import UtilsCpp import UtilsCpp
import 'qrc:/qt/qml/Linphone/view/Style/buttonStyle.js' as ButtonStyle import 'qrc:/qt/qml/Linphone/view/Style/buttonStyle.js' as ButtonStyle
@ -22,6 +22,7 @@ AbstractSettingsLayout {
contentComponent: accountParametersComponent contentComponent: accountParametersComponent
}, },
{ {
visible: SettingsCpp.showAccountDevices,
//: "Vos appareils" //: "Vos appareils"
title: qsTr("manage_account_devices_title"), title: qsTr("manage_account_devices_title"),
//: "La liste des appareils connectés à votre compte. Vous pouvez retirer les appareils que vous nutilisez plus." //: "La liste des appareils connectés à votre compte. Vous pouvez retirer les appareils que vous nutilisez plus."