Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 1 | |
| 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 | */ |
| 19 | import QtQuick 2.14 |
| 20 | import QtQuick.Controls 2.14 |
| 21 | import QtQuick.Layouts 1.14 |
| 22 | import QtQuick.Controls.Universal 2.12 |
| 23 | import net.jami.Models 1.0 |
| 24 | |
| 25 | import "../../commoncomponents" |
| 26 | |
| 27 | Rectangle { |
| 28 | id: audioCallPageRect |
| 29 | |
| 30 | property string contactImgSource: "" |
| 31 | property string bestName: "Best Name" |
| 32 | property string bestId: "Best Id" |
| 33 | |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame^] | 34 | property var linkedWebview: null |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 35 | |
| 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 Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame^] | 45 | function setLinkedWebview(webViewId) { |
| 46 | linkedWebview = webViewId |
| 47 | linkedWebview.needToHideConversationInCall.disconnect( |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 48 | closeInCallConversation) |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame^] | 49 | linkedWebview.needToHideConversationInCall.connect( |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 50 | closeInCallConversation) |
| 51 | } |
| 52 | |
| 53 | function closeInCallConversation() { |
| 54 | if (inAudioCallMessageWebViewStack.visible) { |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame^] | 55 | linkedWebview.resetMessagingHeaderBackButtonSource( |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 56 | true) |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame^] | 57 | linkedWebview.setMessagingHeaderButtonsVisible(true) |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 58 | 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 |
| 78 | implicitHeight: JamiTheme.splitViewHandlePreferedWidth |
| 79 | 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 Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame^] | 110 | audioCallPageRect.bestName = bestName |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 111 | } |
| 112 | |
| 113 | function onShowOnHoldLabel(isPaused) { |
| 114 | audioCallOverlay.showOnHoldImage(isPaused) |
| 115 | audioCallPageRectCentralRect.visible = !isPaused |
| 116 | } |
| 117 | } |
| 118 | |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 119 | onOverlayChatButtonClicked: { |
| 120 | if (inAudioCallMessageWebViewStack.visible) { |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame^] | 121 | linkedWebview.resetMessagingHeaderBackButtonSource( |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 122 | true) |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame^] | 123 | linkedWebview.setMessagingHeaderButtonsVisible( |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 124 | true) |
| 125 | inAudioCallMessageWebViewStack.visible = false |
| 126 | inAudioCallMessageWebViewStack.clear() |
| 127 | } else { |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame^] | 128 | linkedWebview.resetMessagingHeaderBackButtonSource( |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 129 | false) |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame^] | 130 | linkedWebview.setMessagingHeaderButtonsVisible( |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 131 | false) |
| 132 | inAudioCallMessageWebViewStack.visible = true |
| 133 | inAudioCallMessageWebViewStack.push( |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame^] | 134 | linkedWebview) |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 135 | } |
| 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 | } |