From bd4b18d272e04263c01870486089000f6fbcad36 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Fri, 17 Mar 2017 14:14:05 +0100 Subject: [PATCH] feat(ui/views/App/Calls/Incall): all logic functions are now in a specific file --- .../ui/modules/Linphone/Styles/qmldir | 2 +- linphone-desktop/ui/views/App/Calls/Incall.js | 31 +++++++++++ .../ui/views/App/Calls/Incall.qml | 52 ++++--------------- 3 files changed, 42 insertions(+), 43 deletions(-) diff --git a/linphone-desktop/ui/modules/Linphone/Styles/qmldir b/linphone-desktop/ui/modules/Linphone/Styles/qmldir index 0b189f255..cde60fa38 100644 --- a/linphone-desktop/ui/modules/Linphone/Styles/qmldir +++ b/linphone-desktop/ui/modules/Linphone/Styles/qmldir @@ -1,6 +1,6 @@ # See: https://wiki.qt.io/Qml_Styling -module Linphone.Style +module Linphone.Styles # Components styles ------------------------------------------------------------ diff --git a/linphone-desktop/ui/views/App/Calls/Incall.js b/linphone-desktop/ui/views/App/Calls/Incall.js index c6df8d03f..f7f6eaa3d 100644 --- a/linphone-desktop/ui/views/App/Calls/Incall.js +++ b/linphone-desktop/ui/views/App/Calls/Incall.js @@ -8,6 +8,14 @@ // ============================================================================= +function computeAvatarSize (maxSize) { + var height = container.height + var width = container.width + + var size = height < maxSize && height > 0 ? height : maxSize + return size < width ? size : width +} + function handleVideoRequested () { var call = incall.call var dialog @@ -30,6 +38,7 @@ function handleVideoRequested () { call.statusChanged.connect(endedHandler) + // Ask video to user. dialog = Utils.openConfirmDialog(window, { descriptionText: qsTr('acceptVideoDescription'), exitHandler: function (status) { @@ -48,3 +57,25 @@ function handleVideoRequested () { title: qsTr('acceptVideoTitle') }) } + +function showFullScreen () { + if (incall._fullscreen) { + return + } + + incall._fullscreen = Utils.openWindow('IncallFullscreenWindow', incall, { + properties: { + call: incall.call, + callsWindow: incall + } + }) +} + +function updateCallQualityIcon () { + var quality = call.quality + callQuality.icon = 'call_quality_' + ( + // Note: `quality` is in the [0, 5] interval. + // It's necessary to map in the `call_quality_` interval. ([0, 3]) + quality >= 0 ? Math.round(quality / (5 / 3)) : 0 + ) +} diff --git a/linphone-desktop/ui/views/App/Calls/Incall.qml b/linphone-desktop/ui/views/App/Calls/Incall.qml index 2a38f7bc0..898e9bb54 100644 --- a/linphone-desktop/ui/views/App/Calls/Incall.qml +++ b/linphone-desktop/ui/views/App/Calls/Incall.qml @@ -18,6 +18,7 @@ Rectangle { // --------------------------------------------------------------------------- + // Used by `IncallFullscreenWindow.qml`. readonly property bool cameraActivated: cameraLoader.status !== Loader.Null || cameraPreviewLoader.status !== Loader.Null @@ -29,21 +30,6 @@ Rectangle { // --------------------------------------------------------------------------- - function _showFullscreen () { - if (_fullscreen) { - return - } - - _fullscreen = Utils.openWindow('IncallFullscreenWindow', incall, { - properties: { - call: incall.call, - callsWindow: incall - } - }) - } - - // --------------------------------------------------------------------------- - color: CallStyle.backgroundColor // --------------------------------------------------------------------------- @@ -89,14 +75,7 @@ Rectangle { running: true triggeredOnStart: true - onTriggered: { - var quality = call.quality - callQuality.icon = 'call_quality_' + ( - // Note: `quality` is in the [0, 5] interval. - // It's necessary to map in the `call_quality_` interval. ([0, 3]) - quality >= 0 ? Math.round(quality / (5 / 3)) : 0 - ) - } + onTriggered: Logic.updateCallQualityIcon() } } @@ -144,7 +123,7 @@ Rectangle { icon: 'fullscreen' visible: call.videoEnabled - onClicked: _showFullscreen() + onClicked: Logic.showFullscreen() } } } @@ -158,13 +137,13 @@ Rectangle { font.pointSize: CallStyle.header.elapsedTime.fontSize horizontalAlignment: Text.AlignHCenter - Component.onCompleted: { - var updateDuration = function () { - text = Utils.formatElapsedTime(call.duration) - Utils.setTimeout(elapsedTime, 1000, updateDuration) - } + Timer { + interval: 1000 + repeat: true + running: true + triggeredOnStart: true - updateDuration() + onTriggered: elapsedTime.text = Utils.formatElapsedTime(call.duration) } } @@ -183,17 +162,6 @@ Rectangle { id: avatar Avatar { - function _computeAvatarSize () { - var height = container.height - var width = container.width - - var size = height < CallStyle.container.avatar.maxSize && height > 0 - ? height - : CallStyle.container.avatar.maxSize - - return size < width ? size : width - } - backgroundColor: CallStyle.container.avatar.backgroundColor foregroundColor: call.status === CallModel.CallStatusPaused ? CallStyle.container.pause.color @@ -201,7 +169,7 @@ Rectangle { image: _contactObserver.contact && _contactObserver.contact.vcard.avatar username: contactDescription.username - height: _computeAvatarSize() + height: Logic.computeAvatarSize(CallStyle.container.avatar.maxSize) width: height Text {