Commit a6317321 authored by Ronan's avatar Ronan

feat(Settings): add an option to keep calls window in background

parent 73cb7a2c
Pipeline #187 failed with stage
in 0 seconds
......@@ -1236,6 +1236,10 @@
<source>outgoingCallsEnabledLabel</source>
<translation type="unfinished"/>
</message>
<message>
<source>showTelKeypadAutomaticallyLabel</source>
<translation type="unfinished"/>
</message>
</context>
<context>
<name>SettingsNetwork</name>
......
......@@ -1236,6 +1236,10 @@
<source>outgoingCallsEnabledLabel</source>
<translation type="unfinished"/>
</message>
<message>
<source>showTelKeypadAutomaticallyLabel</source>
<translation type="unfinished"/>
</message>
</context>
<context>
<name>SettingsNetwork</name>
......
......@@ -1236,6 +1236,10 @@
<source>outgoingCallsEnabledLabel</source>
<translation type="unfinished"/>
</message>
<message>
<source>showTelKeypadAutomaticallyLabel</source>
<translation type="unfinished"/>
</message>
</context>
<context>
<name>SettingsNetwork</name>
......
......@@ -1236,6 +1236,10 @@
<source>outgoingCallsEnabledLabel</source>
<translation type="unfinished"/>
</message>
<message>
<source>showTelKeypadAutomaticallyLabel</source>
<translation type="unfinished"/>
</message>
</context>
<context>
<name>SettingsNetwork</name>
......
......@@ -1247,6 +1247,10 @@ Server URL ist nicht konfiguriert.</translation>
<source>automaticallyRecordCallsLabel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>keepCallsWindowInBackgroundLabel</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SettingsNetwork</name>
......
......@@ -1252,6 +1252,10 @@ your friend&apos;s SIP address or username.</translation>
<source>automaticallyRecordCallsLabel</source>
<translation>Automatically record calls</translation>
</message>
<message>
<source>keepCallsWindowInBackgroundLabel</source>
<translation>Keep calls window in background</translation>
</message>
</context>
<context>
<name>SettingsNetwork</name>
......
......@@ -1250,6 +1250,10 @@ Cliquez ici : &lt;a href=&quot;%1&quot;&gt;%1&lt;/a&gt;
<source>automaticallyRecordCallsLabel</source>
<translation>Enregister auto. les appels</translation>
</message>
<message>
<source>keepCallsWindowInBackgroundLabel</source>
<translation>Fenêtre d&apos;appels en tâche de fond</translation>
</message>
</context>
<context>
<name>SettingsNetwork</name>
......
......@@ -1247,6 +1247,10 @@
<source>automaticallyRecordCallsLabel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>keepCallsWindowInBackgroundLabel</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SettingsNetwork</name>
......
......@@ -1249,6 +1249,10 @@ Tiesiog, įveskite savo draugo SIP adresą ar naudotojo vardą.</translation>
<source>automaticallyRecordCallsLabel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>keepCallsWindowInBackgroundLabel</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SettingsNetwork</name>
......
......@@ -1252,6 +1252,10 @@ o endereço SIP ou nome de usuário do seu amigo.</translation>
<source>automaticallyRecordCallsLabel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>keepCallsWindowInBackgroundLabel</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SettingsNetwork</name>
......
......@@ -1250,6 +1250,10 @@
<source>automaticallyRecordCallsLabel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>keepCallsWindowInBackgroundLabel</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SettingsNetwork</name>
......
......@@ -1249,6 +1249,10 @@ Klicka här: &lt;a href=&quot;%1&quot;&gt;%1&lt;/a&gt;
<source>automaticallyRecordCallsLabel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>keepCallsWindowInBackgroundLabel</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SettingsNetwork</name>
......
......@@ -1249,6 +1249,10 @@ arkadaşınızın SIP adresini veya kullanıcı adını girin.</translation>
<source>automaticallyRecordCallsLabel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>keepCallsWindowInBackgroundLabel</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SettingsNetwork</name>
......
......@@ -22,12 +22,15 @@
#include <iostream>
#include <QQuickWindow>
#include "config.h"
#include "app/App.hpp"
#include "components/calls/CallsListModel.hpp"
#include "components/core/CoreHandlers.hpp"
#include "components/core/CoreManager.hpp"
#include "components/settings/SettingsModel.hpp"
#include "utils/Utils.hpp"
#include "Cli.hpp"
......@@ -121,13 +124,20 @@ static void cliInitiateConference (QHash<QString, QString> &args) {
shared_ptr<linphone::Conference> conference = core->getConference();
const QString id = args["conference-id"];
auto updateCallsWindow = []() {
// TODO: Set the view to the "waiting call view".
QQuickWindow *callsWindow = App::getInstance()->getCallsWindow();
if (CoreManager::getInstance()->getSettingsModel()->getKeepCallsWindowInBackground()) {
if (!callsWindow->isVisible())
callsWindow->showMinimized();
} else
App::smartShowWindow(callsWindow);
};
App *app = App::getInstance();
if (conference) {
if (conference->getId() == Utils::appStringToCoreString(id)) {
qInfo() << QStringLiteral("Conference `%1` already exists.").arg(id);
// TODO: Set the view to the "waiting call view".
app->smartShowWindow(app->getCallsWindow());
updateCallsWindow();
return;
}
......@@ -144,8 +154,8 @@ static void cliInitiateConference (QHash<QString, QString> &args) {
qWarning() << QStringLiteral("Unable to join created conference: `%1`.").arg(id);
return;
}
// TODO: Set the view to the "waiting call view".
app->smartShowWindow(app->getCallsWindow());
updateCallsWindow();
}
// =============================================================================
......
......@@ -21,6 +21,7 @@
*/
#include <QDateTime>
#include <QQuickWindow>
#include <QTimer>
#include "app/App.hpp"
......@@ -151,27 +152,11 @@ void CallModel::notifyCameraFirstFrameReceived (unsigned int width, unsigned int
// -----------------------------------------------------------------------------
void CallModel::accept () {
stopAutoAnswerTimer();
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
shared_ptr<linphone::CallParams> params = core->createCallParams(mCall);
params->enableVideo(false);
setRecordFile(params);
App::smartShowWindow(App::getInstance()->getCallsWindow());
mCall->acceptWithParams(params);
accept(false);
}
void CallModel::acceptWithVideo () {
stopAutoAnswerTimer();
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
shared_ptr<linphone::CallParams> params = core->createCallParams(mCall);
params->enableVideo(true);
setRecordFile(params);
App::smartShowWindow(App::getInstance()->getCallsWindow());
mCall->acceptWithParams(params);
accept(true);
}
void CallModel::terminate () {
......@@ -307,7 +292,6 @@ void CallModel::handleCallStateChanged (const shared_ptr<linphone::Call> &call,
mCall->deferUpdate();
emit videoRequested();
}
break;
case linphone::CallStateIdle:
......@@ -329,6 +313,28 @@ void CallModel::handleCallStateChanged (const shared_ptr<linphone::Call> &call,
// -----------------------------------------------------------------------------
void CallModel::accept (bool withVideo) {
stopAutoAnswerTimer();
CoreManager *coreManager = CoreManager::getInstance();
shared_ptr<linphone::Core> core = coreManager->getCore();
shared_ptr<linphone::CallParams> params = core->createCallParams(mCall);
params->enableVideo(withVideo);
setRecordFile(params);
QQuickWindow *callsWindow = App::getInstance()->getCallsWindow();
if (coreManager->getSettingsModel()->getKeepCallsWindowInBackground()) {
if (!callsWindow->isVisible())
callsWindow->showMinimized();
} else
App::smartShowWindow(callsWindow);
mCall->acceptWithParams(params);
}
// -----------------------------------------------------------------------------
void CallModel::updateIsInConference () {
if (mIsInConference != mCall->getParams()->getLocalConferenceMode()) {
mIsInConference = !mIsInConference;
......@@ -496,7 +502,6 @@ void CallModel::setPausedByUser (bool status) {
if (status) {
if (!mPausedByUser)
mCall->pause();
return;
}
......
......@@ -140,6 +140,8 @@ private:
void handleCallEncryptionChanged (const std::shared_ptr<linphone::Call> &call);
void handleCallStateChanged (const std::shared_ptr<linphone::Call> &call, linphone::CallState state);
void accept (bool withVideo);
void stopAutoAnswerTimer () const;
CallStatus getStatus () const;
......
......@@ -20,8 +20,9 @@
* Author: Ronan Abhamon
*/
#include <QTimer>
#include <QQmlApplicationEngine>
#include <QQuickWindow>
#include <QTimer>
#include "app/App.hpp"
#include "components/call/CallModel.hpp"
......@@ -29,6 +30,7 @@
#include "components/conference/ConferenceHelperModel.hpp"
#include "components/core/CoreHandlers.hpp"
#include "components/core/CoreManager.hpp"
#include "components/settings/SettingsModel.hpp"
#include "utils/Utils.hpp"
#include "CallsListModel.hpp"
......@@ -226,8 +228,14 @@ bool CallsListModel::removeRows (int row, int count, const QModelIndex &parent)
// -----------------------------------------------------------------------------
void CallsListModel::addCall (const shared_ptr<linphone::Call> &call) {
if (call->getDir() == linphone::CallDirOutgoing)
App::smartShowWindow(App::getInstance()->getCallsWindow());
if (call->getDir() == linphone::CallDirOutgoing) {
QQuickWindow *callsWindow = App::getInstance()->getCallsWindow();
if (CoreManager::getInstance()->getSettingsModel()->getKeepCallsWindowInBackground()) {
if (!callsWindow->isVisible())
callsWindow->showMinimized();
} else
App::smartShowWindow(callsWindow);
}
CallModel *callModel = new CallModel(call);
qInfo() << QStringLiteral("Add call:") << callModel;
......
......@@ -365,6 +365,17 @@ void SettingsModel::setShowTelKeypadAutomatically (bool status) {
// -----------------------------------------------------------------------------
bool SettingsModel::getKeepCallsWindowInBackground () const {
return !!mConfig->getInt(UiSection, "keep_calls_window_in_background", 0);
}
void SettingsModel::setKeepCallsWindowInBackground (bool status) {
mConfig->setInt(UiSection, "keep_calls_window_in_background", status);
emit keepCallsWindowInBackgroundChanged(status);
}
// -----------------------------------------------------------------------------
bool SettingsModel::getOutgoingCallsEnabled () const {
return !!mConfig->getInt(UiSection, "outgoing_calls_enabled", 1);
}
......
......@@ -84,6 +84,8 @@ class SettingsModel : public QObject {
Q_PROPERTY(bool showTelKeypadAutomatically READ getShowTelKeypadAutomatically WRITE setShowTelKeypadAutomatically NOTIFY showTelKeypadAutomaticallyChanged);
Q_PROPERTY(bool keepCallsWindowInBackground READ getKeepCallsWindowInBackground WRITE setKeepCallsWindowInBackground NOTIFY keepCallsWindowInBackgroundChanged);
Q_PROPERTY(bool outgoingCallsEnabled READ getOutgoingCallsEnabled WRITE setOutgoingCallsEnabled NOTIFY outgoingCallsEnabledChanged);
Q_PROPERTY(bool callRecorderEnabled READ getCallRecorderEnabled WRITE setCallRecorderEnabled NOTIFY callRecorderEnabledChanged);
......@@ -266,6 +268,9 @@ public:
bool getShowTelKeypadAutomatically () const;
void setShowTelKeypadAutomatically (bool status);
bool getKeepCallsWindowInBackground () const;
void setKeepCallsWindowInBackground (bool status);
bool getOutgoingCallsEnabled () const;
void setOutgoingCallsEnabled (bool status);
......@@ -461,6 +466,8 @@ signals:
void showTelKeypadAutomaticallyChanged (bool status);
void keepCallsWindowInBackgroundChanged (bool status);
void outgoingCallsEnabledChanged (bool status);
void callRecorderEnabledChanged (bool status);
......
import QtQuick 2.7
import QtQuick.Layouts 1.3
import Common 1.0
import Common.Styles 1.0
// =============================================================================
......@@ -28,6 +29,12 @@ RowLayout {
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
TooltipArea {
delay: 0
text: parent.text
visible: parent.truncated
}
}
// ---------------------------------------------------------------------------
......
import QtQuick 2.7
import QtQuick.Layouts 1.3
import Common 1.0
import Common.Styles 1.0
// =============================================================================
......@@ -26,6 +27,12 @@ ColumnLayout {
elide: Text.ElideRight
font.pointSize: FormVGroupStyle.legend.pointSize
verticalAlignment: Text.AlignVCenter
TooltipArea {
delay: 0
text: parent.text
visible: parent.truncated
}
}
// ---------------------------------------------------------------------------
......
import QtQuick 2.7
import Common.Styles 1.0
// =============================================================================
MouseArea {
id: tooltipArea
property alias text: tooltip.text
property int delay: TooltipStyle.delay
property bool force: false
property var tooltipParent: parent
......@@ -23,6 +28,7 @@ MouseArea {
Tooltip {
id: tooltip
delay: tooltipArea.delay
parent: tooltipParent
visible: _visible || force
......
......@@ -111,6 +111,16 @@ TabContainer {
onClicked: SettingsModel.showTelKeypadAutomatically = !checked
}
}
FormGroup {
label: qsTr('keepCallsWindowInBackgroundLabel')
Switch {
checked: SettingsModel.keepCallsWindowInBackground
onClicked: SettingsModel.keepCallsWindowInBackground = !checked
}
}
}
FormLine {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment