- Remove 'app' section and keep 'ui'

- Allow to make a variable in readonly (only for enabling chats yet)
- Rename chatEnabled to standardChatEnabled
This commit is contained in:
Julien Wadel 2021-10-21 13:10:59 +02:00
parent 49327b7311
commit 331e621c8e
18 changed files with 53 additions and 41 deletions

View file

@ -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<linphone::Core> core = CoreManager::getInstance()->getCore();
std::shared_ptr<const linphone::ChatRoomParams> dbParams = mCall->getChatRoom()->getCurrentParams();

View file

@ -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;

View file

@ -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();
}

View file

@ -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;
}

View file

@ -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);

View file

@ -360,7 +360,7 @@ void TimelineListModel::onCallCreated(const std::shared_ptr<linphone::Call> &cal
if( settingsModel->getSecureChatEnabled() &&
(!settingsModel->getChatEnabled() || (settingsModel->getChatEnabled() && isEncrypted))
(!settingsModel->getStandardChatEnabled() || (settingsModel->getStandardChatEnabled() && isEncrypted))
){
params->enableEncryption(true);
createSecureChatRoom = true;

View file

@ -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 {

View file

@ -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)

View file

@ -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

View file

@ -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)
}
}

View file

@ -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) {

View file

@ -154,7 +154,7 @@ ColumnLayout {
ActionButton {
icon: SettingsModel.getShowStartChatButton() ? 'chat' : 'history'
visible: SettingsModel.chatEnabled
visible: SettingsModel.standardChatEnabled
onClicked: sipAddressesMenu.open(false)
TooltipArea {
isClickable: false

View file

@ -149,7 +149,7 @@ ColumnLayout {
ActionButton {
icon: SettingsModel.getShowStartChatButton() ? 'chat' : 'history'
visible: SettingsModel.chatEnabled
visible: SettingsModel.standardChatEnabled
onClicked: actions.itemAt(2).open()
}

View file

@ -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)
}

View file

@ -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()

View file

@ -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()

View file

@ -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 {

View file

@ -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')