From 331e621c8e354d2489381ba7bc2ac8131152151f Mon Sep 17 00:00:00 2001 From: Julien Wadel Date: Thu, 21 Oct 2021 13:10:59 +0200 Subject: [PATCH] - Remove 'app' section and keep 'ui' - Allow to make a variable in readonly (only for enabling chats yet) - Rename chatEnabled to standardChatEnabled --- .../src/components/call/CallModel.cpp | 2 +- .../src/components/core/CoreHandlers.cpp | 2 +- .../AbstractEventCountNotifier.cpp | 4 +-- .../src/components/settings/SettingsModel.cpp | 32 ++++++++++++------- .../src/components/settings/SettingsModel.hpp | 12 ++++--- .../components/timeline/TimelineListModel.cpp | 2 +- .../ui/modules/Linphone/Chat/Chat.qml | 4 +-- .../SmartSearchBar/SmartSearchBar.qml | 2 +- .../ui/modules/Linphone/Timeline/Timeline.qml | 2 +- .../ui/views/App/Calls/CallsWindow.qml | 4 +-- linphone-app/ui/views/App/Calls/Incall.qml | 2 +- .../ui/views/App/Main/ContactEdit.qml | 2 +- linphone-app/ui/views/App/Main/Contacts.qml | 2 +- .../ui/views/App/Main/Conversation.qml | 6 ++-- .../ui/views/App/Main/Dialogs/NewChatRoom.qml | 4 +-- linphone-app/ui/views/App/Main/MainWindow.qml | 2 +- .../views/App/Settings/SettingsCallsChat.qml | 6 ++-- .../ui/views/App/Settings/SettingsUi.qml | 4 +-- 18 files changed, 53 insertions(+), 41 deletions(-) diff --git a/linphone-app/src/components/call/CallModel.cpp b/linphone-app/src/components/call/CallModel.cpp index 6357096ad..c75d592c2 100644 --- a/linphone-app/src/components/call/CallModel.cpp +++ b/linphone-app/src/components/call/CallModel.cpp @@ -122,7 +122,7 @@ ChatRoomModel * CallModel::getChatRoomModel() const{ SettingsModel * settingsModel = CoreManager::getInstance()->getSettingsModel(); if( mCall->getChatRoom() && (settingsModel->getSecureChatEnabled() && - (!settingsModel->getChatEnabled() || (settingsModel->getChatEnabled() && isEncrypted)) + (!settingsModel->getStandardChatEnabled() || (settingsModel->getStandardChatEnabled() && isEncrypted)) )){ std::shared_ptr core = CoreManager::getInstance()->getCore(); std::shared_ptr dbParams = mCall->getChatRoom()->getCurrentParams(); diff --git a/linphone-app/src/components/core/CoreHandlers.cpp b/linphone-app/src/components/core/CoreHandlers.cpp index b2c2eda6f..b419ae38f 100644 --- a/linphone-app/src/components/core/CoreHandlers.cpp +++ b/linphone-app/src/components/core/CoreHandlers.cpp @@ -197,7 +197,7 @@ void CoreHandlers::onMessageReceived ( // 1. Do not notify if chat is not activated. CoreManager *coreManager = CoreManager::getInstance(); SettingsModel *settingsModel = coreManager->getSettingsModel(); - if (chatRoom->getCurrentParams()->getEncryptionBackend() == linphone::ChatRoomEncryptionBackend::None && !settingsModel->getChatEnabled() + if (chatRoom->getCurrentParams()->getEncryptionBackend() == linphone::ChatRoomEncryptionBackend::None && !settingsModel->getStandardChatEnabled() || chatRoom->getCurrentParams()->getEncryptionBackend() != linphone::ChatRoomEncryptionBackend::None && !settingsModel->getSecureChatEnabled()) return; diff --git a/linphone-app/src/components/core/event-count-notifier/AbstractEventCountNotifier.cpp b/linphone-app/src/components/core/event-count-notifier/AbstractEventCountNotifier.cpp index d1617bf86..fd2531aa1 100644 --- a/linphone-app/src/components/core/event-count-notifier/AbstractEventCountNotifier.cpp +++ b/linphone-app/src/components/core/event-count-notifier/AbstractEventCountNotifier.cpp @@ -50,7 +50,7 @@ AbstractEventCountNotifier::AbstractEventCountNotifier (QObject *parent) : QObje this, &AbstractEventCountNotifier::updateUnreadMessageCount ); QObject::connect( - coreManager->getSettingsModel(), &SettingsModel::chatEnabledChanged, + coreManager->getSettingsModel(), &SettingsModel::standardChatEnabledChanged, this, &AbstractEventCountNotifier::internalnotifyEventCount ); QObject::connect( @@ -76,7 +76,7 @@ void AbstractEventCountNotifier::internalnotifyEventCount () { qInfo() << QStringLiteral("Notify event count: %1.").arg(n); n = n > 99 ? 99 : n; - notifyEventCount(CoreManager::getInstance()->getSettingsModel()->getChatEnabled() || CoreManager::getInstance()->getSettingsModel()->getSecureChatEnabled()? n : 0); + notifyEventCount(CoreManager::getInstance()->getSettingsModel()->getStandardChatEnabled() || CoreManager::getInstance()->getSettingsModel()->getSecureChatEnabled()? n : 0); emit eventCountChanged(); } diff --git a/linphone-app/src/components/settings/SettingsModel.cpp b/linphone-app/src/components/settings/SettingsModel.cpp index 539cc261c..e0c039722 100644 --- a/linphone-app/src/components/settings/SettingsModel.cpp +++ b/linphone-app/src/components/settings/SettingsModel.cpp @@ -41,7 +41,6 @@ using namespace std; const string SettingsModel::UiSection("ui"); -const string SettingsModel::AppSection("app"); const string SettingsModel::ContactsSection("contacts_import"); SettingsModel::SettingsModel (QObject *parent) : QObject(parent) { @@ -601,22 +600,24 @@ void SettingsModel::setMuteMicrophoneEnabled (bool status) { // ----------------------------------------------------------------------------- -bool SettingsModel::getChatEnabled () const { - return !!mConfig->getInt(AppSection, "chat_enabled", 1); +bool SettingsModel::getStandardChatEnabled () const { + return !!mConfig->getInt(UiSection, getEntryFullName(UiSection,"standard_chat_enabled"), 1); } -void SettingsModel::setChatEnabled (bool status) { - mConfig->setInt(AppSection, "chat_enabled", status); - emit chatEnabledChanged(status); +void SettingsModel::setStandardChatEnabled (bool status) { + if(!isReadOnly(UiSection, "standard_chat_enabled")) + mConfig->setInt(UiSection, "standard_chat_enabled", status); + emit standardChatEnabledChanged(getStandardChatEnabled ()); } bool SettingsModel::getSecureChatEnabled () const { - return !!mConfig->getInt(AppSection, "secure_chat_enabled", 1); + return !!mConfig->getInt(UiSection, getEntryFullName(UiSection, "secure_chat_enabled"), 1); } void SettingsModel::setSecureChatEnabled (bool status) { - mConfig->setInt(AppSection, "secure_chat_enabled", status); - emit secureChatEnabledChanged(status); + if(!isReadOnly(UiSection, "secure_chat_enabled")) + mConfig->setInt(UiSection, "secure_chat_enabled", status); + emit secureChatEnabledChanged(getSecureChatEnabled () ); } // ----------------------------------------------------------------------------- @@ -790,8 +791,9 @@ bool SettingsModel::getContactsEnabled () const { } void SettingsModel::setContactsEnabled (bool status) { - mConfig->setInt(UiSection, "contacts_enabled", status); - emit contactsEnabledChanged(status); + if(!isReadOnly(UiSection, "contacts_enabled")) + mConfig->setInt(UiSection, "contacts_enabled", status); + emit contactsEnabledChanged(getContactsEnabled ()); } // ============================================================================= @@ -1372,3 +1374,11 @@ void SettingsModel::handleEcCalibrationResult(linphone::EcCalibratorStatus statu bool SettingsModel::getIsInCall() const { return CoreManager::getInstance()->getCore()->getCallsNb() != 0; } + +bool SettingsModel::isReadOnly(const std::string& section, const std::string& name) const { + return mConfig->hasEntry(section, name+"/readonly"); +} + +std::string SettingsModel::getEntryFullName(const std::string& section, const std::string& name) const { + return isReadOnly(section, name)?name+"/readonly" : name; +} \ No newline at end of file diff --git a/linphone-app/src/components/settings/SettingsModel.hpp b/linphone-app/src/components/settings/SettingsModel.hpp index f9bb5de42..0d1ccbce3 100644 --- a/linphone-app/src/components/settings/SettingsModel.hpp +++ b/linphone-app/src/components/settings/SettingsModel.hpp @@ -103,7 +103,7 @@ class SettingsModel : public QObject { Q_PROPERTY(bool callPauseEnabled READ getCallPauseEnabled WRITE setCallPauseEnabled NOTIFY callPauseEnabledChanged) Q_PROPERTY(bool muteMicrophoneEnabled READ getMuteMicrophoneEnabled WRITE setMuteMicrophoneEnabled NOTIFY muteMicrophoneEnabledChanged) - Q_PROPERTY(bool chatEnabled READ getChatEnabled WRITE setChatEnabled NOTIFY chatEnabledChanged) + Q_PROPERTY(bool standardChatEnabled READ getStandardChatEnabled WRITE setStandardChatEnabled NOTIFY standardChatEnabledChanged) Q_PROPERTY(bool secureChatEnabled READ getSecureChatEnabled WRITE setSecureChatEnabled NOTIFY secureChatEnabledChanged) Q_PROPERTY(bool hideEmptyChatRooms READ getHideEmptyChatRooms WRITE setHideEmptyChatRooms NOTIFY hideEmptyChatRoomsChanged) @@ -326,8 +326,8 @@ public: bool getMuteMicrophoneEnabled () const; void setMuteMicrophoneEnabled (bool status); - bool getChatEnabled () const; - void setChatEnabled (bool status); + bool getStandardChatEnabled () const; + void setStandardChatEnabled (bool status); bool getSecureChatEnabled () const; void setSecureChatEnabled (bool status); @@ -490,8 +490,10 @@ public: bool getIsInCall() const; + bool isReadOnly(const std::string& section, const std::string& name) const; + std::string getEntryFullName(const std::string& section, 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; static const std::string ContactsSection; // =========================================================================== @@ -559,7 +561,7 @@ signals: void callPauseEnabledChanged (bool status); void muteMicrophoneEnabledChanged (bool status); - void chatEnabledChanged (bool status); + void standardChatEnabledChanged (bool status); void secureChatEnabledChanged (bool status); void hideEmptyChatRoomsChanged (bool status); void waitRegistrationForCallChanged (bool status); diff --git a/linphone-app/src/components/timeline/TimelineListModel.cpp b/linphone-app/src/components/timeline/TimelineListModel.cpp index e8e6d140c..272e11b85 100644 --- a/linphone-app/src/components/timeline/TimelineListModel.cpp +++ b/linphone-app/src/components/timeline/TimelineListModel.cpp @@ -360,7 +360,7 @@ void TimelineListModel::onCallCreated(const std::shared_ptr &cal if( settingsModel->getSecureChatEnabled() && - (!settingsModel->getChatEnabled() || (settingsModel->getChatEnabled() && isEncrypted)) + (!settingsModel->getStandardChatEnabled() || (settingsModel->getStandardChatEnabled() && isEncrypted)) ){ params->enableEncryption(true); createSecureChatRoom = true; diff --git a/linphone-app/ui/modules/Linphone/Chat/Chat.qml b/linphone-app/ui/modules/Linphone/Chat/Chat.qml index 726acd42f..2daf13fdf 100644 --- a/linphone-app/ui/modules/Linphone/Chat/Chat.qml +++ b/linphone-app/ui/modules/Linphone/Chat/Chat.qml @@ -277,7 +277,7 @@ Rectangle { font.pointSize: ChatStyle.composingText.pointSize height: visible ? undefined : 0 leftPadding: ChatStyle.composingText.leftPadding - visible: composers.length > 0 && (!proxyModel.chatRoomModel.haveEncryption && SettingsModel.chatEnabled || proxyModel.chatRoomModel.haveEncryption && SettingsModel.secureChatEnabled) + visible: composers.length > 0 && (!proxyModel.chatRoomModel.haveEncryption && SettingsModel.standardChatEnabled || proxyModel.chatRoomModel.haveEncryption && SettingsModel.secureChatEnabled) wrapMode: Text.Wrap //: '%1 is typing...' indicate that someone is composing in chat text:(composers.length==0?'': qsTr('chatTyping','',composers.length).arg(container.proxyModel.getDisplayNameComposers())) @@ -358,7 +358,7 @@ Rectangle { borderColor: ChatStyle.sendArea.border.color topWidth: ChatStyle.sendArea.border.width - visible: proxyModel.chatRoomModel && !proxyModel.chatRoomModel.hasBeenLeft && (!proxyModel.chatRoomModel.haveEncryption && SettingsModel.chatEnabled || proxyModel.chatRoomModel.haveEncryption && SettingsModel.secureChatEnabled) + visible: proxyModel.chatRoomModel && !proxyModel.chatRoomModel.hasBeenLeft && (!proxyModel.chatRoomModel.haveEncryption && SettingsModel.standardChatEnabled || proxyModel.chatRoomModel.haveEncryption && SettingsModel.secureChatEnabled) DroppableTextArea { diff --git a/linphone-app/ui/modules/Linphone/SmartSearchBar/SmartSearchBar.qml b/linphone-app/ui/modules/Linphone/SmartSearchBar/SmartSearchBar.qml index fa2c11fef..960782197 100644 --- a/linphone-app/ui/modules/Linphone/SmartSearchBar/SmartSearchBar.qml +++ b/linphone-app/ui/modules/Linphone/SmartSearchBar/SmartSearchBar.qml @@ -79,7 +79,7 @@ SearchBox { }, { icon: SettingsModel.getShowStartChatButton() ? 'chat' : 'history', secure: 0, - visible: SettingsModel.chatEnabled , + visible: SettingsModel.standardChatEnabled , handler: function (entry) { searchBox.closeMenu() searchBox.launchChat(entry.sipAddress) diff --git a/linphone-app/ui/modules/Linphone/Timeline/Timeline.qml b/linphone-app/ui/modules/Linphone/Timeline/Timeline.qml index a888b19d6..d88c75c13 100644 --- a/linphone-app/ui/modules/Linphone/Timeline/Timeline.qml +++ b/linphone-app/ui/modules/Linphone/Timeline/Timeline.qml @@ -243,7 +243,7 @@ Rectangle { ? TimelineStyle.contact.backgroundColor.a : TimelineStyle.contact.backgroundColor.b ) - displayUnreadMessageCount: SettingsModel.chatEnabled || SettingsModel.secureChatEnabled + displayUnreadMessageCount: SettingsModel.standardChatEnabled || SettingsModel.secureChatEnabled entry: modelData.chatRoomModel sipAddressColor: isSelected ? TimelineStyle.contact.sipAddress.color.selected diff --git a/linphone-app/ui/views/App/Calls/CallsWindow.qml b/linphone-app/ui/views/App/Calls/CallsWindow.qml index e451dcd92..838b3220c 100644 --- a/linphone-app/ui/views/App/Calls/CallsWindow.qml +++ b/linphone-app/ui/views/App/Calls/CallsWindow.qml @@ -203,7 +203,7 @@ Window { proxyModel: ChatRoomProxyModel { Component.onCompleted: { if (chatRoomModel - && (!chatRoomModel.haveEncryption && !SettingsModel.chatEnabled || chatRoomModel.haveEncryption && !SettingsModel.secureChatEnabled)) { + && (!chatRoomModel.haveEncryption && !SettingsModel.standardChatEnabled || chatRoomModel.haveEncryption && !SettingsModel.secureChatEnabled)) { setEntryTypeFilter(ChatRoomModel.CallEntry | ChatRoomModel.NoticeEntry) } } @@ -218,7 +218,7 @@ Window { Connections { target: SettingsModel - onChatEnabledChanged: if(!chatRoomModel.haveEncryption) proxyModel.setEntryTypeFilter(status ? ChatRoomModel.GenericEntry : ChatRoomModel.CallEntry | ChatRoomModel.NoticeEntry) + onStandardChatEnabledChanged: if(!chatRoomModel.haveEncryption) proxyModel.setEntryTypeFilter(status ? ChatRoomModel.GenericEntry : ChatRoomModel.CallEntry | ChatRoomModel.NoticeEntry) onSecureChatEnabledChanged: if(chatRoomModel.haveEncryption) proxyModel.setEntryTypeFilter(status ? ChatRoomModel.GenericEntry : ChatRoomModel.CallEntry | ChatRoomModel.NoticeEntry) } } diff --git a/linphone-app/ui/views/App/Calls/Incall.qml b/linphone-app/ui/views/App/Calls/Incall.qml index 541ee6c4e..71d479aa4 100644 --- a/linphone-app/ui/views/App/Calls/Incall.qml +++ b/linphone-app/ui/views/App/Calls/Incall.qml @@ -421,7 +421,7 @@ Rectangle { } ActionButton { - icon: (SettingsModel.chatEnabled || SettingsModel.secureChatEnabled) && SettingsModel.showStartChatButton ? 'chat' : 'history' + icon: (SettingsModel.standardChatEnabled || SettingsModel.secureChatEnabled) && SettingsModel.showStartChatButton ? 'chat' : 'history' onClicked: { if (window.chatIsOpened) { diff --git a/linphone-app/ui/views/App/Main/ContactEdit.qml b/linphone-app/ui/views/App/Main/ContactEdit.qml index 6ce088d41..eda59b616 100644 --- a/linphone-app/ui/views/App/Main/ContactEdit.qml +++ b/linphone-app/ui/views/App/Main/ContactEdit.qml @@ -154,7 +154,7 @@ ColumnLayout { ActionButton { icon: SettingsModel.getShowStartChatButton() ? 'chat' : 'history' - visible: SettingsModel.chatEnabled + visible: SettingsModel.standardChatEnabled onClicked: sipAddressesMenu.open(false) TooltipArea { isClickable: false diff --git a/linphone-app/ui/views/App/Main/Contacts.qml b/linphone-app/ui/views/App/Main/Contacts.qml index 5d7836090..97c733eb6 100644 --- a/linphone-app/ui/views/App/Main/Contacts.qml +++ b/linphone-app/ui/views/App/Main/Contacts.qml @@ -149,7 +149,7 @@ ColumnLayout { ActionButton { icon: SettingsModel.getShowStartChatButton() ? 'chat' : 'history' - visible: SettingsModel.chatEnabled + visible: SettingsModel.standardChatEnabled onClicked: actions.itemAt(2).open() } diff --git a/linphone-app/ui/views/App/Main/Conversation.qml b/linphone-app/ui/views/App/Main/Conversation.qml index 8c10fd84c..b7bae311a 100644 --- a/linphone-app/ui/views/App/Main/Conversation.qml +++ b/linphone-app/ui/views/App/Main/Conversation.qml @@ -258,7 +258,7 @@ ColumnLayout { } ActionButton { icon: 'chat' - visible: SettingsModel.chatEnabled && SettingsModel.getShowStartChatButton() && !conversation.haveMoreThanOneParticipants && conversation.securityLevel != 1 + visible: SettingsModel.standardChatEnabled && SettingsModel.getShowStartChatButton() && !conversation.haveMoreThanOneParticipants && conversation.securityLevel != 1 onClicked: CallsListModel.launchChat(chatRoomModel.participants.addressesToString, 0) } @@ -415,7 +415,7 @@ ColumnLayout { bottomWidth: ConversationStyle.filters.border.bottomWidth color: ConversationStyle.filters.backgroundColor topWidth: ConversationStyle.filters.border.topWidth - visible: !chatRoomModel.haveEncryption && SettingsModel.chatEnabled || chatRoomModel.haveEncryption && SettingsModel.secureChatEnabled + visible: !chatRoomModel.haveEncryption && SettingsModel.standardChatEnabled || chatRoomModel.haveEncryption && SettingsModel.secureChatEnabled ExclusiveButtons { id: filterButtons @@ -515,7 +515,7 @@ ColumnLayout { id: chatRoomProxyModel Component.onCompleted: { - if ( (!chatRoomModel.haveEncryption && !SettingsModel.chatEnabled) + if ( (!chatRoomModel.haveEncryption && !SettingsModel.standardChatEnabled) || (chatRoomModel.haveEncryption && !SettingsModel.secureChatEnabled) ) { setEntryTypeFilter(ChatRoomModel.CallEntry) } diff --git a/linphone-app/ui/views/App/Main/Dialogs/NewChatRoom.qml b/linphone-app/ui/views/App/Main/Dialogs/NewChatRoom.qml index 21e465ac8..334243d8e 100644 --- a/linphone-app/ui/views/App/Main/Dialogs/NewChatRoom.qml +++ b/linphone-app/ui/views/App/Main/Dialogs/NewChatRoom.qml @@ -119,11 +119,11 @@ DialogPlus { anchors.verticalCenter: parent.verticalCenter width:50 enabled:true - checked: !SettingsModel.chatEnabled && SettingsModel.secureChatEnabled + checked: !SettingsModel.standardChatEnabled && SettingsModel.secureChatEnabled onClicked: { var newCheck = checked - if(! ( SettingsModel.chatEnabled && !checked || SettingsModel.secureChatEnabled && checked)) + if(! ( SettingsModel.standardChatEnabled && !checked || SettingsModel.secureChatEnabled && checked)) newCheck = !checked; if(newCheck){ // Remove all participants that have not the capabilities var participants = selectedParticipants.getParticipants() diff --git a/linphone-app/ui/views/App/Main/MainWindow.qml b/linphone-app/ui/views/App/Main/MainWindow.qml index 638fda64a..3336eace2 100644 --- a/linphone-app/ui/views/App/Main/MainWindow.qml +++ b/linphone-app/ui/views/App/Main/MainWindow.qml @@ -201,7 +201,7 @@ ApplicationWindow { //: 'Open Conference' : Tooltip to illustrate a button tooltipText : qsTr('newChatRoom') iconSize: MainWindowStyle.newConferenceSize - visible: SettingsModel.chatEnabled || SettingsModel.secureChatEnabled + visible: SettingsModel.standardChatEnabled || SettingsModel.secureChatEnabled //autoIcon: true onClicked: { window.detachVirtualWindow() diff --git a/linphone-app/ui/views/App/Settings/SettingsCallsChat.qml b/linphone-app/ui/views/App/Settings/SettingsCallsChat.qml index 123cc3904..a23cf05dd 100644 --- a/linphone-app/ui/views/App/Settings/SettingsCallsChat.qml +++ b/linphone-app/ui/views/App/Settings/SettingsCallsChat.qml @@ -216,7 +216,7 @@ TabContainer { Form { title: qsTr('chatTitle') - visible: SettingsModel.chatEnabled || SettingsModel.secureChatEnabled || SettingsModel.developerSettingsEnabled + visible: SettingsModel.standardChatEnabled || SettingsModel.secureChatEnabled || SettingsModel.developerSettingsEnabled width: parent.width FormLine { @@ -226,9 +226,9 @@ TabContainer { label: qsTr('chatEnabledLabel') Switch { - checked: SettingsModel.chatEnabled + checked: SettingsModel.standardChatEnabled - onClicked: SettingsModel.chatEnabled = !checked + onClicked: SettingsModel.standardChatEnabled = !checked } } FormGroup { diff --git a/linphone-app/ui/views/App/Settings/SettingsUi.qml b/linphone-app/ui/views/App/Settings/SettingsUi.qml index e7ad37dcc..cb9141f26 100644 --- a/linphone-app/ui/views/App/Settings/SettingsUi.qml +++ b/linphone-app/ui/views/App/Settings/SettingsUi.qml @@ -106,7 +106,7 @@ TabContainer { title: qsTr('pathsTitle') visible: SettingsModel.videoSupported || SettingsModel.callRecorderEnabled || - SettingsModel.chatEnabled || + SettingsModel.standardChatEnabled || SettingsModel.secureChatEnabled || SettingsModel.developerSettingsEnabled width: parent.width @@ -142,7 +142,7 @@ TabContainer { } FormLine { - visible: SettingsModel.chatEnabled || SettingsModel.secureChatEnabled || SettingsModel.developerSettingsEnabled + visible: SettingsModel.standardChatEnabled || SettingsModel.secureChatEnabled || SettingsModel.developerSettingsEnabled FormGroup { label: qsTr('downloadLabel')