From 639fabf8167ed7dcae684857cf286177bf75bf30 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Wed, 25 Jan 2017 13:39:01 +0100 Subject: [PATCH] feat(app): many fixes on calls (pause, buttons, actions...) --- prepare.conf | 1 - tests/assets/images/generic_error_hovered.svg | 14 ++ tests/assets/images/generic_error_normal.svg | 14 ++ tests/assets/images/generic_error_pressed.svg | 14 ++ tests/resources.qrc | 3 + tests/src/components/call/CallModel.cpp | 40 +++-- tests/src/components/call/CallModel.hpp | 4 +- tests/src/components/calls/CallsListModel.cpp | 12 +- tests/ui/modules/Common/Colors.qml | 1 + tests/ui/modules/Linphone/Calls/Calls.qml | 141 ++++++++++-------- tests/ui/modules/Linphone/Contact/Avatar.qml | 2 + tests/ui/views/App/Calls/Incall.qml | 18 +++ tests/ui/views/App/Styles/Calls/CallStyle.qml | 9 ++ 13 files changed, 191 insertions(+), 82 deletions(-) create mode 100644 tests/assets/images/generic_error_hovered.svg create mode 100644 tests/assets/images/generic_error_normal.svg create mode 100644 tests/assets/images/generic_error_pressed.svg diff --git a/prepare.conf b/prepare.conf index 5f9935b69..a4eecc31f 100644 --- a/prepare.conf +++ b/prepare.conf @@ -1,4 +1,3 @@ -DENABLE_CXX_WRAPPER=YES --DENABLE_GTK_UI=NO -DENABLE_JPEG=NO diff --git a/tests/assets/images/generic_error_hovered.svg b/tests/assets/images/generic_error_hovered.svg new file mode 100644 index 000000000..1a9838722 --- /dev/null +++ b/tests/assets/images/generic_error_hovered.svg @@ -0,0 +1,14 @@ + + + + chat_error + Created with Sketch. + + + + + + + + + \ No newline at end of file diff --git a/tests/assets/images/generic_error_normal.svg b/tests/assets/images/generic_error_normal.svg new file mode 100644 index 000000000..1a9838722 --- /dev/null +++ b/tests/assets/images/generic_error_normal.svg @@ -0,0 +1,14 @@ + + + + chat_error + Created with Sketch. + + + + + + + + + \ No newline at end of file diff --git a/tests/assets/images/generic_error_pressed.svg b/tests/assets/images/generic_error_pressed.svg new file mode 100644 index 000000000..1a9838722 --- /dev/null +++ b/tests/assets/images/generic_error_pressed.svg @@ -0,0 +1,14 @@ + + + + chat_error + Created with Sketch. + + + + + + + + + \ No newline at end of file diff --git a/tests/resources.qrc b/tests/resources.qrc index 908f43ee4..8eb83eb52 100644 --- a/tests/resources.qrc +++ b/tests/resources.qrc @@ -80,6 +80,9 @@ assets/images/fullscreen_hovered.svg assets/images/fullscreen_normal.svg assets/images/fullscreen_pressed.svg + assets/images/generic_error_hovered.svg + assets/images/generic_error_normal.svg + assets/images/generic_error_pressed.svg assets/images/generic_error.svg assets/images/hangup_hovered.svg assets/images/hangup_normal.svg diff --git a/tests/src/components/call/CallModel.cpp b/tests/src/components/call/CallModel.cpp index 419ddc6b7..237b1289d 100644 --- a/tests/src/components/call/CallModel.cpp +++ b/tests/src/components/call/CallModel.cpp @@ -18,16 +18,22 @@ CallModel::CallModel (shared_ptr linphone_call) { case linphone::CallStateConnected: case linphone::CallStateEnd: case linphone::CallStateError: - case linphone::CallStatePaused: case linphone::CallStateRefered: case linphone::CallStateReleased: case linphone::CallStateStreamsRunning: - m_linphone_call_status = state; + m_paused_by_remote = false; break; case linphone::CallStatePausedByRemote: - if (m_linphone_call_status != linphone::CallStatePaused) - m_linphone_call_status = state; + m_paused_by_remote = true; + break; + + case linphone::CallStatePausing: + m_paused_by_user = true; + break; + + case linphone::CallStateResuming: + m_paused_by_user = false; break; default: @@ -64,7 +70,7 @@ QString CallModel::getSipAddress () const { } CallModel::CallStatus CallModel::getStatus () const { - switch (m_linphone_call_status) { + switch (m_linphone_call->getState()) { case linphone::CallStateConnected: case linphone::CallStateStreamsRunning: return CallStatusConnected; @@ -77,9 +83,23 @@ CallModel::CallStatus CallModel::getStatus () const { case linphone::CallStatePaused: case linphone::CallStatePausedByRemote: + case linphone::CallStatePausing: + case linphone::CallStateResuming: return CallStatusPaused; - default: + case linphone::CallStateUpdating: + case linphone::CallStateUpdatedByRemote: + return m_paused_by_remote ? CallStatusPaused : CallStatusConnected; + + case linphone::CallStateEarlyUpdatedByRemote: + case linphone::CallStateEarlyUpdating: + case linphone::CallStateIdle: + case linphone::CallStateIncomingEarlyMedia: + case linphone::CallStateIncomingReceived: + case linphone::CallStateOutgoingEarlyMedia: + case linphone::CallStateOutgoingInit: + case linphone::CallStateOutgoingProgress: + case linphone::CallStateOutgoingRinging: break; } @@ -111,20 +131,18 @@ void CallModel::setMicroMuted (bool status) { } bool CallModel::getPausedByUser () const { - return m_linphone_call_status == linphone::CallStatePaused; + return m_paused_by_user; } void CallModel::setPausedByUser (bool status) { - bool paused = getPausedByUser(); - if (status) { - if (!paused) + if (!m_paused_by_user) CoreManager::getInstance()->getCore()->pauseCall(m_linphone_call); return; } - if (paused) + if (m_paused_by_user) CoreManager::getInstance()->getCore()->resumeCall(m_linphone_call); } diff --git a/tests/src/components/call/CallModel.hpp b/tests/src/components/call/CallModel.hpp index 2cbcd4000..caae3537a 100644 --- a/tests/src/components/call/CallModel.hpp +++ b/tests/src/components/call/CallModel.hpp @@ -69,8 +69,8 @@ private: void setVideoOutputEnabled (bool status); bool m_micro_muted = false; - - linphone::CallState m_linphone_call_status = linphone::CallStateIdle; + bool m_paused_by_remote = false; + bool m_paused_by_user = false; std::shared_ptr m_linphone_call; }; diff --git a/tests/src/components/calls/CallsListModel.cpp b/tests/src/components/calls/CallsListModel.cpp index aa4f489cc..23cebb2b5 100644 --- a/tests/src/components/calls/CallsListModel.cpp +++ b/tests/src/components/calls/CallsListModel.cpp @@ -76,8 +76,16 @@ void CallsListModel::launchAudioCall (const QString &sip_uri) const { void CallsListModel::launchVideoCall (const QString &sip_uri) const { shared_ptr core = CoreManager::getInstance()->getCore(); - // TODO: Deal with videos. - core->inviteAddress(core->interpretUrl(::Utils::qStringToLinphoneString(sip_uri))); + shared_ptr address = core->interpretUrl(::Utils::qStringToLinphoneString(sip_uri)); + + if (!address) + return; + + shared_ptr params = core->createCallParams(nullptr); + params->enableEarlyMediaSending(true); + params->enableVideo(true); + + core->inviteAddressWithParams(address, params); } // ----------------------------------------------------------------------------- diff --git a/tests/ui/modules/Common/Colors.qml b/tests/ui/modules/Common/Colors.qml index e0810f722..bf36256b7 100644 --- a/tests/ui/modules/Common/Colors.qml +++ b/tests/ui/modules/Common/Colors.qml @@ -13,6 +13,7 @@ QtObject { property color g: '#6B7A86' property color g10: '#1A6B7A86' property color g20: '#336B7A86' + property color g90: '#E66B7A86' property color h: '#687680' property color i: '#FE5E00' property color i30: '#4DFE5E00' diff --git a/tests/ui/modules/Linphone/Calls/Calls.qml b/tests/ui/modules/Linphone/Calls/Calls.qml index 50a31e615..8ade6fc4a 100644 --- a/tests/ui/modules/Linphone/Calls/Calls.qml +++ b/tests/ui/modules/Linphone/Calls/Calls.qml @@ -17,17 +17,9 @@ ListView { // --------------------------------------------------------------------------- - function _getSignIcon (call) { - if (call) { - return 'call_sign_' + _mapStatusToParams[call.status].string - } - - return '' - } - function _getParams (call) { if (call) { - return _mapStatusToParams[call.status] + return _mapStatusToParams[call.status](call) } } @@ -42,63 +34,74 @@ ListView { Component.onCompleted: { _mapStatusToParams = {} - _mapStatusToParams[CallModel.CallStatusConnected] = { - actions: [{ - handler: (function (call) { call.pausedByUser = false }), - name: qsTr('resumeCall') - }, { - handler: (function (call) { call.transfer() }), - name: qsTr('transferCall') - }, { - handler: (function (call) { call.terminate() }), - name: qsTr('terminateCall') - }], - component: callActions, - icon: 'hangup', - string: 'connected' - } + _mapStatusToParams[CallModel.CallStatusConnected] = (function (call) { + return { + actions: [{ + handler: (function () { call.pausedByUser = true }), + name: qsTr('pauseCall') + }, { + handler: (function () { call.transfer() }), + name: qsTr('transferCall') + }, { + handler: (function () { call.terminate() }), + name: qsTr('terminateCall') + }], + component: callActions, + string: 'connected' + } + }) - _mapStatusToParams[CallModel.CallStatusEnded] = { - icon: 'hangup', - string: 'ended' - } + _mapStatusToParams[CallModel.CallStatusEnded] = (function (call) { + return { + string: 'ended' + } + }) - _mapStatusToParams[CallModel.CallStatusIncoming] = { - actions: [{ - name: qsTr('acceptAudioCall'), - handler: (function (call) { call.accept() }) - }, { - name: qsTr('acceptVideoCall'), - handler: (function (call) { call.acceptWithVideo() }) - }, { - name: qsTr('terminateCall'), - handler: (function (call) { call.terminate() }) - }], - component: callActions, - string: 'incoming' - } + _mapStatusToParams[CallModel.CallStatusIncoming] = (function (call) { + return { + actions: [{ + name: qsTr('acceptAudioCall'), + handler: (function () { call.accept() }) + }, { + name: qsTr('acceptVideoCall'), + handler: (function () { call.acceptWithVideo() }) + }, { + name: qsTr('terminateCall'), + handler: (function () { call.terminate() }) + }], + component: callActions, + string: 'incoming' + } + }) - _mapStatusToParams[CallModel.CallStatusOutgoing] = { - component: callAction, - handler: (function (call) { call.terminate() }), - icon: 'hangup', - string: 'outgoing' - } + _mapStatusToParams[CallModel.CallStatusOutgoing] = (function (call) { + return { + component: callAction, + handler: (function () { call.terminate() }), + icon: 'hangup', + string: 'outgoing' + } + }) - _mapStatusToParams[CallModel.CallStatusPaused] = { - actions: [{ - handler: (function (call) { call.pausedByUser = true }), - name: qsTr('pauseCall') - }, { - handler: (function (call) { call.transfer() }), - name: qsTr('transferCall') - }, { - handler: (function (call) { call.terminate() }), - name: qsTr('terminateCall') - }], - component: callActions, - string: 'paused' - } + _mapStatusToParams[CallModel.CallStatusPaused] = (function (call) { + return { + actions: [(call.pausedByUser ? { + handler: (function () { call.pausedByUser = false }), + name: qsTr('resumeCall') + } : { + handler: (function () { call.pausedByUser = true }), + name: qsTr('pauseCall') + }), { + handler: (function () { call.transfer() }), + name: qsTr('transferCall') + }, { + handler: (function () { call.terminate() }), + name: qsTr('terminateCall') + }], + component: callActions, + string: 'paused' + } + }) } // --------------------------------------------------------------------------- @@ -107,10 +110,10 @@ ListView { id: callAction ActionButton { - icon: params.icon + icon: params.icon || 'generic_error' iconSize: CallsStyle.entry.iconActionSize - onClicked: params.handler(call) + onClicked: params.handler() } } @@ -149,7 +152,7 @@ ListView { onClicked: { menu.hideMenu() - params.actions[index].handler(call) + params.actions[index].handler() } } } @@ -233,7 +236,11 @@ ListView { ? CallsStyle.entry.usernameColor.selected : CallsStyle.entry.usernameColor.normal - signIcon: _getSignIcon($call) + signIcon: { + var params = loader.params + return params ? 'call_sign_' + params.string : '' + } + sipAddress: $call.sipAddress width: parent.width @@ -245,6 +252,8 @@ ListView { // ------------------------------------------------------------------------- Loader { + id: loader + property int callId: index property var call: $call property var callControls: _callControls diff --git a/tests/ui/modules/Linphone/Contact/Avatar.qml b/tests/ui/modules/Linphone/Contact/Avatar.qml index 6173a272b..cf5d4544c 100644 --- a/tests/ui/modules/Linphone/Contact/Avatar.qml +++ b/tests/ui/modules/Linphone/Contact/Avatar.qml @@ -13,6 +13,7 @@ Item { property alias presenceLevel: presenceLevel.level property color backgroundColor: AvatarStyle.backgroundColor + property color foregroundColor: 'transparent' property string username property var image @@ -45,6 +46,7 @@ Item { anchors.fill: parent backgroundColor: avatar.backgroundColor + foregroundColor: avatar.foregroundColor source: avatar.image || '' } diff --git a/tests/ui/views/App/Calls/Incall.qml b/tests/ui/views/App/Calls/Incall.qml index bc2235257..76cf841f3 100644 --- a/tests/ui/views/App/Calls/Incall.qml +++ b/tests/ui/views/App/Calls/Incall.qml @@ -148,11 +148,29 @@ Rectangle { } backgroundColor: CallStyle.container.avatar.backgroundColor + foregroundColor: call.status === CallModel.CallStatusPaused + ? CallStyle.container.pause.color + : 'transparent' image: _contactObserver.contact && _contactObserver.contact.vcard.avatar username: contactDescription.username height: _computeAvatarSize() width: height + + Text { + anchors.fill: parent + color: CallStyle.container.pause.text.color + + // `|| 1` => `pointSize` must be greater than 0. + font.pointSize: (width / CallStyle.container.pause.text.fontSizeFactor) || 1 + + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + + text: '▐ ▌' + textFormat: Text.RichText + visible: call.status === CallModel.CallStatusPaused + } } } diff --git a/tests/ui/views/App/Styles/Calls/CallStyle.qml b/tests/ui/views/App/Styles/Calls/CallStyle.qml index c22a18faa..6bce6fbd4 100644 --- a/tests/ui/views/App/Styles/Calls/CallStyle.qml +++ b/tests/ui/views/App/Styles/Calls/CallStyle.qml @@ -28,6 +28,15 @@ QtObject { property color backgroundColor: Colors.w property int maxSize: 300 } + + property QtObject pause: QtObject { + property color color: Colors.g90 + + property QtObject text: QtObject { + property color color: Colors.k + property int fontSizeFactor: 10 + } + } } property QtObject header: QtObject {