From 1f2fb48e46edacf8981b0253d2f3f6bc4f5efd57 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Fri, 20 Jan 2017 16:08:12 +0100 Subject: [PATCH] feat(app): calls in progress (unstable, crash) --- tests/assets/languages/en.ts | 22 ---- tests/assets/languages/fr.ts | 8 +- tests/resources.qrc | 3 +- tests/src/app/App.cpp | 2 +- tests/src/components/call/CallModel.cpp | 10 +- tests/src/components/call/CallModel.hpp | 7 +- tests/ui/modules/Linphone/Calls/Calls.qml | 22 ++-- .../views/App/Calls/AbstractStartingCall.qml | 61 ++++------ .../App/Calls/{Calls.qml => CallsWindow.qml} | 105 ++++++++++++++---- tests/ui/views/App/Calls/Incall.qml | 5 +- tests/ui/views/App/Calls/IncomingCall.qml | 6 +- tests/ui/views/App/Calls/OutgoingCall.qml | 22 ++-- .../App/Styles/Calls/CallsWindowStyle.qml | 22 ++++ .../App/Styles/Calls/StartingCallStyle.qml | 5 - tests/ui/views/App/Styles/qmldir | 3 +- 15 files changed, 172 insertions(+), 131 deletions(-) rename tests/ui/views/App/Calls/{Calls.qml => CallsWindow.qml} (50%) create mode 100644 tests/ui/views/App/Styles/Calls/CallsWindowStyle.qml diff --git a/tests/assets/languages/en.ts b/tests/assets/languages/en.ts index ae4ec4710..873bef5f4 100644 --- a/tests/assets/languages/en.ts +++ b/tests/assets/languages/en.ts @@ -357,17 +357,6 @@ Server url not configured. Display tooltips to discover Linphone Desktop - - IncomingCall - - incomingVideoCall - - - - incomingAudioCall - - - MainWindow @@ -453,17 +442,6 @@ Server url not configured. CANCEL - - OutgoingCall - - outgoingVideoCall - - - - outgoingAudioCall - - - PresenceString diff --git a/tests/assets/languages/fr.ts b/tests/assets/languages/fr.ts index 6b954c919..1047a8058 100644 --- a/tests/assets/languages/fr.ts +++ b/tests/assets/languages/fr.ts @@ -349,11 +349,11 @@ Url du serveur non configurée. IncomingCall incomingVideoCall - APPEL VIDEO ENTRANT + APPEL VIDEO ENTRANT incomingAudioCall - APPEL AUDIO ENTRANT + APPEL AUDIO ENTRANT @@ -445,11 +445,11 @@ Url du serveur non configurée. OutgoingCall outgoingVideoCall - APPEL VIDEO SORTANT + APPEL VIDEO SORTANT outgoingAudioCall - APPEL AUDIO SORTANT + APPEL AUDIO SORTANT diff --git a/tests/resources.qrc b/tests/resources.qrc index e44b070ef..3ecda11f3 100644 --- a/tests/resources.qrc +++ b/tests/resources.qrc @@ -250,7 +250,7 @@ ui/scripts/Utils/uri-tools.js ui/scripts/Utils/utils.js ui/views/App/Calls/AbstractStartingCall.qml - ui/views/App/Calls/Calls.qml + ui/views/App/Calls/CallsWindow.qml ui/views/App/Calls/Incall.qml ui/views/App/Calls/IncomingCall.qml ui/views/App/Calls/OutgoingCall.qml @@ -261,6 +261,7 @@ ui/views/App/MainWindow/MainWindow.qml ui/views/App/ManageAccounts.qml ui/views/App/qmldir + ui/views/App/Styles/Calls/CallsWindowStyle.qml ui/views/App/Styles/Calls/StartingCallStyle.qml ui/views/App/Styles/MainWindow/ContactEditStyle.qml ui/views/App/Styles/MainWindow/ContactsStyle.qml diff --git a/tests/src/app/App.cpp b/tests/src/app/App.cpp index 62a00d9bd..5bf01d238 100644 --- a/tests/src/app/App.cpp +++ b/tests/src/app/App.cpp @@ -21,7 +21,7 @@ // The two main windows of Linphone desktop. #define QML_VIEW_MAIN_WINDOW "qrc:/ui/views/App/MainWindow/MainWindow.qml" -#define QML_VIEW_CALL_WINDOW "qrc:/ui/views/App/Calls/Calls.qml" +#define QML_VIEW_CALL_WINDOW "qrc:/ui/views/App/Calls/CallsWindow.qml" // ============================================================================= diff --git a/tests/src/components/call/CallModel.cpp b/tests/src/components/call/CallModel.cpp index 28d8dfc84..7546e9443 100644 --- a/tests/src/components/call/CallModel.cpp +++ b/tests/src/components/call/CallModel.cpp @@ -41,15 +41,19 @@ CallModel::CallModel (shared_ptr linphone_call) { // ----------------------------------------------------------------------------- -void CallModel::acceptAudioCall () { +void CallModel::accept () { CoreManager::getInstance()->getCore()->acceptCall(m_linphone_call); } -void CallModel::terminateCall () { +void CallModel::acceptWithVideo () { + // TODO +} + +void CallModel::terminate () { CoreManager::getInstance()->getCore()->terminateCall(m_linphone_call); } -void CallModel::transferCall () { +void CallModel::transfer () { // TODO } diff --git a/tests/src/components/call/CallModel.hpp b/tests/src/components/call/CallModel.hpp index 58893923c..9f98cd63c 100644 --- a/tests/src/components/call/CallModel.hpp +++ b/tests/src/components/call/CallModel.hpp @@ -30,9 +30,10 @@ public: CallModel (std::shared_ptr linphone_call); ~CallModel () = default; - Q_INVOKABLE void acceptAudioCall (); - Q_INVOKABLE void terminateCall (); - Q_INVOKABLE void transferCall (); + Q_INVOKABLE void accept (); + Q_INVOKABLE void acceptWithVideo (); + Q_INVOKABLE void terminate (); + Q_INVOKABLE void transfer (); signals: void statusChanged (CallStatus status); diff --git a/tests/ui/modules/Linphone/Calls/Calls.qml b/tests/ui/modules/Linphone/Calls/Calls.qml index faf53ad86..6a37e87ff 100644 --- a/tests/ui/modules/Linphone/Calls/Calls.qml +++ b/tests/ui/modules/Linphone/Calls/Calls.qml @@ -11,14 +11,12 @@ ListView { // --------------------------------------------------------------------------- + readonly property var selectedCall: currentIndex >= 0 ? model.data(model.index(currentIndex, 0)) : null + property var _mapStatusToParams // --------------------------------------------------------------------------- - signal entrySelected (var entry) - - // --------------------------------------------------------------------------- - function _getSignIcon (call) { if (call) { return 'call_sign_' + _mapStatusToParams[call.status].string @@ -50,10 +48,10 @@ ListView { handler: (function (call) { call.pausedByUser = false }) }, { name: qsTr('transferCall'), - handler: (function (call) { call.transferCall() }) + handler: (function (call) { call.transfer() }) }, { name: qsTr('terminateCall'), - handler: (function (call) { call.terminateCall() }) + handler: (function (call) { call.terminate() }) }], component: callActions, string: 'connected' @@ -66,13 +64,13 @@ ListView { _mapStatusToParams[CallModel.CallStatusIncoming] = { actions: [{ name: qsTr('acceptAudioCall'), - handler: (function (call) { call.acceptAudioCall() }) + handler: (function (call) { call.accept() }) }, { name: qsTr('acceptVideoCall'), - handler: (function (call) { call.acceptVideoCall() }) + handler: (function (call) { call.acceptWithVideo() }) }, { name: qsTr('terminateCall'), - handler: (function (call) { call.terminateCall() }) + handler: (function (call) { call.terminate() }) }], component: callActions, string: 'incoming' @@ -80,7 +78,7 @@ ListView { _mapStatusToParams[CallModel.CallStatusOutgoing] = { component: callAction, - handler: (function (call) { call.terminateCall() }), + handler: (function (call) { call.terminate() }), icon: 'hangup', string: 'outgoing' } @@ -91,10 +89,10 @@ ListView { handler: (function (call) { call.pausedByUser = true }) }, { name: qsTr('transferCall'), - handler: (function (call) { call.transferCall() }) + handler: (function (call) { call.transfer() }) }, { name: qsTr('terminateCall'), - handler: (function (call) { call.terminateCall() }) + handler: (function (call) { call.terminate() }) }], component: callActions, string: 'paused' diff --git a/tests/ui/views/App/Calls/AbstractStartingCall.qml b/tests/ui/views/App/Calls/AbstractStartingCall.qml index 86f4a9dab..f18641e90 100644 --- a/tests/ui/views/App/Calls/AbstractStartingCall.qml +++ b/tests/ui/views/App/Calls/AbstractStartingCall.qml @@ -7,22 +7,19 @@ import LinphoneUtils 1.0 import App.Styles 1.0 -// =================================================================== +// ============================================================================= Rectangle { id: abstractCall + // --------------------------------------------------------------------------- + + property var call + default property alias _actionArea: actionArea.data - property alias callTypeLabel: callType.text - property bool isOutgoing: false - property bool isVideoCall: false - property string sipAddress + property var _contact: SipAddressesModel.mapSipAddressToContact(call.sipAddress) - property var _contact: SipAddressesModel.mapSipAddressToContact( - sipAddress - ) || sipAddress - - // ----------------------------------------------------------------- + // --------------------------------------------------------------------------- color: StartingCallStyle.backgroundColor @@ -34,47 +31,33 @@ Rectangle { spacing: 0 - // --------------------------------------------------------------- - // Call type. - // --------------------------------------------------------------- + // ------------------------------------------------------------------------- + // Contact & Call type (animation). + // ------------------------------------------------------------------------- Column { Layout.fillWidth: true spacing: StartingCallStyle.header.spacing - Text { - id: callType - - color: StartingCallStyle.callType.color - - font { - bold: true - pointSize: StartingCallStyle.callType.fontSize - } - - horizontalAlignment: Text.AlignHCenter - width: parent.width - } - - CaterpillarAnimation { - anchors.horizontalCenter: parent.horizontalCenter - visible: abstractCall.isOutgoing - } - ContactDescription { id: contactDescription height: StartingCallStyle.contactDescriptionHeight horizontalTextAlignment: Text.AlignHCenter - sipAddress: abstractCall.sipAddress - username: LinphoneUtils.getContactUsername(_contact) + sipAddress: call.sipAddress + username: LinphoneUtils.getContactUsername(_contact || call.sipAddress) width: parent.width } + + CaterpillarAnimation { + anchors.horizontalCenter: parent.horizontalCenter + visible: call.isOutgoing + } } - // --------------------------------------------------------------- + // ------------------------------------------------------------------------- // Contact visual. - // --------------------------------------------------------------- + // ------------------------------------------------------------------------- Item { id: container @@ -98,7 +81,7 @@ Rectangle { anchors.centerIn: parent backgroundColor: StartingCallStyle.avatar.backgroundColor - image: _contact.avatar + image: _contact && _contact.avatar username: contactDescription.username height: _computeAvatarSize() @@ -106,9 +89,9 @@ Rectangle { } } - // --------------------------------------------------------------- + // ------------------------------------------------------------------------- // Buttons. - // --------------------------------------------------------------- + // ------------------------------------------------------------------------- Item { id: actionArea diff --git a/tests/ui/views/App/Calls/Calls.qml b/tests/ui/views/App/Calls/CallsWindow.qml similarity index 50% rename from tests/ui/views/App/Calls/Calls.qml rename to tests/ui/views/App/Calls/CallsWindow.qml index 58f31cd1e..f69b25a32 100644 --- a/tests/ui/views/App/Calls/Calls.qml +++ b/tests/ui/views/App/Calls/CallsWindow.qml @@ -1,6 +1,5 @@ import QtGraphicalEffects 1.0 import QtQuick 2.7 -import QtQuick.Controls 2.0 import QtQuick.Layouts 1.3 import QtQuick.Window 2.2 @@ -16,6 +15,18 @@ Window { // --------------------------------------------------------------------------- + readonly property var call: { + console.log('hihi') + return calls.selectedCall + } + readonly property var sipAddress: { + if (call) { + return call.sipAddress + } + } + + // --------------------------------------------------------------------------- + function launchAudioCall (sipAddress) { window.show() @@ -28,8 +39,9 @@ Window { // --------------------------------------------------------------------------- - minimumHeight: 480 - minimumWidth: 960 + minimumHeight: CallsWindowStyle.minimumHeight + minimumWidth: CallsWindowStyle.minimumWidth + title: CallsWindowStyle.title Paned { anchors.fill: parent @@ -37,13 +49,13 @@ Window { maximumLeftLimit: 250 minimumLeftLimit: 110 - // --------------------------------------------------------------- + // ------------------------------------------------------------------------- // Calls list. - // --------------------------------------------------------------- + // ------------------------------------------------------------------------- childA: Rectangle { anchors.fill: parent - color: '#FFFFFF' + color: CallsWindowStyle.callsList.color ColumnLayout { anchors.fill: parent @@ -51,7 +63,7 @@ Window { Item { Layout.fillWidth: true - Layout.preferredHeight: 60 + Layout.preferredHeight: CallsWindowStyle.callsList.header.height LinearGradient { anchors.fill: parent @@ -60,8 +72,8 @@ Window { end: Qt.point(0, height) gradient: Gradient { - GradientStop { position: 0.0; color: '#FFFFFF' } - GradientStop { position: 1.0; color: '#E3E3E3' } + GradientStop { position: 0.0; color: CallsWindowStyle.callsList.header.color1 } + GradientStop { position: 1.0; color: CallsWindowStyle.callsList.header.color2 } } } @@ -85,6 +97,8 @@ Window { } Calls { + id: calls + Layout.fillHeight: true Layout.fillWidth: true @@ -93,9 +107,9 @@ Window { } } - // --------------------------------------------------------------- + // ------------------------------------------------------------------------- // Content. - // --------------------------------------------------------------- + // ------------------------------------------------------------------------- childB: Paned { anchors.fill: parent @@ -105,20 +119,67 @@ Window { minimumRightLimit: 300 resizeAInPriority: true - // Call. - childA: Incall { - anchors.fill: parent - sipAddress: 'sip:erwan.croze@sip.linphone.org' - isVideoCall: true + // ----------------------------------------------------------------------- + + Component { + id: incomingCall + + IncomingCall { + anchors.fill: parent + call: window.call + } } - // Chat. - childB: Chat { - anchors.fill: parent - proxyModel: ChatProxyModel { - id: chatProxyModel + Component { + id: outgoingCall - sipAddress: 'sip:erwan.croze@sip.linphone.org' + OutgoingCall { + anchors.fill: parent + call: window.call + } + } + + Component { + id: incall + + Incall { + anchors.fill: parent + call: window.call + } + } + + // ----------------------------------------------------------------------- + + childA: Loader { + active: Boolean(window.call) + anchors.fill: parent + sourceComponent: { + var call = window.call + if (!call) { + return null + } + return incomingCall + var status = call.status + if (status === CallModel.CallStatusIncoming) { + return incomingCall + } + if (status === CallModel.CallStatusOutgoing) { + return outgoingCall + } + + return incall + } + } + + childB: Loader { + active: Boolean(window.call) + anchors.fill: parent + + sourceComponent: Chat { + anchors.fill: parent + proxyModel: ChatProxyModel { + sipAddress: window.sipAddress || '' + } } } } diff --git a/tests/ui/views/App/Calls/Incall.qml b/tests/ui/views/App/Calls/Incall.qml index 89086593e..7662f03c0 100644 --- a/tests/ui/views/App/Calls/Incall.qml +++ b/tests/ui/views/App/Calls/Incall.qml @@ -13,8 +13,9 @@ import App.Styles 1.0 Rectangle { id: call - property bool isVideoCall: false - property string sipAddress + // --------------------------------------------------------------------------- + + property var call property var _contactObserver: SipAddressesModel.getContactObserver(sipAddress) diff --git a/tests/ui/views/App/Calls/IncomingCall.qml b/tests/ui/views/App/Calls/IncomingCall.qml index ec4ec858d..e0fa0e67d 100644 --- a/tests/ui/views/App/Calls/IncomingCall.qml +++ b/tests/ui/views/App/Calls/IncomingCall.qml @@ -5,10 +5,6 @@ import App.Styles 1.0 // =================================================================== AbstractStartingCall { - callTypeLabel: isVideoCall - ? qsTr('incomingVideoCall') - : qsTr('incomingAudioCall') - ActionBar { anchors.centerIn: parent iconSize: StartingCallStyle.iconSize @@ -32,6 +28,8 @@ AbstractStartingCall { ActionButton { icon: 'hangup' + + onClicked: call.terminate() } } } diff --git a/tests/ui/views/App/Calls/OutgoingCall.qml b/tests/ui/views/App/Calls/OutgoingCall.qml index b89f39f67..4604b696f 100644 --- a/tests/ui/views/App/Calls/OutgoingCall.qml +++ b/tests/ui/views/App/Calls/OutgoingCall.qml @@ -6,17 +6,12 @@ import Common.Styles 1.0 import App.Styles 1.0 -// =================================================================== +// ============================================================================= AbstractStartingCall { - isOutgoing: true - callTypeLabel: isVideoCall - ? qsTr('outgoingVideoCall') - : qsTr('outgoingAudioCall') - GridLayout { rowSpacing: ActionBarStyle.spacing - columns: parent.width < 415 && isVideoCall ? 1 : 2 + columns: parent.width < 415 && call.isVideoCall ? 1 : 2 anchors { left: parent.left @@ -25,10 +20,11 @@ AbstractStartingCall { } ActionSwitch { + enabled: !call.microMuted icon: 'micro' iconSize: StartingCallStyle.iconSize - onClicked: enabled = !enabled + onClicked: call.microMuted = !enabled } ActionSwitch { @@ -39,24 +35,26 @@ AbstractStartingCall { } } - Rectangle { + Item { anchors.centerIn: parent - color: 'red' height: StartingCallStyle.userVideo.height - visible: isVideoCall width: StartingCallStyle.userVideo.width + + visible: isVideoCall } ActionBar { anchors { - verticalCenter: parent.verticalCenter right: parent.right rightMargin: StartingCallStyle.rightButtonsGroupMargin + verticalCenter: parent.verticalCenter } iconSize: StartingCallStyle.iconSize ActionButton { icon: 'hangup' + + onClicked: call.terminate() } } } diff --git a/tests/ui/views/App/Styles/Calls/CallsWindowStyle.qml b/tests/ui/views/App/Styles/Calls/CallsWindowStyle.qml new file mode 100644 index 000000000..85431aa9e --- /dev/null +++ b/tests/ui/views/App/Styles/Calls/CallsWindowStyle.qml @@ -0,0 +1,22 @@ +pragma Singleton +import QtQuick 2.7 + +import Common 1.0 + +// ============================================================================= + +QtObject { + property int minimumHeight: 480 + property int minimumWidth: 960 + property string title: 'Linphone' + + property QtObject callsList: QtObject { + property color color: Colors.k + + property QtObject header: QtObject { + property int height: 60 + property color color1: Colors.k + property color color2: Colors.v + } + } +} diff --git a/tests/ui/views/App/Styles/Calls/StartingCallStyle.qml b/tests/ui/views/App/Styles/Calls/StartingCallStyle.qml index 1e1bbf00e..d21d67864 100644 --- a/tests/ui/views/App/Styles/Calls/StartingCallStyle.qml +++ b/tests/ui/views/App/Styles/Calls/StartingCallStyle.qml @@ -19,11 +19,6 @@ QtObject { property int maxSize: 300 } - property QtObject callType: QtObject { - property color color: Colors.x - property int fontSize: 17 - } - property QtObject header: QtObject { property int spacing: 10 property int topMargin: 26 diff --git a/tests/ui/views/App/Styles/qmldir b/tests/ui/views/App/Styles/qmldir index ed402eb70..f909ab6df 100644 --- a/tests/ui/views/App/Styles/qmldir +++ b/tests/ui/views/App/Styles/qmldir @@ -2,8 +2,9 @@ module App.Styles -# Views styles ------------------------------------------------------- +# Views styles ----------------------------------------------------------------- +singleton CallsWindowStyle 1.0 Calls/CallsWindowStyle.qml singleton StartingCallStyle 1.0 Calls/StartingCallStyle.qml singleton ContactEditStyle 1.0 MainWindow/ContactEditStyle.qml