blob: 49511f32cbd6d216236d2dc80248edc279947676 [file] [log] [blame]
Sébastien Blin1f915762020-08-03 13:27:42 -04001
2/*
3 * Copyright (C) 2020 by Savoir-faire Linux
Sébastien Blin8940f3c2020-07-23 17:03:11 -04004 * Author: Sébastien Blin <sebastien.blin@savoirfairelinux.com>
Sébastien Blin1f915762020-08-03 13:27:42 -04005 * Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20import QtQuick 2.14
21import QtQuick.Controls 2.14
22import QtQuick.Layouts 1.14
23import QtQuick.Controls.Universal 2.12
24import QtQml 2.14
25import net.jami.Models 1.0
26
27import "../../commoncomponents"
28
29Rectangle {
Sébastien Blin8940f3c2020-07-23 17:03:11 -040030 id: root
Sébastien Blin1f915762020-08-03 13:27:42 -040031
32 /*
33 * ButtonCounts here is to make sure that flow layout margin is calculated correctly,
34 * since no other methods can make buttons at the layout center.
35 */
Sébastien Blin8940f3c2020-07-23 17:03:11 -040036 property int buttonPreferredSize: 24
Sébastien Blin6607e0e2020-07-24 15:15:47 -040037 property var isMaster: true
38 property var isSip: false
Sébastien Blin1f915762020-08-03 13:27:42 -040039
Sébastien Blin1f915762020-08-03 13:27:42 -040040 signal chatButtonClicked
41 signal addToConferenceButtonClicked
Sébastien Blin1f915762020-08-03 13:27:42 -040042
Sébastien Blin6607e0e2020-07-24 15:15:47 -040043 function updateMaster() {
44 root.isMaster = CallAdapter.isCurrentMaster()
45 addToConferenceButton.visible = !root.isSip && root.isMaster
46 }
47
Sébastien Blin1f915762020-08-03 13:27:42 -040048 function setButtonStatus(isPaused, isAudioOnly, isAudioMuted, isVideoMuted, isRecording, isSIP, isConferenceCall) {
Sébastien Blin6607e0e2020-07-24 15:15:47 -040049 root.isMaster = CallAdapter.isCurrentMaster()
50 root.isSip = isSIP
Sébastien Blin1f915762020-08-03 13:27:42 -040051 noVideoButton.visible = !isAudioOnly
Sébastien Blin6607e0e2020-07-24 15:15:47 -040052 addToConferenceButton.visible = !isSIP && isMaster
53 transferCallButton.visible = isSIP
54 sipInputPanelButton.visible = isSIP
Sébastien Blin1f915762020-08-03 13:27:42 -040055
Sébastien Blin8940f3c2020-07-23 17:03:11 -040056 noMicButton.checked = isAudioMuted
57 noVideoButton.checked = isVideoMuted
Sébastien Blin1f915762020-08-03 13:27:42 -040058 }
59
Sébastien Blin8940f3c2020-07-23 17:03:11 -040060 color: "transparent"
61 z: 2
Sébastien Blin1f915762020-08-03 13:27:42 -040062
Sébastien Blin8940f3c2020-07-23 17:03:11 -040063 RowLayout {
64 id: callOverlayButtonGroup
65
66 spacing: 8
67 height: 56
Sébastien Blin1f915762020-08-03 13:27:42 -040068
69 anchors.fill: parent
70
Sébastien Blin8940f3c2020-07-23 17:03:11 -040071 Item {
72 Layout.preferredWidth: {
73 // 6 is the number of button
74 // If ~ 500px, go into wide mode
75 (callOverlayButtonGroup.width < buttonPreferredSize * 12 - callOverlayButtonGroup.spacing * 6 + 300)?
76 0 : callOverlayButtonGroup.width / 2 - buttonPreferredSize * 3 - callOverlayButtonGroup.spacing
Sébastien Blin1f915762020-08-03 13:27:42 -040077 }
78 }
79
Sébastien Blin8940f3c2020-07-23 17:03:11 -040080 HoverableButton {
Sébastien Blin1f915762020-08-03 13:27:42 -040081 id: noMicButton
82
Sébastien Blin8940f3c2020-07-23 17:03:11 -040083 Layout.preferredWidth: buttonPreferredSize * 2
84 Layout.preferredHeight: buttonPreferredSize * 2
Sébastien Blin1f915762020-08-03 13:27:42 -040085
Sébastien Blin8940f3c2020-07-23 17:03:11 -040086 backgroundColor: Qt.rgba(0, 0, 0, 0.75)
87 onEnterColor: Qt.rgba(0, 0, 0, 0.6)
88 onPressColor: Qt.rgba(0, 0, 0, 0.5)
89 onReleaseColor: Qt.rgba(0, 0, 0, 0.6)
90 onExitColor: Qt.rgba(0, 0, 0, 0.75)
91
92 buttonImageHeight: buttonPreferredSize
93 buttonImageWidth: buttonPreferredSize
94 baseImage: "qrc:/images/icons/ic_mic_white_24dp.png"
95 checkedImage: "qrc:/images/icons/ic_mic_off_white_24dp.png"
96 baseColor: "white"
97 checkedColor: JamiTheme.declineButtonPressedRed
98 radius: 30
Sébastien Blin1f915762020-08-03 13:27:42 -040099
100 onClicked: {
101 CallAdapter.muteThisCallToggle()
102 }
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400103 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400104
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400105 HoverableButton {
106 id: hangUpButton
Sébastien Blin1f915762020-08-03 13:27:42 -0400107
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400108 Layout.preferredWidth: buttonPreferredSize * 2
109 Layout.preferredHeight: buttonPreferredSize * 2
110
111 backgroundColor: JamiTheme.declineButtonRed
112 onEnterColor: JamiTheme.declineButtonHoverRed
113 onPressColor: JamiTheme.declineButtonPressedRed
114 onReleaseColor: JamiTheme.declineButtonHoverRed
115 onExitColor: JamiTheme.declineButtonRed
116
117 buttonImageHeight: buttonPreferredSize
118 buttonImageWidth: buttonPreferredSize
119 source: "qrc:/images/icons/ic_call_end_white_24px.svg"
120 color: "white"
121 radius: 30
122
123 onClicked: {
124 CallAdapter.hangUpThisCall()
Sébastien Blin1f915762020-08-03 13:27:42 -0400125 }
126 }
127
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400128 HoverableButton {
Sébastien Blin1f915762020-08-03 13:27:42 -0400129 id: noVideoButton
130
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400131 Layout.preferredWidth: buttonPreferredSize * 2
132 Layout.preferredHeight: buttonPreferredSize * 2
Sébastien Blin1f915762020-08-03 13:27:42 -0400133
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400134 backgroundColor: Qt.rgba(0, 0, 0, 0.75)
135 onEnterColor: Qt.rgba(0, 0, 0, 0.6)
136 onPressColor: Qt.rgba(0, 0, 0, 0.5)
137 onReleaseColor: Qt.rgba(0, 0, 0, 0.6)
138 onExitColor: Qt.rgba(0, 0, 0, 0.75)
Sébastien Blin1f915762020-08-03 13:27:42 -0400139
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400140 buttonImageHeight: buttonPreferredSize
141 buttonImageWidth: buttonPreferredSize
142 baseImage: "qrc:/images/icons/ic_videocam_white.png"
143 checkedImage: "qrc:/images/icons/ic_videocam_off_white_24dp.png"
144 baseColor: "white"
145 checkedColor: JamiTheme.declineButtonPressedRed
146 radius: 30
Sébastien Blin1f915762020-08-03 13:27:42 -0400147
148 onClicked: {
149 CallAdapter.videoPauseThisCallToggle()
150 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400151 }
152
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400153 Item {
154 Layout.fillWidth: true
155 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400156
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400157 HoverableButton {
158 id: addToConferenceButton
Sébastien Blin1f915762020-08-03 13:27:42 -0400159
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400160 Layout.preferredWidth: buttonPreferredSize * 2
161 Layout.preferredHeight: buttonPreferredSize * 2
Sébastien Blin6607e0e2020-07-24 15:15:47 -0400162 visible: !isMaster
Sébastien Blin1f915762020-08-03 13:27:42 -0400163
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400164 backgroundColor: Qt.rgba(0, 0, 0, 0.75)
165 onEnterColor: Qt.rgba(0, 0, 0, 0.6)
166 onPressColor: Qt.rgba(0, 0, 0, 0.5)
167 onReleaseColor: Qt.rgba(0, 0, 0, 0.6)
168 onExitColor: Qt.rgba(0, 0, 0, 0.75)
169
170 buttonImageHeight: buttonPreferredSize
171 buttonImageWidth: buttonPreferredSize
172 color: "white"
173 source: "qrc:/images/icons/ic_group_add_white_24dp.png"
174 radius: 30
Sébastien Blin1f915762020-08-03 13:27:42 -0400175
176 onClicked: {
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400177 root.addToConferenceButtonClicked()
Sébastien Blin1f915762020-08-03 13:27:42 -0400178 }
179 }
180
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400181 HoverableButton {
182 id: chatButton
Sébastien Blin1f915762020-08-03 13:27:42 -0400183
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400184 Layout.preferredWidth: buttonPreferredSize * 2
185 Layout.preferredHeight: buttonPreferredSize * 2
Sébastien Blin1f915762020-08-03 13:27:42 -0400186
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400187 backgroundColor: Qt.rgba(0, 0, 0, 0.75)
188 onEnterColor: Qt.rgba(0, 0, 0, 0.6)
189 onPressColor: Qt.rgba(0, 0, 0, 0.5)
190 onReleaseColor: Qt.rgba(0, 0, 0, 0.6)
191 onExitColor: Qt.rgba(0, 0, 0, 0.75)
Sébastien Blin1f915762020-08-03 13:27:42 -0400192
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400193 buttonImageHeight: buttonPreferredSize
194 buttonImageWidth: buttonPreferredSize
195 color: "white"
196 source: "qrc:/images/icons/ic_chat_white_24dp.png"
197 radius: 30
Sébastien Blin1f915762020-08-03 13:27:42 -0400198
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400199 onClicked: {
200 root.chatButtonClicked()
Sébastien Blin1f915762020-08-03 13:27:42 -0400201 }
202 }
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400203
204 HoverableButton {
205 id: optionsButton
206
207 Layout.preferredWidth: buttonPreferredSize * 2
208 Layout.preferredHeight: buttonPreferredSize * 2
209
210 backgroundColor: Qt.rgba(0, 0, 0, 0.75)
211 onEnterColor: Qt.rgba(0, 0, 0, 0.6)
212 onPressColor: Qt.rgba(0, 0, 0, 0.5)
213 onReleaseColor: Qt.rgba(0, 0, 0, 0.6)
214 onExitColor: Qt.rgba(0, 0, 0, 0.75)
215
216 buttonImageHeight: buttonPreferredSize
217 buttonImageWidth: buttonPreferredSize
218 source: "qrc:/images/icons/more_vert-24px.svg"
219 radius: 30
220
221 onClicked: {
222 var rectPos = mapToItem(callStackViewWindow, optionsButton.x, optionsButton.y)
223 callViewContextMenu.activate()
224 callViewContextMenu.x = rectPos.x + optionsButton.width/2 - callViewContextMenu.width/2
225 callViewContextMenu.y = rectPos.y - 12 - callViewContextMenu.height
226 }
227 }
228
229 Item { Layout.preferredWidth: 8 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400230 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400231}