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 | |
Yang Wang | b97bde4 | 2020-08-07 11:24:18 -0400 | [diff] [blame] | 100 | toolTipText: !checked ? qsTr("Press to mute the call") : qsTr("Press to unmute the call") |
| 101 | |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 102 | onClicked: { |
| 103 | CallAdapter.muteThisCallToggle() |
| 104 | } |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 105 | } |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 106 | |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 107 | HoverableButton { |
| 108 | id: hangUpButton |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 109 | |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 110 | 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 Wang | b97bde4 | 2020-08-07 11:24:18 -0400 | [diff] [blame] | 125 | toolTipText: qsTr("Press to hang up the call") |
| 126 | |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 127 | onClicked: { |
| 128 | CallAdapter.hangUpThisCall() |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 129 | } |
| 130 | } |
| 131 | |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 132 | HoverableButton { |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 133 | id: noVideoButton |
| 134 | |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 135 | Layout.preferredWidth: buttonPreferredSize * 2 |
| 136 | Layout.preferredHeight: buttonPreferredSize * 2 |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 137 | |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 138 | 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 Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 143 | |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 144 | 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 Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 151 | |
Yang Wang | b97bde4 | 2020-08-07 11:24:18 -0400 | [diff] [blame] | 152 | toolTipText: !checked ? qsTr("Press to pause the call") : qsTr("Press to resume the call") |
| 153 | |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 154 | onClicked: { |
| 155 | CallAdapter.videoPauseThisCallToggle() |
| 156 | } |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 157 | } |
| 158 | |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 159 | Item { |
| 160 | Layout.fillWidth: true |
| 161 | } |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 162 | |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 163 | HoverableButton { |
| 164 | id: addToConferenceButton |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 165 | |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 166 | Layout.preferredWidth: buttonPreferredSize * 2 |
| 167 | Layout.preferredHeight: buttonPreferredSize * 2 |
Sébastien Blin | 6607e0e | 2020-07-24 15:15:47 -0400 | [diff] [blame] | 168 | visible: !isMaster |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 169 | |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 170 | 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 Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 181 | |
Yang Wang | b97bde4 | 2020-08-07 11:24:18 -0400 | [diff] [blame] | 182 | toolTipText: qsTr("Press to add more contact into conference call") |
| 183 | |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 184 | onClicked: { |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 185 | root.addToConferenceButtonClicked() |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 186 | } |
| 187 | } |
| 188 | |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 189 | HoverableButton { |
| 190 | id: chatButton |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 191 | |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 192 | Layout.preferredWidth: buttonPreferredSize * 2 |
| 193 | Layout.preferredHeight: buttonPreferredSize * 2 |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 194 | |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 195 | 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 Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 200 | |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 201 | buttonImageHeight: buttonPreferredSize |
| 202 | buttonImageWidth: buttonPreferredSize |
| 203 | color: "white" |
| 204 | source: "qrc:/images/icons/ic_chat_white_24dp.png" |
| 205 | radius: 30 |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 206 | |
Yang Wang | b97bde4 | 2020-08-07 11:24:18 -0400 | [diff] [blame] | 207 | toolTipText: qsTr("Press to toggle open the chatview") |
| 208 | |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 209 | onClicked: { |
| 210 | root.chatButtonClicked() |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 211 | } |
| 212 | } |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 213 | |
| 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 Wang | b97bde4 | 2020-08-07 11:24:18 -0400 | [diff] [blame] | 231 | toolTipText: qsTr("Press to open chat options") |
| 232 | |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 233 | 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 Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 242 | } |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 243 | } |