Option to deactivate chats and video.

- Replace videoSupported (build-time) by videoEnabled (option).
- Hide chat notifications.
- Add an option to disable video.
- Hide unread messages count.
- Hide mute/ephemerals items.
- Hide conversation's devices/ephemrals/mute/scheduling meetings menu items from conversation.
- Do not use camera in waiting room.
- Hide conference layout.
This commit is contained in:
Julien Wadel 2023-03-21 10:51:12 +01:00
parent a415d125f9
commit 918b3ae68b
28 changed files with 81 additions and 50 deletions

View file

@ -679,7 +679,7 @@ void CallModel::acceptWithAutoAnswerDelay () {
// Use auto-answer if activated and it's the only call.
if (settingsModel->getAutoAnswerStatus() && coreManager->getCore()->getCallsNb() == 1) {
if (mCall && mCall->getRemoteParams()->videoEnabled() && settingsModel->getAutoAnswerVideoStatus() && settingsModel->getVideoSupported())
if (mCall && mCall->getRemoteParams()->videoEnabled() && settingsModel->getAutoAnswerVideoStatus() && settingsModel->getVideoEnabled())
acceptWithVideo();
else
accept();
@ -787,8 +787,8 @@ bool CallModel::getCameraEnabled () const{
void CallModel::setCameraEnabled (bool status){
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
if (!core->videoSupported()) {
qWarning() << QStringLiteral("Unable to update video call property. (Video not supported.)");
if (!CoreManager::getInstance()->getSettingsModel()->getVideoEnabled()) {
qWarning() << QStringLiteral("Unable to update video call property. (Video not enabled.)");
return;
}
if(mCall) {
@ -857,13 +857,13 @@ bool CallModel::getVideoEnabled () const {
shared_ptr<const linphone::CallParams> params = mCall->getCurrentParams();
return params && params->videoEnabled();
}else
return true;
return CoreManager::getInstance()->getSettingsModel()->getVideoEnabled();
}
void CallModel::setVideoEnabled (bool status) {
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
if (!core->videoSupported()) {
qWarning() << QStringLiteral("Unable to update video call property. (Video not supported.)");
if (!CoreManager::getInstance()->getSettingsModel()->getVideoEnabled()) {
qWarning() << QStringLiteral("Unable to update video call property. (Video not enabled.)");
return;
}
if(mCall) {

View file

@ -174,8 +174,8 @@ void CallsListModel::launchSecureAudioCall (const QString &sipAddress, LinphoneE
void CallsListModel::launchVideoCall (const QString &sipAddress, const QString& prepareTransfertAddress, const bool& autoSelectAfterCreation, QVariantMap options) const {
CoreManager::getInstance()->getTimelineListModel()->mAutoSelectAfterCreation = autoSelectAfterCreation;
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
if (!core->videoSupported()) {
qWarning() << QStringLiteral("Unable to launch video call. (Video not supported.) Launching audio call...");
if (!CoreManager::getInstance()->getSettingsModel()->getVideoEnabled()) {
qWarning() << QStringLiteral("Unable to launch video call. (Video not enabled.) Launching audio call...");
launchAudioCall(sipAddress, prepareTransfertAddress, {});
return;
}

View file

@ -238,13 +238,12 @@ void CoreHandlers::onMessagesReceived (
}
if( !message || message->isOutgoing() )
continue;
messagesToSignal.push_back(message);
// 1. Do not notify if chat is not activated.
if (chatRoom->getCurrentParams()->getEncryptionBackend() == linphone::ChatRoomEncryptionBackend::None && !settingsModel->getStandardChatEnabled()
|| chatRoom->getCurrentParams()->getEncryptionBackend() != linphone::ChatRoomEncryptionBackend::None && !settingsModel->getSecureChatEnabled())
continue;
messagesToSignal.push_back(message);
// 2. Do not notify if the chatroom's notification has been deactivated.
appSettings.beginGroup(ChatRoomModel::getChatRoomId(chatRoom));

View file

@ -57,6 +57,8 @@ AbstractEventCountNotifier::AbstractEventCountNotifier (QObject *parent) : QObje
coreManager->getSettingsModel(), &SettingsModel::secureChatEnabledChanged,
this, &AbstractEventCountNotifier::internalnotifyEventCount
);
QObject::connect(coreManager->getSettingsModel(), &SettingsModel::standardChatEnabledChanged, this, &AbstractEventCountNotifier::updateUnreadMessageCount);
QObject::connect(coreManager->getSettingsModel(), &SettingsModel::secureChatEnabledChanged, this, &AbstractEventCountNotifier::updateUnreadMessageCount);
/*
QObject::connect(
coreManager->getCallsListModel(), &CallsListModel::callMissed,
@ -67,8 +69,12 @@ AbstractEventCountNotifier::AbstractEventCountNotifier (QObject *parent) : QObje
// -----------------------------------------------------------------------------
void AbstractEventCountNotifier::updateUnreadMessageCount () {
mUnreadMessageCount = CoreManager::getInstance()->getCore()->getUnreadChatMessageCountFromActiveLocals();
internalnotifyEventCount();
auto coreManager = CoreManager::getInstance();
if(!coreManager->getSettingsModel()->getStandardChatEnabled() && !coreManager->getSettingsModel()->getSecureChatEnabled())
mUnreadMessageCount = 0;
else
mUnreadMessageCount = CoreManager::getInstance()->getCore()->getUnreadChatMessageCountFromActiveLocals();
internalnotifyEventCount();
}
void AbstractEventCountNotifier::internalnotifyEventCount () {

View file

@ -519,12 +519,12 @@ QString AccountSettingsModel::getDefaultAccountDomain() const{
QVariantList AccountSettingsModel::getAccounts () const {
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
QVariantList accounts;
if(CoreManager::getInstance()->getSettingsModel()->getShowLocalSipAccount()) {
auto settingsModel = CoreManager::getInstance()->getSettingsModel();
if(settingsModel->getShowLocalSipAccount()) {
QVariantMap account;
account["sipAddress"] = Utils::coreStringToAppString(core->createPrimaryContactParsed()->asStringUriOnly());
account["fullSipAddress"] = Utils::coreStringToAppString(core->createPrimaryContactParsed()->asString());
account["unreadMessageCount"] = core->getUnreadChatMessageCountFromLocal(core->createPrimaryContactParsed());
account["unreadMessageCount"] = settingsModel->getStandardChatEnabled() || settingsModel->getSecureChatEnabled() ? core->getUnreadChatMessageCountFromLocal(core->createPrimaryContactParsed()) : 0;
account["missedCallCount"] = CoreManager::getInstance()->getMissedCallCountFromLocal(account["sipAddress"].toString());
account["account"].setValue(nullptr);
accounts << account;
@ -535,7 +535,7 @@ QVariantList AccountSettingsModel::getAccounts () const {
accountMap["sipAddress"] = Utils::coreStringToAppString(account->getParams()->getIdentityAddress()->asStringUriOnly());
accountMap["fullSipAddress"] = Utils::coreStringToAppString(account->getParams()->getIdentityAddress()->asString());
accountMap["account"].setValue(account);
accountMap["unreadMessageCount"] = account->getUnreadChatMessageCount();
accountMap["unreadMessageCount"] = settingsModel->getStandardChatEnabled() || settingsModel->getSecureChatEnabled() ? account->getUnreadChatMessageCount() : 0;
accountMap["missedCallCount"] = CoreManager::getInstance()->getMissedCallCountFromLocal(accountMap["sipAddress"].toString());
accounts << accountMap;
}

View file

@ -632,9 +632,17 @@ void SettingsModel::setVideoDefinition (const QVariantMap &definition) {
emit videoDefinitionChanged(definition);
}
bool SettingsModel::getVideoSupported () const {
return CoreManager::getInstance()->getCore()->videoSupported();
bool SettingsModel::getVideoEnabled() const {
return CoreManager::getInstance()->getCore()->videoSupported() && !!mConfig->getInt(UiSection, "video_enabled", 1);
}
void SettingsModel::setVideoEnabled(const bool& enable){
if( CoreManager::getInstance()->getCore()->videoSupported()){
mConfig->setInt(UiSection, "video_enabled", enable);
emit videoEnabledChanged();
}
}
void SettingsModel::setHighMosaicQuality(){
mConfig->setString("video", "max_mosaic_size", "");
}

View file

@ -97,7 +97,7 @@ class SettingsModel : public QObject {
Q_PROPERTY(QVariantMap videoDefinition READ getVideoDefinition WRITE setVideoDefinition NOTIFY videoDefinitionChanged)
Q_PROPERTY(bool videoSupported READ getVideoSupported CONSTANT)
Q_PROPERTY(bool videoEnabled READ getVideoEnabled WRITE setVideoEnabled NOTIFY videoEnabledChanged)
Q_PROPERTY(bool showVideoCodecs READ getShowVideoCodecs WRITE setShowVideoCodecs NOTIFY showVideoCodecsChanged)
@ -374,7 +374,8 @@ public:
Q_INVOKABLE QVariantMap getCurrentPreviewVideoDefinition () const;
void setVideoDefinition (const QVariantMap &definition);
bool getVideoSupported () const;
bool getVideoEnabled() const;
void setVideoEnabled(const bool& enable);
bool getShowVideoCodecs () const;
void setShowVideoCodecs (bool status);
@ -709,7 +710,7 @@ signals:
void showAudioCodecsChanged (bool status);
// Video. --------------------------------------------------------------------
void videoEnabledChanged();
void videoDevicesChanged (const QStringList &devices);
void videoDeviceChanged (const QString &device);

View file

@ -32,6 +32,7 @@
#include "components/core/CoreManager.hpp"
#include "components/history/HistoryModel.hpp"
#include "components/settings/AccountSettingsModel.hpp"
#include "components/settings/SettingsModel.hpp"
#include "utils/Utils.hpp"
#include "SipAddressesModel.hpp"
@ -510,7 +511,11 @@ void SipAddressesModel::addOrUpdateSipAddress (SipAddressEntry &sipAddressEntry,
void SipAddressesModel::addOrUpdateSipAddress (SipAddressEntry &sipAddressEntry, const shared_ptr<linphone::ChatMessage> &message) {
shared_ptr<linphone::ChatRoom> chatRoom(message->getChatRoom());
int count = chatRoom->getUnreadMessagesCount();
auto settingsModel = CoreManager::getInstance()->getSettingsModel();
int count = 0;
if (chatRoom->getCurrentParams()->getEncryptionBackend() == linphone::ChatRoomEncryptionBackend::None && !settingsModel->getStandardChatEnabled()
|| chatRoom->getCurrentParams()->getEncryptionBackend() != linphone::ChatRoomEncryptionBackend::None && !settingsModel->getSecureChatEnabled())
count = chatRoom->getUnreadMessagesCount();
QString localAddress(Utils::cleanSipAddress(Utils::coreStringToAppString(chatRoom->getLocalAddress()->asStringUriOnly())));
QString peerAddress(Utils::cleanSipAddress(Utils::coreStringToAppString(chatRoom->getPeerAddress()->asStringUriOnly())));

View file

@ -83,7 +83,7 @@ function getParams (call) {
if (status === CallModel.CallStatusIncoming) {
var optActions = []
if (Linphone.SettingsModel.videoSupported) {
if (Linphone.SettingsModel.videoEnabled) {
optActions.push({
handler: call.acceptWithVideo,
name: qsTr('acceptVideoCall')

View file

@ -198,7 +198,7 @@ DialogPlus {
RowLayout {
spacing: MultimediaParametersDialogStyle.column.entry.spacing
width: parent.width
visible: SettingsModel.videoSupported
visible: SettingsModel.videoEnabled
Icon {
icon: MultimediaParametersDialogStyle.column.entry.camera.icon

View file

@ -129,7 +129,7 @@ Rectangle{
: IncallMenuStyle.settingsIcons.activeSpeakerIcon
: IncallMenuStyle.settingsIcons.audioOnlyIcon)
, nextPage:layoutMenu
, visible: mainItem.callModel && mainItem.callModel.isConference},
, visible: mainItem.callModel && mainItem.callModel.isConference && SettingsModel.videoEnabled},
{ titleIndex: 2
, icon: IncallMenuStyle.settingsIcons.participantsIcon

View file

@ -62,7 +62,7 @@ Notification {
isCustom: true
backgroundRadius: 90
colorSet: NotificationReceivedCallStyle.acceptVideoCall
visible: SettingsModel.videoSupported && notification.call.getRemoteVideoEnabled()
visible: SettingsModel.videoEnabled && notification.call.getRemoteVideoEnabled()
onClicked: notification._close(notification.call.acceptWithVideo)
}

View file

@ -70,7 +70,7 @@ SearchBox {
searchBox.closeMenu()
searchBox.launchVideoCall(entry.sipAddress)
},
visible: SettingsModel.videoSupported && SettingsModel.outgoingCallsEnabled && SettingsModel.showStartVideoCallButton
visible: SettingsModel.videoEnabled && SettingsModel.outgoingCallsEnabled && SettingsModel.showStartVideoCallButton
}, {
colorSet: SipAddressesViewStyle.call,
secure: 0,

View file

@ -129,6 +129,7 @@ Rectangle {
spacing: 0
Layout.alignment: Qt.AlignBottom | Qt.AlignRight
Layout.preferredHeight: TimelineStyle.status.iconSize
visible: SettingsModel.standardChatEnabled || SettingsModel.secureChatEnabled
Icon{
id: notificationsIcon
Layout.preferredHeight: TimelineStyle.status.iconSize

View file

@ -75,7 +75,7 @@ DialogPlus {
handler: function (entry) {
launchVideoCall(entry.sipAddress)
},
visible: SettingsModel.videoSupported && SettingsModel.showStartVideoCallButton,
visible: SettingsModel.videoEnabled && SettingsModel.showStartVideoCallButton,
handlerSipAddress: function(sipAddress) {
launchVideoCall(sipAddress)
}

View file

@ -65,7 +65,7 @@ function handleStatusChanged (status, isFullscreen) {
}
function handleVideoRequested (call) {
if (window.virtualWindowVisible || !Linphone.SettingsModel.videoSupported) {
if (window.virtualWindowVisible || !Linphone.SettingsModel.videoEnabled) {
call.rejectVideoRequest()
return
}

View file

@ -539,7 +539,7 @@ Rectangle {
colorSet: callModel && callModel.cameraEnabled ? IncallStyle.buttons.cameraOn : IncallStyle.buttons.cameraOff
updating: callModel.videoEnabled && callModel.updating && !mainItem.layoutChanging
enabled: callModel && !callModel.pausedByUser
visible: SettingsModel.videoSupported
visible: SettingsModel.videoEnabled
property bool _activateCamera: false
onClicked: if(callModel && !mainItem.layoutChanging){
if( callModel.isConference){// Only deactivate camera in conference.

View file

@ -16,7 +16,7 @@ AbstractStartingCall {
isCustom: true
backgroundRadius: 90
colorSet: CallStyle.buttons.acceptVideoCall
visible: SettingsModel.videoSupported
visible: SettingsModel.videoEnabled
onClicked: call.acceptWithVideo()
}

View file

@ -20,7 +20,7 @@ Rectangle {
color: WaitingRoomStyle.backgroundColor.color
property ConferenceInfoModel conferenceInfoModel
property CallModel callModel // Store the call for processing calling.
property bool previewLoaderEnabled: callModel ? callModel.videoEnabled : true
property bool previewLoaderEnabled: callModel ? callModel.videoEnabled : SettingsModel.videoEnabled
property var _sipAddressObserver: callModel ? SipAddressesModel.getSipAddressObserver(callModel.fullPeerAddress, callModel.fullLocalAddress) : undefined
property bool isEnded: callModel && callModel.status == CallModel.CallStatusEnded
@ -156,7 +156,7 @@ Rectangle {
: mainItem.callModel
? mainItem.callModel.conferenceModel
: null
deactivateCamera: !mainItem.previewLoaderEnabled || mainItem.isEnded
deactivateCamera: !SettingsModel.videoEnabled || !mainItem.previewLoaderEnabled || mainItem.isEnded
/*
image: mainItem._sipAddressObserver && mainItem._sipAddressObserver.contact && mainItem._sipAddressObserver.contact.vcard.avatar
@ -307,7 +307,7 @@ Rectangle {
ActionSwitch {
id: camera
property bool cameraEnabled: true
visible: !mainItem.callModel
visible: !mainItem.callModel && SettingsModel.videoEnabled
isCustom: true
backgroundRadius: 90
colorSet: cameraEnabled ? WaitingRoomStyle.buttons.cameraOn : WaitingRoomStyle.buttons.cameraOff
@ -346,7 +346,7 @@ Rectangle {
property int selectedMode: SettingsModel.videoConferenceLayout
anchors.centerIn: parent
anchors.horizontalCenterOffset: contentsStack.cameraWidth/2 - modeChoice.width/2
visible: !mainItem.callModel
visible: !mainItem.callModel && SettingsModel.videoEnabled
toggled: layoutMenu.visible
isCustom: true
backgroundRadius: width/2

View file

@ -159,7 +159,7 @@ ColumnLayout {
backgroundRadius: 90
colorSet: ContactEditStyle.videoCall
visible: SettingsModel.videoSupported && SettingsModel.outgoingCallsEnabled && SettingsModel.showStartVideoCallButton
visible: SettingsModel.videoEnabled && SettingsModel.outgoingCallsEnabled && SettingsModel.showStartVideoCallButton
onClicked: sipAddressesMenu.open(sipAddressesMenu.startVideoCall)
}

View file

@ -139,7 +139,7 @@ ColumnLayout {
isCustom: true
backgroundRadius: 90
colorSet: ContactsStyle.videoCall
visible: SettingsModel.videoSupported && SettingsModel.outgoingCallsEnabled && SettingsModel.getShowStartVideoCallButton()
visible: SettingsModel.videoEnabled && SettingsModel.outgoingCallsEnabled && SettingsModel.getShowStartVideoCallButton()
onClicked: actions.itemAt(0).open()
}

View file

@ -213,7 +213,7 @@ ColumnLayout {
iconSize:30
MouseArea{
anchors.fill:parent
visible: conversation.chatRoomModel && !conversation.chatRoomModel.isReadOnly
visible: conversation.chatRoomModel && !conversation.chatRoomModel.isReadOnly && (SettingsModel.standardChatEnabled || SettingsModel.secureChatEnabled)
onClicked : {
window.detachVirtualWindow()
window.attachVirtualWindow(Qt.resolvedUrl('Dialogs/InfoEncryption.qml')
@ -265,7 +265,7 @@ ColumnLayout {
backgroundRadius: 1000
colorSet: ConversationStyle.bar.actions.videoCall
visible: SettingsModel.videoSupported && SettingsModel.outgoingCallsEnabled && SettingsModel.showStartVideoCallButton && !conversation.haveMoreThanOneParticipants
visible: SettingsModel.videoEnabled && SettingsModel.outgoingCallsEnabled && SettingsModel.showStartVideoCallButton && !conversation.haveMoreThanOneParticipants
onClicked: CallsListModel.launchVideoCall(chatRoomModel.participants.addressesToString)
}
@ -441,7 +441,7 @@ ColumnLayout {
//: "Conversation's devices" : Item menu to get all participant devices of the chat room
text: qsTr('conversationMenuDevices')
iconMenu: MenuItemStyle.devices.icon
visible: conversationMenu.showDevices
visible: conversationMenu.showDevices && (SettingsModel.standardChatEnabled || SettingsModel.secureChatEnabled)
iconSizeMenu: 40
menuItemStyle : MenuItemStyle.aux2
onTriggered: {
@ -463,7 +463,7 @@ ColumnLayout {
iconMenu: MenuItemStyle.ephemeral.icon
iconSizeMenu: 40
menuItemStyle : MenuItemStyle.aux2
visible: conversationMenu.showEphemerals
visible: conversationMenu.showEphemerals && (SettingsModel.standardChatEnabled || SettingsModel.secureChatEnabled)
onTriggered: {
window.detachVirtualWindow()
window.attachVirtualWindow(Qt.resolvedUrl('Dialogs/EphemeralChatRoom.qml')
@ -485,7 +485,7 @@ ColumnLayout {
iconMenu: MenuItemStyle.scheduleMeeting.icon
iconSizeMenu: 40
menuItemStyle : MenuItemStyle.aux2
visible: conversationMenu.showScheduleMeeting
visible: SettingsModel.videoConferenceEnabled && conversationMenu.showScheduleMeeting
onClicked: {
conferenceInfoModel.resetConferenceInfo()
conferenceInfoModel.isScheduled = true
@ -511,6 +511,7 @@ ColumnLayout {
}
MenuItem{
id: muteMenuItem
visible: SettingsModel.standardChatEnabled || SettingsModel.secureChatEnabled
text: chatRoomModel.notificationsEnabled
//: 'Disable notifications' : Item menu to disable chat's notifications
? qsTr('conversationMenuDeactivate')

View file

@ -92,7 +92,7 @@ ColumnLayout {
isCustom: true
backgroundRadius: 90
colorSet: HistoryViewStyle.videoCall
visible: peerAddress && SettingsModel.videoSupported && SettingsModel.outgoingCallsEnabled && SettingsModel.showStartVideoCallButton
visible: peerAddress && SettingsModel.videoEnabled && SettingsModel.outgoingCallsEnabled && SettingsModel.showStartVideoCallButton
onClicked: CallsListModel.launchVideoCall(historyView.peerAddress)
}

View file

@ -94,7 +94,7 @@ TabContainer {
FormLine {
FormGroup {
label: qsTr('autoAnswerWithVideoLabel')
visible: SettingsModel.videoSupported
visible: SettingsModel.videoEnabled
Switch {
checked: SettingsModel.autoAnswerVideoStatus

View file

@ -254,7 +254,7 @@ TabContainer {
readonly property int defaultPort: 9078
title: qsTr('videoRtpUdpPortLabel')
visible: SettingsModel.videoSupported
visible: SettingsModel.videoEnabled
FormTableEntry {
width:randomVideoRtpUdpPort.width
@ -394,7 +394,7 @@ TabContainer {
FormGroup {
label: qsTr('videoRtpStreamFieldLabel')
visible: SettingsModel.videoSupported
visible: SettingsModel.videoEnabled
HexField {
text: SettingsModel.dscpVideo

View file

@ -112,7 +112,7 @@ TabContainer {
Form {
title: qsTr('pathsTitle')
visible: SettingsModel.videoSupported ||
visible: SettingsModel.videoEnabled ||
SettingsModel.callRecorderEnabled ||
SettingsModel.standardChatEnabled ||
SettingsModel.secureChatEnabled ||
@ -120,7 +120,7 @@ TabContainer {
width: parent.width
FormLine {
visible: SettingsModel.videoSupported
visible: SettingsModel.videoEnabled
FormGroup {
label: qsTr('savedScreenshotsLabel')

View file

@ -176,6 +176,16 @@ TabContainer {
onClicked: SettingsModel.showVideoCodecs = !checked
}
}
FormGroup {
label: 'Video enabled'
Switch {
checked: SettingsModel.videoEnabled
onClicked: SettingsModel.videoEnabled = !checked
}
}
}
CodecsViewer {

View file

@ -71,7 +71,7 @@ ApplicationWindow {
}
TabButton {
visible: SettingsModel.videoSupported
visible: SettingsModel.videoEnabled || SettingsModel.developerSettingsEnabled
iconName: TabButtonStyle.icon.videoIcon
text: qsTr('videoTab')
width: visible ? implicitWidth : 0