blob: 0a85cf235897a6d8774da405ca1110b74593bf3b [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
Sébastien Blin8940f3c2020-07-23 17:03:11 -040034 property var linkedWebview: null
Sébastien Blin1f915762020-08-03 13:27:42 -040035
36 function updateUI(accountId, convUid) {
37 contactImgSource = "data:image/png;base64," + ClientWrapper.utilsAdaptor.getContactImageString(
38 accountId, convUid)
39 bestName = ClientWrapper.utilsAdaptor.getBestName(accountId, convUid)
40
41 var id = ClientWrapper.utilsAdaptor.getBestId(accountId, convUid)
42 bestId = (bestName !== id) ? id : ""
43 }
44
Sébastien Blin8940f3c2020-07-23 17:03:11 -040045 function setLinkedWebview(webViewId) {
46 linkedWebview = webViewId
47 linkedWebview.needToHideConversationInCall.disconnect(
Sébastien Blin1f915762020-08-03 13:27:42 -040048 closeInCallConversation)
Sébastien Blin8940f3c2020-07-23 17:03:11 -040049 linkedWebview.needToHideConversationInCall.connect(
Sébastien Blin1f915762020-08-03 13:27:42 -040050 closeInCallConversation)
51 }
52
53 function closeInCallConversation() {
54 if (inAudioCallMessageWebViewStack.visible) {
Sébastien Blin8940f3c2020-07-23 17:03:11 -040055 linkedWebview.resetMessagingHeaderBackButtonSource(
Sébastien Blin1f915762020-08-03 13:27:42 -040056 true)
Sébastien Blin8940f3c2020-07-23 17:03:11 -040057 linkedWebview.setMessagingHeaderButtonsVisible(true)
Sébastien Blin1f915762020-08-03 13:27:42 -040058 inAudioCallMessageWebViewStack.visible = false
59 inAudioCallMessageWebViewStack.clear()
60 }
61 }
62
63 function closeContextMenuAndRelatedWindows() {
64 audioCallOverlay.closePotentialContactPicker()
65 }
66
67 anchors.fill: parent
68
69 SplitView {
70 id: mainColumnLayout
71
72 anchors.fill: parent
73
74 orientation: Qt.Vertical
75
76 handle: Rectangle {
77 implicitWidth: audioCallPageRect.width
ababia284cae2020-08-10 12:33:34 +020078 implicitHeight: JamiTheme.splitViewHandlePreferredWidth
Sébastien Blin1f915762020-08-03 13:27:42 -040079 color: SplitHandle.pressed ? JamiTheme.pressColor : (SplitHandle.hovered ? JamiTheme.hoverColor : JamiTheme.tabbarBorderColor)
80 }
81
82 Rectangle {
83 id: audioCallPageMainRect
84
85 SplitView.preferredHeight: (audioCallPageRect.height / 3) * 2
86 SplitView.minimumHeight: audioCallPageRect.height / 2 + 20
87 SplitView.fillWidth: true
88
89 CallOverlay {
90 id: audioCallOverlay
91
92 anchors.fill: parent
93
94 Connections {
95 target: CallAdapter
96
97 function onUpdateTimeText(time) {
98 audioCallOverlay.timeText = time
99 }
100
101 function onUpdateOverlay(isPaused, isAudioOnly, isAudioMuted, isVideoMuted, isRecording, isSIP, isConferenceCall, bestName) {
102 audioCallOverlay.showOnHoldImage(isPaused)
103 audioCallPageRectCentralRect.visible = !isPaused
104 audioCallOverlay.updateButtonStatus(isPaused,
105 isAudioOnly,
106 isAudioMuted,
107 isVideoMuted,
108 isRecording, isSIP,
109 isConferenceCall)
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400110 audioCallPageRect.bestName = bestName
Sébastien Blin1f915762020-08-03 13:27:42 -0400111 }
112
113 function onShowOnHoldLabel(isPaused) {
114 audioCallOverlay.showOnHoldImage(isPaused)
115 audioCallPageRectCentralRect.visible = !isPaused
116 }
117 }
118
Sébastien Blin1f915762020-08-03 13:27:42 -0400119 onOverlayChatButtonClicked: {
120 if (inAudioCallMessageWebViewStack.visible) {
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400121 linkedWebview.resetMessagingHeaderBackButtonSource(
Sébastien Blin1f915762020-08-03 13:27:42 -0400122 true)
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400123 linkedWebview.setMessagingHeaderButtonsVisible(
Sébastien Blin1f915762020-08-03 13:27:42 -0400124 true)
125 inAudioCallMessageWebViewStack.visible = false
126 inAudioCallMessageWebViewStack.clear()
127 } else {
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400128 linkedWebview.resetMessagingHeaderBackButtonSource(
Sébastien Blin1f915762020-08-03 13:27:42 -0400129 false)
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400130 linkedWebview.setMessagingHeaderButtonsVisible(
Sébastien Blin1f915762020-08-03 13:27:42 -0400131 false)
132 inAudioCallMessageWebViewStack.visible = true
133 inAudioCallMessageWebViewStack.push(
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400134 linkedWebview)
Sébastien Blin1f915762020-08-03 13:27:42 -0400135 }
136 }
137 }
138
139 Rectangle {
140 id: audioCallPageRectCentralRect
141
142 anchors.centerIn: parent
143
144 width: audioCallPageRect.width
145 height: audioCallPageRegisteredNameText.height
146 + audioCallPageIdText.height + contactImage.height + 10
147
148 ColumnLayout {
149 id: audioCallPageRectColumnLayout
150
151 Image {
152 id: contactImage
153
154 Layout.alignment: Qt.AlignCenter
155
156 Layout.preferredWidth: 100
157 Layout.preferredHeight: 100
158
159 fillMode: Image.PreserveAspectFit
160 source: contactImgSource
161 asynchronous: true
162 }
163
164 Text {
165 id: audioCallPageRegisteredNameText
166
167 Layout.alignment: Qt.AlignCenter
168
169 Layout.preferredWidth: audioCallPageRectCentralRect.width
170 Layout.preferredHeight: 50
171
172 font.pointSize: JamiTheme.textFontSize + 3
173
174 horizontalAlignment: Text.AlignHCenter
175 verticalAlignment: Text.AlignVCenter
176
177 text: textMetricsAudioCallPageRegisteredNameText.elidedText
178 color: "white"
179
180 TextMetrics {
181 id: textMetricsAudioCallPageRegisteredNameText
182 font: audioCallPageRegisteredNameText.font
183 text: bestName
184 elideWidth: audioCallPageRectCentralRect.width - 50
185 elide: Qt.ElideMiddle
186 }
187 }
188
189 Text {
190 id: audioCallPageIdText
191
192 Layout.alignment: Qt.AlignCenter
193
194 Layout.preferredWidth: audioCallPageRectCentralRect.width
195 Layout.preferredHeight: 30
196
197 font.pointSize: JamiTheme.textFontSize
198
199 horizontalAlignment: Text.AlignHCenter
200 verticalAlignment: Text.AlignVCenter
201
202 text: textMetricsAudioCallPageIdText.elidedText
203 color: "white"
204
205 TextMetrics {
206 id: textMetricsAudioCallPageIdText
207 font: audioCallPageIdText.font
208 text: bestId
209 elideWidth: audioCallPageRectCentralRect.width - 50
210 elide: Qt.ElideMiddle
211 }
212 }
213 }
214
215 color: "transparent"
216 }
217
218 color: "transparent"
219 }
220
221 StackView {
222 id: inAudioCallMessageWebViewStack
223
224 SplitView.preferredHeight: audioCallPageRect.height / 3
225 SplitView.fillWidth: true
226
227 visible: false
228
229 clip: true
230 }
231 }
232
233 color: "black"
234}