From 9f6857ce7c8e0ca644fee4b5294541e96c8e5dc4 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Fri, 21 Jul 2017 13:18:47 +0200 Subject: [PATCH] feat(SettingsModel): add a video mode supports for auto answer (close #44) --- assets/languages/en.ts | 4 ++++ assets/languages/fr.ts | 4 ++++ src/components/call/CallModel.cpp | 12 +++++++++--- src/components/settings/SettingsModel.cpp | 11 +++++++++++ src/components/settings/SettingsModel.hpp | 5 +++++ ui/views/App/Settings/SettingsCallsChat.qml | 13 +++++++++++++ 6 files changed, 46 insertions(+), 3 deletions(-) diff --git a/assets/languages/en.ts b/assets/languages/en.ts index 5e4627089..f3715d375 100644 --- a/assets/languages/en.ts +++ b/assets/languages/en.ts @@ -1110,6 +1110,10 @@ your friend's SIP address or username. autoAnswerDelayLabel Delay (in ms) + + autoAnswerWithVideoLabel + Auto answer (with video) + SettingsNetwork diff --git a/assets/languages/fr.ts b/assets/languages/fr.ts index b77ec8b69..3ec1c7674 100644 --- a/assets/languages/fr.ts +++ b/assets/languages/fr.ts @@ -1108,6 +1108,10 @@ Cliquez ici : <a href="%1">%1</a> autoAnswerDelayLabel Délai (en ms) + + autoAnswerWithVideoLabel + Répondre autom. (avec vidéo) + SettingsNetwork diff --git a/src/components/call/CallModel.cpp b/src/components/call/CallModel.cpp index a2bcc9b46..ee30b1b63 100644 --- a/src/components/call/CallModel.cpp +++ b/src/components/call/CallModel.cpp @@ -343,10 +343,16 @@ CallModel::CallStatus CallModel::getStatus () const { // ----------------------------------------------------------------------------- void CallModel::acceptWithAutoAnswerDelay () { - // Use auto-answer if activated and it's the only call. CoreManager *coreManager = CoreManager::getInstance(); - if (coreManager->getSettingsModel()->getAutoAnswerStatus() && coreManager->getCore()->getCallsNb() == 1) - accept(); + SettingsModel *settingsModel = coreManager->getSettingsModel(); + + // Use auto-answer if activated and it's the only call. + if (settingsModel->getAutoAnswerStatus() && coreManager->getCore()->getCallsNb() == 1) { + if (mCall->getRemoteParams()->videoEnabled() && settingsModel->getAutoAnswerVideoStatus()) + acceptWithVideo(); + else + accept(); + } } // ----------------------------------------------------------------------------- diff --git a/src/components/settings/SettingsModel.cpp b/src/components/settings/SettingsModel.cpp index 88eb40628..f243df470 100644 --- a/src/components/settings/SettingsModel.cpp +++ b/src/components/settings/SettingsModel.cpp @@ -261,6 +261,17 @@ void SettingsModel::setAutoAnswerStatus (bool status) { // ----------------------------------------------------------------------------- +bool SettingsModel::getAutoAnswerVideoStatus () const { + return !!mConfig->getInt(UI_SECTION, "auto_answer_with_video", 0); +} + +void SettingsModel::setAutoAnswerVideoStatus (bool status) { + mConfig->setInt(UI_SECTION, "auto_answer_with_video", status); + emit autoAnswerVideoStatusChanged(status); +} + +// ----------------------------------------------------------------------------- + QString SettingsModel::getFileTransferUrl () const { return ::Utils::coreStringToAppString( CoreManager::getInstance()->getCore()->getFileTransferServer() diff --git a/src/components/settings/SettingsModel.hpp b/src/components/settings/SettingsModel.hpp index 0b71553e7..f6aaf2ccf 100644 --- a/src/components/settings/SettingsModel.hpp +++ b/src/components/settings/SettingsModel.hpp @@ -64,6 +64,7 @@ class SettingsModel : public QObject { // Chat & calls. ------------------------------------------------------------- Q_PROPERTY(bool autoAnswerStatus READ getAutoAnswerStatus WRITE setAutoAnswerStatus NOTIFY autoAnswerStatusChanged); + Q_PROPERTY(bool autoAnswerVideoStatus READ getAutoAnswerVideoStatus WRITE setAutoAnswerVideoStatus NOTIFY autoAnswerVideoStatusChanged); Q_PROPERTY(int autoAnswerDelay READ getAutoAnswerDelay WRITE setAutoAnswerDelay NOTIFY autoAnswerDelayChanged); Q_PROPERTY(QString fileTransferUrl READ getFileTransferUrl WRITE setFileTransferUrl NOTIFY fileTransferUrlChanged); @@ -194,6 +195,9 @@ public: bool getAutoAnswerStatus () const; void setAutoAnswerStatus (bool status); + bool getAutoAnswerVideoStatus () const; + void setAutoAnswerVideoStatus (bool status); + int getAutoAnswerDelay () const; void setAutoAnswerDelay (int delay); @@ -333,6 +337,7 @@ signals: // Chat & calls. ------------------------------------------------------------- void autoAnswerStatusChanged (bool status); + void autoAnswerVideoStatusChanged (bool status); void autoAnswerDelayChanged (int delay); void fileTransferUrlChanged (const QString &url); diff --git a/ui/views/App/Settings/SettingsCallsChat.qml b/ui/views/App/Settings/SettingsCallsChat.qml index 66daeab72..d231f2d10 100644 --- a/ui/views/App/Settings/SettingsCallsChat.qml +++ b/ui/views/App/Settings/SettingsCallsChat.qml @@ -86,6 +86,19 @@ TabContainer { } } } + + FormLine { + FormGroup { + label: qsTr('autoAnswerWithVideoLabel') + + Switch { + checked: SettingsModel.autoAnswerVideoStatus + enabled: autoAnswer.checked + + onClicked: SettingsModel.autoAnswerVideoStatus = !checked + } + } + } } Form {