Commit bd4b18d2 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(ui/views/App/Calls/Incall): all logic functions are now in a specific file

parent 176e3d1a
# See: https://wiki.qt.io/Qml_Styling # See: https://wiki.qt.io/Qml_Styling
module Linphone.Style module Linphone.Styles
# Components styles ------------------------------------------------------------ # Components styles ------------------------------------------------------------
......
...@@ -8,6 +8,14 @@ ...@@ -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 () { function handleVideoRequested () {
var call = incall.call var call = incall.call
var dialog var dialog
...@@ -30,6 +38,7 @@ function handleVideoRequested () { ...@@ -30,6 +38,7 @@ function handleVideoRequested () {
call.statusChanged.connect(endedHandler) call.statusChanged.connect(endedHandler)
// Ask video to user.
dialog = Utils.openConfirmDialog(window, { dialog = Utils.openConfirmDialog(window, {
descriptionText: qsTr('acceptVideoDescription'), descriptionText: qsTr('acceptVideoDescription'),
exitHandler: function (status) { exitHandler: function (status) {
...@@ -48,3 +57,25 @@ function handleVideoRequested () { ...@@ -48,3 +57,25 @@ function handleVideoRequested () {
title: qsTr('acceptVideoTitle') 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
)
}
...@@ -18,6 +18,7 @@ Rectangle { ...@@ -18,6 +18,7 @@ Rectangle {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Used by `IncallFullscreenWindow.qml`.
readonly property bool cameraActivated: readonly property bool cameraActivated:
cameraLoader.status !== Loader.Null || cameraLoader.status !== Loader.Null ||
cameraPreviewLoader.status !== Loader.Null cameraPreviewLoader.status !== Loader.Null
...@@ -29,21 +30,6 @@ Rectangle { ...@@ -29,21 +30,6 @@ Rectangle {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function _showFullscreen () {
if (_fullscreen) {
return
}
_fullscreen = Utils.openWindow('IncallFullscreenWindow', incall, {
properties: {
call: incall.call,
callsWindow: incall
}
})
}
// ---------------------------------------------------------------------------
color: CallStyle.backgroundColor color: CallStyle.backgroundColor
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
...@@ -89,14 +75,7 @@ Rectangle { ...@@ -89,14 +75,7 @@ Rectangle {
running: true running: true
triggeredOnStart: true triggeredOnStart: true
onTriggered: { onTriggered: Logic.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
)
}
} }
} }
...@@ -144,7 +123,7 @@ Rectangle { ...@@ -144,7 +123,7 @@ Rectangle {
icon: 'fullscreen' icon: 'fullscreen'
visible: call.videoEnabled visible: call.videoEnabled
onClicked: _showFullscreen() onClicked: Logic.showFullscreen()
} }
} }
} }
...@@ -158,13 +137,13 @@ Rectangle { ...@@ -158,13 +137,13 @@ Rectangle {
font.pointSize: CallStyle.header.elapsedTime.fontSize font.pointSize: CallStyle.header.elapsedTime.fontSize
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
Component.onCompleted: { Timer {
var updateDuration = function () { interval: 1000
text = Utils.formatElapsedTime(call.duration) repeat: true
Utils.setTimeout(elapsedTime, 1000, updateDuration) running: true
} triggeredOnStart: true
updateDuration() onTriggered: elapsedTime.text = Utils.formatElapsedTime(call.duration)
} }
} }
...@@ -183,17 +162,6 @@ Rectangle { ...@@ -183,17 +162,6 @@ Rectangle {
id: avatar id: avatar
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 backgroundColor: CallStyle.container.avatar.backgroundColor
foregroundColor: call.status === CallModel.CallStatusPaused foregroundColor: call.status === CallModel.CallStatusPaused
? CallStyle.container.pause.color ? CallStyle.container.pause.color
...@@ -201,7 +169,7 @@ Rectangle { ...@@ -201,7 +169,7 @@ Rectangle {
image: _contactObserver.contact && _contactObserver.contact.vcard.avatar image: _contactObserver.contact && _contactObserver.contact.vcard.avatar
username: contactDescription.username username: contactDescription.username
height: _computeAvatarSize() height: Logic.computeAvatarSize(CallStyle.container.avatar.maxSize)
width: height width: height
Text { Text {
......
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