Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 1 | |
| 2 | /* |
| 3 | * Copyright (C) 2020 by Savoir-faire Linux |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 4 | * Author: Sébastien Blin <sebastien.blin@savoirfairelinux.com> |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 5 | * 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 | */ |
| 20 | import QtQuick 2.14 |
| 21 | import QtQuick.Controls 2.14 |
| 22 | import QtQuick.Layouts 1.14 |
| 23 | import QtQuick.Controls.Universal 2.12 |
| 24 | import QtQml 2.14 |
| 25 | import net.jami.Models 1.0 |
| 26 | |
| 27 | import "../../commoncomponents" |
| 28 | |
| 29 | Rectangle { |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 30 | id: root |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 31 | |
| 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 Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 36 | property int buttonPreferredSize: 24 |
Sébastien Blin | 6607e0e | 2020-07-24 15:15:47 -0400 | [diff] [blame^] | 37 | property var isMaster: true |
| 38 | property var isSip: false |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 39 | |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 40 | signal chatButtonClicked |
| 41 | signal addToConferenceButtonClicked |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 42 | |
Sébastien Blin | 6607e0e | 2020-07-24 15:15:47 -0400 | [diff] [blame^] | 43 | function updateMaster() { |
| 44 | root.isMaster = CallAdapter.isCurrentMaster() |
| 45 | addToConferenceButton.visible = !root.isSip && root.isMaster |
| 46 | } |
| 47 | |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 48 | function setButtonStatus(isPaused, isAudioOnly, isAudioMuted, isVideoMuted, isRecording, isSIP, isConferenceCall) { |
Sébastien Blin | 6607e0e | 2020-07-24 15:15:47 -0400 | [diff] [blame^] | 49 | root.isMaster = CallAdapter.isCurrentMaster() |
| 50 | root.isSip = isSIP |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 51 | noVideoButton.visible = !isAudioOnly |
Sébastien Blin | 6607e0e | 2020-07-24 15:15:47 -0400 | [diff] [blame^] | 52 | addToConferenceButton.visible = !isSIP && isMaster |
| 53 | transferCallButton.visible = isSIP |
| 54 | sipInputPanelButton.visible = isSIP |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 55 | |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 56 | noMicButton.checked = isAudioMuted |
| 57 | noVideoButton.checked = isVideoMuted |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 58 | } |
| 59 | |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 60 | color: "transparent" |
| 61 | z: 2 |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 62 | |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 63 | RowLayout { |
| 64 | id: callOverlayButtonGroup |
| 65 | |
| 66 | spacing: 8 |
| 67 | height: 56 |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 68 | |
| 69 | anchors.fill: parent |
| 70 | |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 71 | 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 Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 77 | } |
| 78 | } |
| 79 | |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 80 | HoverableButton { |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 81 | id: noMicButton |
| 82 | |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 83 | Layout.preferredWidth: buttonPreferredSize * 2 |
| 84 | Layout.preferredHeight: buttonPreferredSize * 2 |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 85 | |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 86 | 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 Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 99 | |
| 100 | onClicked: { |
| 101 | CallAdapter.muteThisCallToggle() |
| 102 | } |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 103 | } |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 104 | |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 105 | HoverableButton { |
| 106 | id: hangUpButton |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 107 | |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 108 | 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 Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 125 | } |
| 126 | } |
| 127 | |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 128 | HoverableButton { |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 129 | id: noVideoButton |
| 130 | |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 131 | Layout.preferredWidth: buttonPreferredSize * 2 |
| 132 | Layout.preferredHeight: buttonPreferredSize * 2 |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 133 | |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 134 | 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 Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 139 | |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 140 | 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 Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 147 | |
| 148 | onClicked: { |
| 149 | CallAdapter.videoPauseThisCallToggle() |
| 150 | } |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 151 | } |
| 152 | |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 153 | Item { |
| 154 | Layout.fillWidth: true |
| 155 | } |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 156 | |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 157 | HoverableButton { |
| 158 | id: addToConferenceButton |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 159 | |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 160 | Layout.preferredWidth: buttonPreferredSize * 2 |
| 161 | Layout.preferredHeight: buttonPreferredSize * 2 |
Sébastien Blin | 6607e0e | 2020-07-24 15:15:47 -0400 | [diff] [blame^] | 162 | visible: !isMaster |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 163 | |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 164 | 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 Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 175 | |
| 176 | onClicked: { |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 177 | root.addToConferenceButtonClicked() |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 178 | } |
| 179 | } |
| 180 | |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 181 | HoverableButton { |
| 182 | id: chatButton |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 183 | |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 184 | Layout.preferredWidth: buttonPreferredSize * 2 |
| 185 | Layout.preferredHeight: buttonPreferredSize * 2 |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 186 | |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 187 | 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 Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 192 | |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 193 | buttonImageHeight: buttonPreferredSize |
| 194 | buttonImageWidth: buttonPreferredSize |
| 195 | color: "white" |
| 196 | source: "qrc:/images/icons/ic_chat_white_24dp.png" |
| 197 | radius: 30 |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 198 | |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 199 | onClicked: { |
| 200 | root.chatButtonClicked() |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 201 | } |
| 202 | } |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 203 | |
| 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 Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 230 | } |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 231 | } |