From bc6a75ad4965bc17d6f0b966366d61dd4671c178 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Tue, 24 Jan 2017 10:57:48 +0100 Subject: [PATCH] fix(ui/modules/Linphone/Calls/Calls): workarounds and many fixes to avoid type errors --- tests/src/components/chat/ChatModel.cpp | 2 +- tests/ui/modules/Linphone/Calls/Calls.qml | 3 +- .../views/App/Calls/AbstractStartingCall.qml | 2 -- tests/ui/views/App/Calls/CallsWindow.qml | 29 ++++++------------- tests/ui/views/App/Calls/Incall.qml | 14 +++++---- 5 files changed, 20 insertions(+), 30 deletions(-) diff --git a/tests/src/components/chat/ChatModel.cpp b/tests/src/components/chat/ChatModel.cpp index 66d578783..de379e854 100644 --- a/tests/src/components/chat/ChatModel.cpp +++ b/tests/src/components/chat/ChatModel.cpp @@ -228,7 +228,7 @@ QString ChatModel::getSipAddress () const { } void ChatModel::setSipAddress (const QString &sip_address) { - if (sip_address == getSipAddress()) + if (sip_address == getSipAddress() || sip_address.isEmpty()) return; beginResetModel(); diff --git a/tests/ui/modules/Linphone/Calls/Calls.qml b/tests/ui/modules/Linphone/Calls/Calls.qml index 4106d83a0..5253384b1 100644 --- a/tests/ui/modules/Linphone/Calls/Calls.qml +++ b/tests/ui/modules/Linphone/Calls/Calls.qml @@ -58,6 +58,7 @@ ListView { } _mapStatusToParams[CallModel.CallStatusEnded] = { + icon: 'hangup', string: 'ended' } @@ -157,7 +158,7 @@ ListView { } // --------------------------------------------------------------------------- - // Update the current selected call and the current index. + // SmartConnect that updates the current selected call and the current index. // --------------------------------------------------------------------------- SmartConnect { diff --git a/tests/ui/views/App/Calls/AbstractStartingCall.qml b/tests/ui/views/App/Calls/AbstractStartingCall.qml index 6656e61e1..c317e19ff 100644 --- a/tests/ui/views/App/Calls/AbstractStartingCall.qml +++ b/tests/ui/views/App/Calls/AbstractStartingCall.qml @@ -10,8 +10,6 @@ import App.Styles 1.0 // ============================================================================= Rectangle { - property var call - default property alias _actionArea: actionArea.data property var _contactObserver: SipAddressesModel.getContactObserver(sipAddress) diff --git a/tests/ui/views/App/Calls/CallsWindow.qml b/tests/ui/views/App/Calls/CallsWindow.qml index bd9590594..c6cf48fbd 100644 --- a/tests/ui/views/App/Calls/CallsWindow.qml +++ b/tests/ui/views/App/Calls/CallsWindow.qml @@ -16,12 +16,10 @@ Window { // --------------------------------------------------------------------------- readonly property bool chatIsOpened: !rightPaned.isClosed() - readonly property var call: calls.selectedCall - readonly property var sipAddress: { - if (call) { - return call.sipAddress - } - } + + // `{}` is a workaround to avoid `TypeError: Cannot read property...` in `Incall` component. + property var call: calls.selectedCall || {} + property string sipAddress: call.sipAddress || '' // --------------------------------------------------------------------------- @@ -124,25 +122,19 @@ Window { Component { id: incomingCall - IncomingCall { - call: window.call - } + IncomingCall {} } Component { id: outgoingCall - OutgoingCall { - call: window.call - } + OutgoingCall {} } Component { id: incall - Incall { - call: window.call - } + Incall {} } Component { @@ -158,15 +150,13 @@ Window { // ----------------------------------------------------------------------- childA: Loader { - active: Boolean(window.call) anchors.fill: parent sourceComponent: { - var call = window.call - if (!call) { + var status = window.call.status + if (!status) { return null } - var status = call.status if (status === CallModel.CallStatusIncoming) { return incomingCall } @@ -180,7 +170,6 @@ Window { } childB: Loader { - active: Boolean(window.sipAddress) anchors.fill: parent sourceComponent: window.sipAddress ? chat : null } diff --git a/tests/ui/views/App/Calls/Incall.qml b/tests/ui/views/App/Calls/Incall.qml index f8d2af9a6..adbacff35 100644 --- a/tests/ui/views/App/Calls/Incall.qml +++ b/tests/ui/views/App/Calls/Incall.qml @@ -15,8 +15,6 @@ Rectangle { // --------------------------------------------------------------------------- - property var call - property var _contactObserver: SipAddressesModel.getContactObserver(sipAddress) // --------------------------------------------------------------------------- @@ -58,6 +56,10 @@ Rectangle { triggeredOnStart: true onTriggered: { + if (!call.getQuality) { + return + } + var quality = call.getQuality() callQuality.icon = 'call_quality_' + ( // Note: `quality` is in the [0, 5] interval. @@ -73,8 +75,8 @@ Rectangle { anchors.centerIn: parent horizontalTextAlignment: Text.AlignHCenter - sipAddress: call.sipAddress - username: LinphoneUtils.getContactUsername(_contactObserver.contact || call.sipAddress) + sipAddress: _contactObserver.sipAddress + username: LinphoneUtils.getContactUsername(_contactObserver.contact || sipAddress) height: parent.height width: parent.width - cameraActions.width - callQuality.width - CallStyle.header.contactDescription.width @@ -84,7 +86,7 @@ Rectangle { id: cameraActions anchors.right: parent.right - active: call.videoInputEnabled + active: Boolean(call.videoInputEnabled) sourceComponent: ActionBar { iconSize: CallStyle.header.iconSize @@ -203,7 +205,7 @@ Rectangle { Item { anchors.centerIn: parent height: CallStyle.actionArea.userVideo.height - visible: incall.width >= CallStyle.actionArea.lowWidth && call.videoOutputEnabled + visible: Boolean(incall.width >= CallStyle.actionArea.lowWidth && call.videoOutputEnabled) width: CallStyle.actionArea.userVideo.width }