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 QtQml 2.14 |
| 24 | import net.jami.Models 1.0 |
| 25 | |
| 26 | import "../../commoncomponents" |
| 27 | |
| 28 | Rectangle { |
| 29 | id: callOverlayButtonGroupRect |
| 30 | |
| 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 | */ |
| 36 | property int buttonCounts: 9 |
| 37 | property int buttonPreferredSize: 30 |
| 38 | |
| 39 | signal buttonEntered |
| 40 | signal chatButtonClicked |
| 41 | signal addToConferenceButtonClicked |
| 42 | signal transferCallButtonClicked |
| 43 | |
| 44 | function setButtonStatus(isPaused, isAudioOnly, isAudioMuted, isVideoMuted, isRecording, isSIP, isConferenceCall) { |
| 45 | noVideoButton.visible = !isAudioOnly |
| 46 | addToConferenceButton.visible = !isSIP |
| 47 | transferCallButton.visible = isSIP |
| 48 | sipInputPanelButton.visible = isSIP |
| 49 | |
| 50 | noMicButton.setChecked(isAudioMuted) |
| 51 | noVideoButton.setChecked(isVideoMuted) |
| 52 | recButton.setChecked(isRecording) |
| 53 | holdButton.setChecked(isPaused) |
| 54 | |
| 55 | holdButton.visible = !isConferenceCall |
| 56 | } |
| 57 | |
| 58 | function calculateFlowMargin() { |
| 59 | return (callOverlayButtonGroupRect.width - buttonCounts * buttonPreferredSize |
| 60 | - callOverlayButtonGroupRectFlow.spacing * (buttonCounts - 1)) / 2 |
| 61 | } |
| 62 | |
| 63 | Flow { |
| 64 | id: callOverlayButtonGroupRectFlow |
| 65 | |
| 66 | anchors.fill: parent |
| 67 | |
| 68 | |
| 69 | /* |
| 70 | * Minus 1 is to make sure that button will not flick when doing flow layout. |
| 71 | */ |
| 72 | anchors.leftMargin: calculateFlowMargin( |
| 73 | ) < 0 ? 0 : calculateFlowMargin() - 1 |
| 74 | anchors.rightMargin: calculateFlowMargin( |
| 75 | ) < 0 ? 0 : calculateFlowMargin() - 1 |
| 76 | |
| 77 | spacing: 10 |
| 78 | |
| 79 | TintedButton { |
| 80 | id: hangUpButton |
| 81 | |
| 82 | width: buttonPreferredSize |
| 83 | height: buttonPreferredSize |
| 84 | |
| 85 | tintColor: JamiTheme.hangUpButtonTintedRed |
| 86 | normalPixmapSource: "qrc:/images/icons/ic_close_white_24dp.png" |
| 87 | selectedPixmapSource: "qrc:/images/icons/ic_close_white_24dp.png" |
| 88 | |
| 89 | onButtonEntered: { |
| 90 | callOverlayButtonGroupRect.buttonEntered() |
| 91 | } |
| 92 | |
| 93 | onClicked: { |
| 94 | CallAdapter.hangUpThisCall() |
| 95 | } |
| 96 | |
| 97 | onVisibleChanged: { |
| 98 | if (this.visible) |
| 99 | buttonCounts++ |
| 100 | else |
| 101 | buttonCounts-- |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | TintedButton { |
| 106 | id: holdButton |
| 107 | |
| 108 | width: buttonPreferredSize |
| 109 | height: buttonPreferredSize |
| 110 | |
| 111 | tintColor: JamiTheme.buttonTintedBlue |
| 112 | normalPixmapSource: "qrc:/images/icons/ic_pause_white_24dp.png" |
| 113 | selectedPixmapSource: "qrc:/images/icons/ic_play_white_24dp.png" |
| 114 | |
| 115 | onClicked: { |
| 116 | CallAdapter.holdThisCallToggle() |
| 117 | } |
| 118 | |
| 119 | onButtonEntered: { |
| 120 | callOverlayButtonGroupRect.buttonEntered() |
| 121 | } |
| 122 | |
| 123 | onVisibleChanged: { |
| 124 | if (this.visible) |
| 125 | buttonCounts++ |
| 126 | else |
| 127 | buttonCounts-- |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | TintedButton { |
| 132 | id: addToConferenceButton |
| 133 | |
| 134 | width: buttonPreferredSize |
| 135 | height: buttonPreferredSize |
| 136 | |
| 137 | tintColor: JamiTheme.buttonTintedBlue |
| 138 | normalPixmapSource: "qrc:/images/icons/ic_group_add_white_24dp.png" |
| 139 | selectedPixmapSource: "qrc:/images/icons/ic_group_add_white_24dp.png" |
| 140 | |
| 141 | onButtonEntered: { |
| 142 | callOverlayButtonGroupRect.buttonEntered() |
| 143 | } |
| 144 | |
| 145 | onClicked: { |
| 146 | callOverlayButtonGroupRect.addToConferenceButtonClicked() |
| 147 | } |
| 148 | |
| 149 | onVisibleChanged: { |
| 150 | if (this.visible) |
| 151 | buttonCounts++ |
| 152 | else |
| 153 | buttonCounts-- |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | TintedButton { |
| 158 | id: transferCallButton |
| 159 | |
| 160 | width: buttonPreferredSize |
| 161 | height: buttonPreferredSize |
| 162 | |
| 163 | tintColor: JamiTheme.buttonTintedBlue |
| 164 | normalPixmapSource: "qrc:/images/icons/ic_call_transfer_white_24px.png" |
| 165 | selectedPixmapSource: "qrc:/images/icons/ic_call_transfer_white_24px.png" |
| 166 | |
| 167 | onButtonEntered: { |
| 168 | callOverlayButtonGroupRect.buttonEntered() |
| 169 | } |
| 170 | |
| 171 | onClicked: { |
| 172 | callOverlayButtonGroupRect.transferCallButtonClicked() |
| 173 | } |
| 174 | |
| 175 | onVisibleChanged: { |
| 176 | if (this.visible) |
| 177 | buttonCounts++ |
| 178 | else |
| 179 | buttonCounts-- |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | TintedButton { |
| 184 | id: chatButton |
| 185 | |
| 186 | width: buttonPreferredSize |
| 187 | height: buttonPreferredSize |
| 188 | |
| 189 | tintColor: JamiTheme.buttonTintedBlue |
| 190 | normalPixmapSource: "qrc:/images/icons/ic_chat_white_24dp.png" |
| 191 | selectedPixmapSource: "qrc:/images/icons/ic_chat_white_24dp.png" |
| 192 | |
| 193 | onClicked: { |
| 194 | callOverlayButtonGroupRect.chatButtonClicked() |
| 195 | } |
| 196 | |
| 197 | onButtonEntered: { |
| 198 | callOverlayButtonGroupRect.buttonEntered() |
| 199 | } |
| 200 | |
| 201 | onVisibleChanged: { |
| 202 | if (this.visible) |
| 203 | buttonCounts++ |
| 204 | else |
| 205 | buttonCounts-- |
| 206 | } |
| 207 | } |
| 208 | |
| 209 | TintedButton { |
| 210 | id: noMicButton |
| 211 | |
| 212 | width: buttonPreferredSize |
| 213 | height: buttonPreferredSize |
| 214 | |
| 215 | tintColor: JamiTheme.buttonTintedBlue |
| 216 | normalPixmapSource: "qrc:/images/icons/ic_mic_white_24dp.png" |
| 217 | selectedPixmapSource: "qrc:/images/icons/ic_mic_off_white_24dp.png" |
| 218 | |
| 219 | onClicked: { |
| 220 | CallAdapter.muteThisCallToggle() |
| 221 | } |
| 222 | |
| 223 | onButtonEntered: { |
| 224 | callOverlayButtonGroupRect.buttonEntered() |
| 225 | } |
| 226 | |
| 227 | onVisibleChanged: { |
| 228 | if (this.visible) |
| 229 | buttonCounts++ |
| 230 | else |
| 231 | buttonCounts-- |
| 232 | } |
| 233 | } |
| 234 | |
| 235 | TintedButton { |
| 236 | id: noVideoButton |
| 237 | |
| 238 | width: buttonPreferredSize |
| 239 | height: buttonPreferredSize |
| 240 | |
| 241 | tintColor: JamiTheme.buttonTintedBlue |
| 242 | normalPixmapSource: "qrc:/images/icons/ic_videocam_white.png" |
| 243 | selectedPixmapSource: "qrc:/images/icons/ic_videocam_off_white_24dp.png" |
| 244 | |
| 245 | onButtonEntered: { |
| 246 | callOverlayButtonGroupRect.buttonEntered() |
| 247 | } |
| 248 | |
| 249 | onClicked: { |
| 250 | CallAdapter.videoPauseThisCallToggle() |
| 251 | } |
| 252 | |
| 253 | onVisibleChanged: { |
| 254 | if (this.visible) |
| 255 | buttonCounts++ |
| 256 | else |
| 257 | buttonCounts-- |
| 258 | } |
| 259 | } |
| 260 | |
| 261 | TintedButton { |
| 262 | id: recButton |
| 263 | |
| 264 | width: buttonPreferredSize |
| 265 | height: buttonPreferredSize |
| 266 | |
| 267 | tintColor: JamiTheme.buttonTintedBlue |
| 268 | normalPixmapSource: "qrc:/images/icons/ic_voicemail_white_24dp_2x.png" |
| 269 | selectedPixmapSource: "qrc:/images/icons/ic_voicemail_white_24dp_2x.png" |
| 270 | |
| 271 | onButtonEntered: { |
| 272 | callOverlayButtonGroupRect.buttonEntered() |
| 273 | } |
| 274 | |
| 275 | onClicked: { |
| 276 | CallAdapter.recordThisCallToggle() |
| 277 | } |
| 278 | |
| 279 | onVisibleChanged: { |
| 280 | if (this.visible) |
| 281 | buttonCounts++ |
| 282 | else |
| 283 | buttonCounts-- |
| 284 | } |
| 285 | } |
| 286 | |
| 287 | TintedButton { |
| 288 | id: sipInputPanelButton |
| 289 | |
| 290 | width: buttonPreferredSize |
| 291 | height: buttonPreferredSize |
| 292 | |
| 293 | tintColor: JamiTheme.buttonTintedBlue |
| 294 | normalPixmapSource: "qrc:/images/icons/icon-keypad-24-2x.png" |
| 295 | selectedPixmapSource: "qrc:/images/icons/icon-keypad-24-2x.png" |
| 296 | |
| 297 | onButtonEntered: { |
| 298 | callOverlayButtonGroupRect.buttonEntered() |
| 299 | } |
| 300 | |
| 301 | onVisibleChanged: { |
| 302 | if (this.visible) |
| 303 | buttonCounts++ |
| 304 | else |
| 305 | buttonCounts-- |
| 306 | } |
| 307 | } |
| 308 | } |
| 309 | |
| 310 | color: "transparent" |
| 311 | } |