mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-17 19:38:09 +00:00
feat(Settings): add an option to disable chat features
This commit is contained in:
parent
a680943b4e
commit
32637550d8
19 changed files with 153 additions and 68 deletions
|
|
@ -1176,6 +1176,10 @@ your friend's SIP address or username.</translation>
|
|||
<source>autoAnswerWithVideoLabel</source>
|
||||
<translation>Auto answer (with video)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>chatEnabledLabel</source>
|
||||
<translation>Chat enabled</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SettingsNetwork</name>
|
||||
|
|
|
|||
|
|
@ -1174,6 +1174,10 @@ Cliquez ici : <a href="%1">%1</a>
|
|||
<source>autoAnswerWithVideoLabel</source>
|
||||
<translation>Répondre autom. (avec vidéo)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>chatEnabledLabel</source>
|
||||
<translation>Chat activé</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SettingsNetwork</name>
|
||||
|
|
|
|||
|
|
@ -1174,6 +1174,10 @@
|
|||
<source>autoAnswerWithVideoLabel</source>
|
||||
<translation>Принимать вызов автоматически (с видео)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>chatEnabledLabel</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SettingsNetwork</name>
|
||||
|
|
|
|||
|
|
@ -1176,6 +1176,10 @@ arkadaşınızın SIP adresini veya kullanıcı adını girin.</translation>
|
|||
<source>autoAnswerWithVideoLabel</source>
|
||||
<translation>Kendiliğinden yanıtla (görüntüyle)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>chatEnabledLabel</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SettingsNetwork</name>
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ void CoreHandlers::onMessageReceived (
|
|||
emit messageReceived(message);
|
||||
|
||||
const App *app = App::getInstance();
|
||||
if (!app->hasFocus())
|
||||
if (!app->hasFocus() && CoreManager::getInstance()->getSettingsModel()->getChatEnabled())
|
||||
app->getNotifier()->notifyReceivedMessage(message);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@
|
|||
#include <QtConcurrent>
|
||||
#include <QTimer>
|
||||
|
||||
#include "../../app/paths/Paths.hpp"
|
||||
#include "../../utils/Utils.hpp"
|
||||
#include "app/paths/Paths.hpp"
|
||||
#include "utils/Utils.hpp"
|
||||
|
||||
#if defined(Q_OS_LINUX)
|
||||
#include "messages-count-notifier/MessagesCountNotifierLinux.hpp"
|
||||
|
|
@ -38,10 +38,10 @@
|
|||
|
||||
#include "CoreManager.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
// =============================================================================
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace {
|
||||
constexpr int cCbsCallInterval = 20;
|
||||
|
||||
|
|
@ -73,17 +73,17 @@ CoreManager::CoreManager (QObject *parent, const QString &configPath) :
|
|||
CoreHandlers *coreHandlers = mHandlers.get();
|
||||
|
||||
QObject::connect(coreHandlers, &CoreHandlers::coreStarted, this, [] {
|
||||
{
|
||||
MessagesCountNotifier *messagesCountNotifier = new MessagesCountNotifier(mInstance);
|
||||
messagesCountNotifier->updateUnreadMessagesCount();
|
||||
}
|
||||
|
||||
mInstance->mCallsListModel = new CallsListModel(mInstance);
|
||||
mInstance->mContactsListModel = new ContactsListModel(mInstance);
|
||||
mInstance->mSipAddressesModel = new SipAddressesModel(mInstance);
|
||||
mInstance->mSettingsModel = new SettingsModel(mInstance);
|
||||
mInstance->mAccountSettingsModel = new AccountSettingsModel(mInstance);
|
||||
|
||||
{
|
||||
MessagesCountNotifier *messagesCountNotifier = new MessagesCountNotifier(mInstance);
|
||||
messagesCountNotifier->updateUnreadMessagesCount();
|
||||
}
|
||||
|
||||
mInstance->migrate();
|
||||
|
||||
mInstance->mStarted = true;
|
||||
|
|
@ -106,12 +106,12 @@ shared_ptr<ChatModel> CoreManager::getChatModelFromSipAddress (const QString &si
|
|||
|
||||
// Create a new chat model.
|
||||
if (!mChatModels.contains(sipAddress)) {
|
||||
Q_ASSERT(mCore->createAddress(::Utils::appStringToCoreString(sipAddress)) != nullptr);
|
||||
Q_ASSERT(mCore->createAddress(Utils::appStringToCoreString(sipAddress)) != nullptr);
|
||||
|
||||
auto deleter = [this](ChatModel *chatModel) {
|
||||
mChatModels.remove(chatModel->getSipAddress());
|
||||
delete chatModel;
|
||||
};
|
||||
mChatModels.remove(chatModel->getSipAddress());
|
||||
delete chatModel;
|
||||
};
|
||||
|
||||
shared_ptr<ChatModel> chatModel(new ChatModel(sipAddress), deleter);
|
||||
mChatModels[chatModel->getSipAddress()] = chatModel;
|
||||
|
|
@ -169,7 +169,7 @@ void CoreManager::sendLogs () const {
|
|||
Q_CHECK_PTR(mCore);
|
||||
|
||||
qInfo() << QStringLiteral("Send logs to: `%1`.")
|
||||
.arg(::Utils::coreStringToAppString(mCore->getLogCollectionUploadServerUrl()));
|
||||
.arg(Utils::coreStringToAppString(mCore->getLogCollectionUploadServerUrl()));
|
||||
mCore->uploadLogCollection();
|
||||
}
|
||||
|
||||
|
|
@ -185,7 +185,7 @@ void CoreManager::cleanLogs () const {
|
|||
do { \
|
||||
qInfo() << QStringLiteral("Set `%1` path: `%2`") \
|
||||
.arg( # DATABASE) \
|
||||
.arg(::Utils::coreStringToAppString(PATH)); \
|
||||
.arg(Utils::coreStringToAppString(PATH)); \
|
||||
mCore->set ## DATABASE ## DatabasePath(PATH); \
|
||||
} while (0);
|
||||
|
||||
|
|
@ -200,15 +200,12 @@ void CoreManager::setDatabasesPaths () {
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
void CoreManager::setOtherPaths () {
|
||||
if (mCore->getZrtpSecretsFile().empty() || !Paths::filePathExists(mCore->getZrtpSecretsFile())) {
|
||||
if (mCore->getZrtpSecretsFile().empty() || !Paths::filePathExists(mCore->getZrtpSecretsFile()))
|
||||
mCore->setZrtpSecretsFile(Paths::getZrtpSecretsFilePath());
|
||||
}
|
||||
if (mCore->getUserCertificatesPath().empty() || !Paths::filePathExists(mCore->getUserCertificatesPath())) {
|
||||
if (mCore->getUserCertificatesPath().empty() || !Paths::filePathExists(mCore->getUserCertificatesPath()))
|
||||
mCore->setUserCertificatesPath(Paths::getUserCertificatesDirPath());
|
||||
}
|
||||
if (mCore->getRootCa().empty() || !Paths::filePathExists(mCore->getRootCa())) {
|
||||
if (mCore->getRootCa().empty() || !Paths::filePathExists(mCore->getRootCa()))
|
||||
mCore->setRootCa(Paths::getRootCaFilePath());
|
||||
}
|
||||
}
|
||||
|
||||
void CoreManager::setResourcesPaths () {
|
||||
|
|
@ -227,11 +224,15 @@ void CoreManager::createLinphoneCore (const QString &configPath) {
|
|||
|
||||
setResourcesPaths();
|
||||
|
||||
mCore = linphone::Factory::get()->createCore(mHandlers, Paths::getConfigFilePath(configPath), Paths::getFactoryConfigFilePath());
|
||||
mCore = linphone::Factory::get()->createCore(
|
||||
mHandlers,
|
||||
Paths::getConfigFilePath(configPath),
|
||||
Paths::getFactoryConfigFilePath()
|
||||
);
|
||||
|
||||
mCore->setVideoDisplayFilter("MSOGL");
|
||||
mCore->usePreviewWindow(true);
|
||||
mCore->setUserAgent("Linphone Desktop", ::Utils::appStringToCoreString(QCoreApplication::applicationVersion()));
|
||||
mCore->setUserAgent("Linphone Desktop", Utils::appStringToCoreString(QCoreApplication::applicationVersion()));
|
||||
|
||||
// Force capture/display.
|
||||
// Useful if the app was built without video support.
|
||||
|
|
@ -274,7 +275,7 @@ void CoreManager::migrate () {
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
QString CoreManager::getVersion () const {
|
||||
return ::Utils::coreStringToAppString(mCore->getVersion());
|
||||
return Utils::coreStringToAppString(mCore->getVersion());
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
@ -294,7 +295,7 @@ void CoreManager::handleLogsUploadStateChanged (linphone::CoreLogCollectionUploa
|
|||
|
||||
case linphone::CoreLogCollectionUploadStateDelivered:
|
||||
case linphone::CoreLogCollectionUploadStateNotDelivered:
|
||||
emit logsUploaded(::Utils::coreStringToAppString(info));
|
||||
emit logsUploaded(Utils::coreStringToAppString(info));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,10 @@ AbstractMessagesCountNotifier::AbstractMessagesCountNotifier (QObject *parent) :
|
|||
coreManager->getHandlers().get(), &CoreHandlers::messageReceived,
|
||||
this, &AbstractMessagesCountNotifier::handleMessageReceived
|
||||
);
|
||||
QObject::connect(
|
||||
coreManager->getSettingsModel(), &SettingsModel::chatEnabledChanged,
|
||||
this, &AbstractMessagesCountNotifier::internalNotifyUnreadMessagesCount
|
||||
);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
@ -54,7 +58,7 @@ void AbstractMessagesCountNotifier::internalNotifyUnreadMessagesCount () {
|
|||
qInfo() << QStringLiteral("Notify unread messages count: %1.").arg(mUnreadMessagesCount);
|
||||
int n = mUnreadMessagesCount > 99 ? 99 : mUnreadMessagesCount;
|
||||
|
||||
notifyUnreadMessagesCount(n);
|
||||
notifyUnreadMessagesCount(CoreManager::getInstance()->getSettingsModel()->getChatEnabled() ? n : 0);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -281,6 +281,15 @@ void SettingsModel::setAutoAnswerVideoStatus (bool status) {
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
bool SettingsModel::getChatEnabled () const {
|
||||
return !!mConfig->getInt(UI_SECTION, "chat_enabled", 1);
|
||||
}
|
||||
|
||||
void SettingsModel::setChatEnabled (bool status) {
|
||||
mConfig->setInt(UI_SECTION, "chat_enabled", status);
|
||||
emit chatEnabledChanged(status);
|
||||
}
|
||||
|
||||
QString SettingsModel::getFileTransferUrl () const {
|
||||
return ::Utils::coreStringToAppString(
|
||||
CoreManager::getInstance()->getCore()->getFileTransferServer()
|
||||
|
|
|
|||
|
|
@ -69,6 +69,8 @@ class SettingsModel : public QObject {
|
|||
Q_PROPERTY(bool autoAnswerVideoStatus READ getAutoAnswerVideoStatus WRITE setAutoAnswerVideoStatus NOTIFY autoAnswerVideoStatusChanged);
|
||||
Q_PROPERTY(int autoAnswerDelay READ getAutoAnswerDelay WRITE setAutoAnswerDelay NOTIFY autoAnswerDelayChanged);
|
||||
|
||||
Q_PROPERTY(bool chatEnabled READ getChatEnabled WRITE setChatEnabled NOTIFY chatEnabledChanged);
|
||||
|
||||
Q_PROPERTY(QString fileTransferUrl READ getFileTransferUrl WRITE setFileTransferUrl NOTIFY fileTransferUrlChanged);
|
||||
|
||||
Q_PROPERTY(bool limeIsSupported READ getLimeIsSupported CONSTANT);
|
||||
|
|
@ -207,6 +209,9 @@ public:
|
|||
int getAutoAnswerDelay () const;
|
||||
void setAutoAnswerDelay (int delay);
|
||||
|
||||
bool getChatEnabled () const;
|
||||
void setChatEnabled (bool status);
|
||||
|
||||
QString getFileTransferUrl () const;
|
||||
void setFileTransferUrl (const QString &url);
|
||||
|
||||
|
|
@ -352,6 +357,8 @@ signals:
|
|||
void autoAnswerVideoStatusChanged (bool status);
|
||||
void autoAnswerDelayChanged (int delay);
|
||||
|
||||
void chatEnabledChanged (bool status);
|
||||
|
||||
void fileTransferUrlChanged (const QString &url);
|
||||
|
||||
void mediaEncryptionChanged (MediaEncryption encryption);
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ function handleTextChanged () {
|
|||
}
|
||||
|
||||
function sendMessage (text) {
|
||||
textArea.text = ''
|
||||
textArea.item.text = ''
|
||||
chat.bindToEnd = true
|
||||
container.proxyModel.sendMessage(text)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -203,26 +203,33 @@ Rectangle {
|
|||
// Send area.
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
Borders {
|
||||
Loader {
|
||||
id: textArea
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: ChatStyle.sendArea.height + ChatStyle.sendArea.border.width
|
||||
Layout.preferredHeight: active ? ChatStyle.sendArea.height + ChatStyle.sendArea.border.width : 0
|
||||
|
||||
borderColor: ChatStyle.sendArea.border.color
|
||||
|
||||
topWidth: ChatStyle.sendArea.border.width
|
||||
|
||||
DroppableTextArea {
|
||||
id: textArea
|
||||
active: SettingsModel.chatEnabled
|
||||
sourceComponent: Borders {
|
||||
property alias text: textArea.text
|
||||
|
||||
anchors.fill: parent
|
||||
borderColor: ChatStyle.sendArea.border.color
|
||||
topWidth: ChatStyle.sendArea.border.width
|
||||
|
||||
dropEnabled: SettingsModel.fileTransferUrl.length > 0
|
||||
dropDisabledReason: qsTr('noFileTransferUrl')
|
||||
placeholderText: qsTr('newMessagePlaceholder')
|
||||
DroppableTextArea {
|
||||
id: textArea
|
||||
|
||||
onDropped: Logic.handleFilesDropped(files)
|
||||
onTextChanged: Logic.handleTextChanged(text)
|
||||
onValidText: Logic.sendMessage(text)
|
||||
anchors.fill: parent
|
||||
|
||||
dropEnabled: SettingsModel.fileTransferUrl.length > 0
|
||||
dropDisabledReason: qsTr('noFileTransferUrl')
|
||||
placeholderText: qsTr('newMessagePlaceholder')
|
||||
|
||||
onDropped: Logic.handleFilesDropped(files)
|
||||
onTextChanged: Logic.handleTextChanged(text)
|
||||
onValidText: Logic.sendMessage(text)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ SearchBox {
|
|||
searchBox.launchCall(entry.sipAddress)
|
||||
}
|
||||
}, {
|
||||
icon: 'chat',
|
||||
icon: SettingsModel.chatEnabled ? 'chat' : 'history',
|
||||
handler: function (entry) {
|
||||
searchBox.closeMenu()
|
||||
searchBox.launchChat(entry.sipAddress)
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ ColumnLayout {
|
|||
? TimelineStyle.contact.backgroundColor.a
|
||||
: TimelineStyle.contact.backgroundColor.b
|
||||
)
|
||||
displayUnreadMessagesCount: view.currentIndex !== index
|
||||
displayUnreadMessagesCount: SettingsModel.chatEnabled && view.currentIndex !== index
|
||||
entry: $timelineEntry
|
||||
sipAddressColor: view.currentIndex === index
|
||||
? TimelineStyle.contact.sipAddress.color.selected
|
||||
|
|
|
|||
|
|
@ -188,8 +188,19 @@ Window {
|
|||
|
||||
Chat {
|
||||
proxyModel: ChatProxyModel {
|
||||
Component.onCompleted: {
|
||||
if (!SettingsModel.chatEnabled) {
|
||||
setEntryTypeFilter(ChatModel.CallEntry)
|
||||
}
|
||||
}
|
||||
|
||||
sipAddress: window.sipAddress
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: SettingsModel
|
||||
onChatEnabledChanged: proxyModel.setEntryTypeFilter(status ? ChatModel.GenericEntry : ChatModel.CallEntry)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -390,6 +390,8 @@ Rectangle {
|
|||
}
|
||||
|
||||
ActionBar {
|
||||
id: bottomActions
|
||||
|
||||
anchors {
|
||||
right: parent.right
|
||||
rightMargin: CallStyle.actionArea.rightButtonsGroupMargin
|
||||
|
|
@ -417,7 +419,7 @@ Rectangle {
|
|||
}
|
||||
|
||||
ActionButton {
|
||||
icon: 'chat'
|
||||
icon: SettingsModel.chatEnabled ? 'chat' : 'history'
|
||||
|
||||
onClicked: {
|
||||
if (window.chatIsOpened) {
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ ColumnLayout {
|
|||
}
|
||||
|
||||
ActionButton {
|
||||
icon: 'chat'
|
||||
icon: SettingsModel.chatEnabled ? 'chat' : 'history'
|
||||
onClicked: actions.itemAt(2).open()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,11 +33,12 @@ function getUsername () {
|
|||
}
|
||||
|
||||
function updateChatFilter (button) {
|
||||
var ChatModel = Linphone.ChatModel
|
||||
if (button === 0) {
|
||||
chatProxyModel.setEntryTypeFilter(Linphone.ChatModel.GenericEntry)
|
||||
chatProxyModel.setEntryTypeFilter(ChatModel.GenericEntry)
|
||||
} else if (button === 1) {
|
||||
chatProxyModel.setEntryTypeFilter(Linphone.ChatModel.CallEntry)
|
||||
chatProxyModel.setEntryTypeFilter(ChatModel.CallEntry)
|
||||
} else {
|
||||
chatProxyModel.setEntryTypeFilter(Linphone.ChatModel.MessageEntry)
|
||||
chatProxyModel.setEntryTypeFilter(ChatModel.MessageEntry)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,29 +118,33 @@ ColumnLayout {
|
|||
// Messages/Calls filters.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Borders {
|
||||
Loader {
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: ConversationStyle.filters.height
|
||||
Layout.preferredHeight: active ? ConversationStyle.filters.height : 0
|
||||
|
||||
borderColor: ConversationStyle.filters.border.color
|
||||
bottomWidth: ConversationStyle.filters.border.bottomWidth
|
||||
color: ConversationStyle.filters.backgroundColor
|
||||
topWidth: ConversationStyle.filters.border.topWidth
|
||||
active: SettingsModel.chatEnabled
|
||||
sourceComponent: Borders {
|
||||
anchors.fill: parent
|
||||
borderColor: ConversationStyle.filters.border.color
|
||||
bottomWidth: ConversationStyle.filters.border.bottomWidth
|
||||
color: ConversationStyle.filters.backgroundColor
|
||||
topWidth: ConversationStyle.filters.border.topWidth
|
||||
|
||||
ExclusiveButtons {
|
||||
anchors {
|
||||
left: parent.left
|
||||
leftMargin: ConversationStyle.filters.leftMargin
|
||||
verticalCenter: parent.verticalCenter
|
||||
ExclusiveButtons {
|
||||
anchors {
|
||||
left: parent.left
|
||||
leftMargin: ConversationStyle.filters.leftMargin
|
||||
verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
texts: [
|
||||
qsTr('displayCallsAndMessages'),
|
||||
qsTr('displayCalls'),
|
||||
qsTr('displayMessages')
|
||||
]
|
||||
|
||||
onClicked: Logic.updateChatFilter(button)
|
||||
}
|
||||
|
||||
texts: [
|
||||
qsTr('displayCallsAndMessages'),
|
||||
qsTr('displayCalls'),
|
||||
qsTr('displayMessages')
|
||||
]
|
||||
|
||||
onClicked: Logic.updateChatFilter(button)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -155,7 +159,18 @@ ColumnLayout {
|
|||
proxyModel: ChatProxyModel {
|
||||
id: chatProxyModel
|
||||
|
||||
Component.onCompleted: {
|
||||
if (!SettingsModel.chatEnabled) {
|
||||
setEntryTypeFilter(ChatModel.CallEntry)
|
||||
}
|
||||
}
|
||||
|
||||
sipAddress: conversation.sipAddress
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: SettingsModel
|
||||
onChatEnabledChanged: chatProxyModel.setEntryTypeFilter(status ? ChatModel.GenericEntry : ChatModel.CallEntry)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,6 +105,18 @@ TabContainer {
|
|||
title: qsTr('chatTitle')
|
||||
width: parent.width
|
||||
|
||||
FormLine {
|
||||
FormGroup {
|
||||
label: qsTr('chatEnabledLabel')
|
||||
|
||||
Switch {
|
||||
checked: SettingsModel.chatEnabled
|
||||
|
||||
onClicked: SettingsModel.chatEnabled = !checked
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FormLine {
|
||||
FormGroup {
|
||||
label: qsTr('fileServerLabel')
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue