blob: 1292f30aa5a0405477bf357c337058716c1b25a9 [file] [log] [blame]
Sébastien Blin1f915762020-08-03 13:27:42 -04001
2/*
3 * Copyright (C) 2020 by Savoir-faire Linux
4 * Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19import QtQuick 2.14
20import QtQuick.Controls 2.14
21import QtQuick.Layouts 1.14
22import QtQuick.Controls.Universal 2.12
23import net.jami.Models 1.0
24
25import "../../commoncomponents"
26
27Rectangle {
28 id: audioCallPageRect
29
30 property string contactImgSource: ""
31 property string bestName: "Best Name"
32 property string bestId: "Best Id"
33
34 property var corrspondingMessageWebView: null
35
36 signal audioCallPageBackButtonIsClicked
37
38 function updateUI(accountId, convUid) {
39 contactImgSource = "data:image/png;base64," + ClientWrapper.utilsAdaptor.getContactImageString(
40 accountId, convUid)
41 bestName = ClientWrapper.utilsAdaptor.getBestName(accountId, convUid)
42
43 var id = ClientWrapper.utilsAdaptor.getBestId(accountId, convUid)
44 bestId = (bestName !== id) ? id : ""
45 }
46
47 function setAudioCallPageCorrspondingMessageWebView(webViewId) {
48 corrspondingMessageWebView = webViewId
49 corrspondingMessageWebView.needToHideConversationInCall.disconnect(
50 closeInCallConversation)
51 corrspondingMessageWebView.needToHideConversationInCall.connect(
52 closeInCallConversation)
53 }
54
55 function closeInCallConversation() {
56 if (inAudioCallMessageWebViewStack.visible) {
57 corrspondingMessageWebView.resetMessagingHeaderBackButtonSource(
58 true)
59 corrspondingMessageWebView.setMessagingHeaderButtonsVisible(true)
60 inAudioCallMessageWebViewStack.visible = false
61 inAudioCallMessageWebViewStack.clear()
62 }
63 }
64
65 function closeContextMenuAndRelatedWindows() {
66 audioCallOverlay.closePotentialContactPicker()
67 }
68
69 anchors.fill: parent
70
71 SplitView {
72 id: mainColumnLayout
73
74 anchors.fill: parent
75
76 orientation: Qt.Vertical
77
78 handle: Rectangle {
79 implicitWidth: audioCallPageRect.width
80 implicitHeight: JamiTheme.splitViewHandlePreferedWidth
81 color: SplitHandle.pressed ? JamiTheme.pressColor : (SplitHandle.hovered ? JamiTheme.hoverColor : JamiTheme.tabbarBorderColor)
82 }
83
84 Rectangle {
85 id: audioCallPageMainRect
86
87 SplitView.preferredHeight: (audioCallPageRect.height / 3) * 2
88 SplitView.minimumHeight: audioCallPageRect.height / 2 + 20
89 SplitView.fillWidth: true
90
91 CallOverlay {
92 id: audioCallOverlay
93
94 anchors.fill: parent
95
96 Connections {
97 target: CallAdapter
98
99 function onUpdateTimeText(time) {
100 audioCallOverlay.timeText = time
101 }
102
103 function onUpdateOverlay(isPaused, isAudioOnly, isAudioMuted, isVideoMuted, isRecording, isSIP, isConferenceCall, bestName) {
104 audioCallOverlay.showOnHoldImage(isPaused)
105 audioCallPageRectCentralRect.visible = !isPaused
106 audioCallOverlay.updateButtonStatus(isPaused,
107 isAudioOnly,
108 isAudioMuted,
109 isVideoMuted,
110 isRecording, isSIP,
111 isConferenceCall)
112 audioCallOverlay.bestName = bestName
113 }
114
115 function onShowOnHoldLabel(isPaused) {
116 audioCallOverlay.showOnHoldImage(isPaused)
117 audioCallPageRectCentralRect.visible = !isPaused
118 }
119 }
120
121 onBackButtonIsClicked: {
122 if (inAudioCallMessageWebViewStack.visible) {
123 corrspondingMessageWebView.resetMessagingHeaderBackButtonSource(
124 true)
125 corrspondingMessageWebView.setMessagingHeaderButtonsVisible(
126 true)
127 inAudioCallMessageWebViewStack.visible = false
128 inAudioCallMessageWebViewStack.clear()
129 }
130 audioCallPageRect.audioCallPageBackButtonIsClicked()
131 }
132
133 onOverlayChatButtonClicked: {
134 if (inAudioCallMessageWebViewStack.visible) {
135 corrspondingMessageWebView.resetMessagingHeaderBackButtonSource(
136 true)
137 corrspondingMessageWebView.setMessagingHeaderButtonsVisible(
138 true)
139 inAudioCallMessageWebViewStack.visible = false
140 inAudioCallMessageWebViewStack.clear()
141 } else {
142 corrspondingMessageWebView.resetMessagingHeaderBackButtonSource(
143 false)
144 corrspondingMessageWebView.setMessagingHeaderButtonsVisible(
145 false)
146 inAudioCallMessageWebViewStack.visible = true
147 inAudioCallMessageWebViewStack.push(
148 corrspondingMessageWebView)
149 }
150 }
151 }
152
153 Rectangle {
154 id: audioCallPageRectCentralRect
155
156 anchors.centerIn: parent
157
158 width: audioCallPageRect.width
159 height: audioCallPageRegisteredNameText.height
160 + audioCallPageIdText.height + contactImage.height + 10
161
162 ColumnLayout {
163 id: audioCallPageRectColumnLayout
164
165 Image {
166 id: contactImage
167
168 Layout.alignment: Qt.AlignCenter
169
170 Layout.preferredWidth: 100
171 Layout.preferredHeight: 100
172
173 fillMode: Image.PreserveAspectFit
174 source: contactImgSource
175 asynchronous: true
176 }
177
178 Text {
179 id: audioCallPageRegisteredNameText
180
181 Layout.alignment: Qt.AlignCenter
182
183 Layout.preferredWidth: audioCallPageRectCentralRect.width
184 Layout.preferredHeight: 50
185
186 font.pointSize: JamiTheme.textFontSize + 3
187
188 horizontalAlignment: Text.AlignHCenter
189 verticalAlignment: Text.AlignVCenter
190
191 text: textMetricsAudioCallPageRegisteredNameText.elidedText
192 color: "white"
193
194 TextMetrics {
195 id: textMetricsAudioCallPageRegisteredNameText
196 font: audioCallPageRegisteredNameText.font
197 text: bestName
198 elideWidth: audioCallPageRectCentralRect.width - 50
199 elide: Qt.ElideMiddle
200 }
201 }
202
203 Text {
204 id: audioCallPageIdText
205
206 Layout.alignment: Qt.AlignCenter
207
208 Layout.preferredWidth: audioCallPageRectCentralRect.width
209 Layout.preferredHeight: 30
210
211 font.pointSize: JamiTheme.textFontSize
212
213 horizontalAlignment: Text.AlignHCenter
214 verticalAlignment: Text.AlignVCenter
215
216 text: textMetricsAudioCallPageIdText.elidedText
217 color: "white"
218
219 TextMetrics {
220 id: textMetricsAudioCallPageIdText
221 font: audioCallPageIdText.font
222 text: bestId
223 elideWidth: audioCallPageRectCentralRect.width - 50
224 elide: Qt.ElideMiddle
225 }
226 }
227 }
228
229 color: "transparent"
230 }
231
232 color: "transparent"
233 }
234
235 StackView {
236 id: inAudioCallMessageWebViewStack
237
238 SplitView.preferredHeight: audioCallPageRect.height / 3
239 SplitView.fillWidth: true
240
241 visible: false
242
243 clip: true
244 }
245 }
246
247 color: "black"
248}