blob: c360a7cdaae3edab6be8508ac45081d580b02d27 [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
Yang Wangb97bde42020-08-07 11:24:18 -0400100 toolTipText: !checked ? qsTr("Press to mute the call") : qsTr("Press to unmute the call")
101
Sébastien Blin1f915762020-08-03 13:27:42 -0400102 onClicked: {
103 CallAdapter.muteThisCallToggle()
104 }
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400105 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400106
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400107 HoverableButton {
108 id: hangUpButton
Sébastien Blin1f915762020-08-03 13:27:42 -0400109
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400110 Layout.preferredWidth: buttonPreferredSize * 2
111 Layout.preferredHeight: buttonPreferredSize * 2
112
113 backgroundColor: JamiTheme.declineButtonRed
114 onEnterColor: JamiTheme.declineButtonHoverRed
115 onPressColor: JamiTheme.declineButtonPressedRed
116 onReleaseColor: JamiTheme.declineButtonHoverRed
117 onExitColor: JamiTheme.declineButtonRed
118
119 buttonImageHeight: buttonPreferredSize
120 buttonImageWidth: buttonPreferredSize
121 source: "qrc:/images/icons/ic_call_end_white_24px.svg"
122 color: "white"
123 radius: 30
124
Yang Wangb97bde42020-08-07 11:24:18 -0400125 toolTipText: qsTr("Press to hang up the call")
126
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400127 onClicked: {
128 CallAdapter.hangUpThisCall()
Sébastien Blin1f915762020-08-03 13:27:42 -0400129 }
130 }
131
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400132 HoverableButton {
Sébastien Blin1f915762020-08-03 13:27:42 -0400133 id: noVideoButton
134
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400135 Layout.preferredWidth: buttonPreferredSize * 2
136 Layout.preferredHeight: buttonPreferredSize * 2
Sébastien Blin1f915762020-08-03 13:27:42 -0400137
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400138 backgroundColor: Qt.rgba(0, 0, 0, 0.75)
139 onEnterColor: Qt.rgba(0, 0, 0, 0.6)
140 onPressColor: Qt.rgba(0, 0, 0, 0.5)
141 onReleaseColor: Qt.rgba(0, 0, 0, 0.6)
142 onExitColor: Qt.rgba(0, 0, 0, 0.75)
Sébastien Blin1f915762020-08-03 13:27:42 -0400143
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400144 buttonImageHeight: buttonPreferredSize
145 buttonImageWidth: buttonPreferredSize
146 baseImage: "qrc:/images/icons/ic_videocam_white.png"
147 checkedImage: "qrc:/images/icons/ic_videocam_off_white_24dp.png"
148 baseColor: "white"
149 checkedColor: JamiTheme.declineButtonPressedRed
150 radius: 30
Sébastien Blin1f915762020-08-03 13:27:42 -0400151
Yang Wangb97bde42020-08-07 11:24:18 -0400152 toolTipText: !checked ? qsTr("Press to pause the call") : qsTr("Press to resume the call")
153
Sébastien Blin1f915762020-08-03 13:27:42 -0400154 onClicked: {
155 CallAdapter.videoPauseThisCallToggle()
156 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400157 }
158
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400159 Item {
160 Layout.fillWidth: true
161 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400162
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400163 HoverableButton {
164 id: addToConferenceButton
Sébastien Blin1f915762020-08-03 13:27:42 -0400165
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400166 Layout.preferredWidth: buttonPreferredSize * 2
167 Layout.preferredHeight: buttonPreferredSize * 2
Sébastien Blin6607e0e2020-07-24 15:15:47 -0400168 visible: !isMaster
Sébastien Blin1f915762020-08-03 13:27:42 -0400169
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400170 backgroundColor: Qt.rgba(0, 0, 0, 0.75)
171 onEnterColor: Qt.rgba(0, 0, 0, 0.6)
172 onPressColor: Qt.rgba(0, 0, 0, 0.5)
173 onReleaseColor: Qt.rgba(0, 0, 0, 0.6)
174 onExitColor: Qt.rgba(0, 0, 0, 0.75)
175
176 buttonImageHeight: buttonPreferredSize
177 buttonImageWidth: buttonPreferredSize
178 color: "white"
179 source: "qrc:/images/icons/ic_group_add_white_24dp.png"
180 radius: 30
Sébastien Blin1f915762020-08-03 13:27:42 -0400181
Yang Wangb97bde42020-08-07 11:24:18 -0400182 toolTipText: qsTr("Press to add more contact into conference call")
183
Sébastien Blin1f915762020-08-03 13:27:42 -0400184 onClicked: {
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400185 root.addToConferenceButtonClicked()
Sébastien Blin1f915762020-08-03 13:27:42 -0400186 }
187 }
188
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400189 HoverableButton {
190 id: chatButton
Sébastien Blin1f915762020-08-03 13:27:42 -0400191
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400192 Layout.preferredWidth: buttonPreferredSize * 2
193 Layout.preferredHeight: buttonPreferredSize * 2
Sébastien Blin1f915762020-08-03 13:27:42 -0400194
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400195 backgroundColor: Qt.rgba(0, 0, 0, 0.75)
196 onEnterColor: Qt.rgba(0, 0, 0, 0.6)
197 onPressColor: Qt.rgba(0, 0, 0, 0.5)
198 onReleaseColor: Qt.rgba(0, 0, 0, 0.6)
199 onExitColor: Qt.rgba(0, 0, 0, 0.75)
Sébastien Blin1f915762020-08-03 13:27:42 -0400200
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400201 buttonImageHeight: buttonPreferredSize
202 buttonImageWidth: buttonPreferredSize
203 color: "white"
204 source: "qrc:/images/icons/ic_chat_white_24dp.png"
205 radius: 30
Sébastien Blin1f915762020-08-03 13:27:42 -0400206
Yang Wangb97bde42020-08-07 11:24:18 -0400207 toolTipText: qsTr("Press to toggle open the chatview")
208
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400209 onClicked: {
210 root.chatButtonClicked()
Sébastien Blin1f915762020-08-03 13:27:42 -0400211 }
212 }
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400213
214 HoverableButton {
215 id: optionsButton
216
217 Layout.preferredWidth: buttonPreferredSize * 2
218 Layout.preferredHeight: buttonPreferredSize * 2
219
220 backgroundColor: Qt.rgba(0, 0, 0, 0.75)
221 onEnterColor: Qt.rgba(0, 0, 0, 0.6)
222 onPressColor: Qt.rgba(0, 0, 0, 0.5)
223 onReleaseColor: Qt.rgba(0, 0, 0, 0.6)
224 onExitColor: Qt.rgba(0, 0, 0, 0.75)
225
226 buttonImageHeight: buttonPreferredSize
227 buttonImageWidth: buttonPreferredSize
228 source: "qrc:/images/icons/more_vert-24px.svg"
229 radius: 30
230
Yang Wangb97bde42020-08-07 11:24:18 -0400231 toolTipText: qsTr("Press to open chat options")
232
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400233 onClicked: {
234 var rectPos = mapToItem(callStackViewWindow, optionsButton.x, optionsButton.y)
235 callViewContextMenu.activate()
236 callViewContextMenu.x = rectPos.x + optionsButton.width/2 - callViewContextMenu.width/2
237 callViewContextMenu.y = rectPos.y - 12 - callViewContextMenu.height
238 }
239 }
240
241 Item { Layout.preferredWidth: 8 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400242 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400243}