matrixion/resources/qml/voip/ActiveCallBar.qml

231 lines
6.6 KiB
QML
Raw Normal View History

// SPDX-FileCopyrightText: Nheko Contributors
//
2021-03-05 02:35:15 +03:00
// SPDX-License-Identifier: GPL-3.0-or-later
2020-12-30 23:03:07 +03:00
import "../"
import QtQuick 2.9
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.2
import im.nheko 1.0
Rectangle {
visible: CallManager.isOnCall
2020-12-17 19:25:32 +03:00
color: callInviteBar.color
implicitHeight: visible ? rowLayout.height + 8 : 0
2020-10-08 22:11:21 +03:00
2020-10-27 20:14:06 +03:00
MouseArea {
anchors.fill: parent
2020-11-15 06:52:49 +03:00
onClicked: {
2021-02-22 00:30:10 +03:00
if (CallManager.callType != CallType.VOICE)
2020-11-15 06:52:49 +03:00
stackLayout.currentIndex = stackLayout.currentIndex ? 0 : 1;
}
2020-10-27 20:14:06 +03:00
}
2020-10-08 22:11:21 +03:00
RowLayout {
id: rowLayout
anchors.left: parent.left
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
anchors.leftMargin: 8
Avatar {
2021-05-13 12:32:20 +03:00
width: Nheko.avatarSize
height: Nheko.avatarSize
url: CallManager.callPartyAvatarUrl.replace("mxc://", "image://MxcImage/")
userid: CallManager.callParty
2021-09-05 03:54:02 +03:00
displayName: CallManager.callPartyDisplayName
onClicked: TimelineManager.openImageOverlay(room, room.avatarUrl(userid), room.data.eventId)
2020-10-08 22:11:21 +03:00
}
Label {
2020-12-19 17:32:20 +03:00
Layout.leftMargin: 8
2020-10-08 22:11:21 +03:00
font.pointSize: fontMetrics.font.pointSize * 1.1
2021-09-05 03:54:02 +03:00
text: CallManager.callPartyDisplayName
2020-12-30 23:03:07 +03:00
color: "#000000"
2020-10-08 22:11:21 +03:00
}
Image {
2021-02-18 23:55:29 +03:00
id: callTypeIcon
2020-12-19 17:32:20 +03:00
Layout.leftMargin: 4
2020-10-08 22:11:21 +03:00
Layout.preferredWidth: 24
Layout.preferredHeight: 24
2021-02-18 23:55:29 +03:00
}
Item {
states: [
State {
name: "VOICE"
when: CallManager.callType == CallType.VOICE
PropertyChanges {
target: callTypeIcon
2021-11-14 04:23:10 +03:00
source: "qrc:/icons/icons/ui/place-call.svg"
2021-02-18 23:55:29 +03:00
}
},
State {
name: "VIDEO"
when: CallManager.callType == CallType.VIDEO
PropertyChanges {
target: callTypeIcon
2021-11-14 04:23:10 +03:00
source: "qrc:/icons/icons/ui/video.svg"
2021-02-18 23:55:29 +03:00
}
},
State {
name: "SCREEN"
when: CallManager.callType == CallType.SCREEN
PropertyChanges {
target: callTypeIcon
2021-11-14 04:23:10 +03:00
source: "qrc:/icons/icons/ui/screen-share.svg"
2021-02-18 23:55:29 +03:00
}
}
]
2020-10-08 22:11:21 +03:00
}
Label {
id: callStateLabel
font.pointSize: fontMetrics.font.pointSize * 1.1
2020-12-30 23:03:07 +03:00
color: "#000000"
2020-10-08 22:11:21 +03:00
}
2020-11-25 23:54:54 +03:00
Item {
states: [
State {
2020-11-30 14:09:24 +03:00
name: "OFFERSENT"
when: CallManager.callState == WebRTCState.OFFERSENT
2020-11-30 14:09:24 +03:00
PropertyChanges {
target: callStateLabel
2020-12-20 18:14:55 +03:00
text: qsTr("Calling...")
2020-11-30 14:09:24 +03:00
}
2020-11-25 23:54:54 +03:00
},
State {
2020-11-30 14:09:24 +03:00
name: "CONNECTING"
when: CallManager.callState == WebRTCState.CONNECTING
2020-11-30 14:09:24 +03:00
PropertyChanges {
target: callStateLabel
2020-12-20 18:14:55 +03:00
text: qsTr("Connecting...")
2020-11-30 14:09:24 +03:00
}
2020-11-25 23:54:54 +03:00
},
State {
2020-11-30 14:09:24 +03:00
name: "ANSWERSENT"
when: CallManager.callState == WebRTCState.ANSWERSENT
2020-11-30 14:09:24 +03:00
PropertyChanges {
target: callStateLabel
2020-12-20 18:14:55 +03:00
text: qsTr("Connecting...")
2020-11-30 14:09:24 +03:00
}
2020-11-25 23:54:54 +03:00
},
State {
2020-11-30 14:09:24 +03:00
name: "CONNECTED"
when: CallManager.callState == WebRTCState.CONNECTED
2020-11-30 14:09:24 +03:00
PropertyChanges {
target: callStateLabel
text: "00:00"
}
PropertyChanges {
target: callTimer
startTime: Math.floor((new Date()).getTime() / 1000)
}
PropertyChanges {
target: stackLayout
2021-02-22 00:30:10 +03:00
currentIndex: CallManager.callType != CallType.VOICE ? 1 : 0
2020-11-30 14:09:24 +03:00
}
2020-11-25 23:54:54 +03:00
},
State {
2020-11-30 14:09:24 +03:00
name: "DISCONNECTED"
when: CallManager.callState == WebRTCState.DISCONNECTED
2020-11-30 14:09:24 +03:00
PropertyChanges {
target: callStateLabel
text: ""
}
PropertyChanges {
target: stackLayout
currentIndex: 0
}
2020-10-08 22:11:21 +03:00
}
2020-11-25 23:54:54 +03:00
]
2020-10-08 22:11:21 +03:00
}
Timer {
id: callTimer
property int startTime
function pad(n) {
return (n < 10) ? ("0" + n) : n;
}
interval: 1000
running: CallManager.callState == WebRTCState.CONNECTED
2020-10-08 22:11:21 +03:00
repeat: true
onTriggered: {
var d = new Date();
let seconds = Math.floor(d.getTime() / 1000 - startTime);
let s = Math.floor(seconds % 60);
let m = Math.floor(seconds / 60) % 60;
let h = Math.floor(seconds / 3600);
callStateLabel.text = (h ? (pad(h) + ":") : "") + pad(m) + ":" + pad(s);
}
}
2021-02-18 23:55:29 +03:00
Label {
Layout.leftMargin: 16
visible: CallManager.callType == CallType.SCREEN && CallManager.callState == WebRTCState.CONNECTED
text: qsTr("You are screen sharing")
font.pointSize: fontMetrics.font.pointSize * 1.1
color: "#000000"
}
2020-10-08 22:11:21 +03:00
Item {
Layout.fillWidth: true
}
2020-11-09 18:51:17 +03:00
ImageButton {
2021-02-22 00:30:10 +03:00
visible: CallManager.haveLocalPiP
2020-11-09 18:51:17 +03:00
width: 24
height: 24
buttonTextColor: "#000000"
2021-11-14 04:23:10 +03:00
image: ":/icons/icons/ui/picture-in-picture.svg"
2020-11-09 18:51:17 +03:00
hoverEnabled: true
ToolTip.visible: hovered
2021-02-22 00:30:10 +03:00
ToolTip.text: qsTr("Hide/Show Picture-in-Picture")
onClicked: CallManager.toggleLocalPiP()
2020-11-09 18:51:17 +03:00
}
2020-10-08 22:11:21 +03:00
ImageButton {
2020-12-30 23:03:07 +03:00
Layout.leftMargin: 8
Layout.rightMargin: 16
2020-10-08 22:11:21 +03:00
width: 24
height: 24
buttonTextColor: "#000000"
2021-11-14 04:23:10 +03:00
image: CallManager.isMicMuted ? ":/icons/icons/ui/microphone-unmute.svg" : ":/icons/icons/ui/microphone-mute.svg"
2020-10-08 22:11:21 +03:00
hoverEnabled: true
ToolTip.visible: hovered
ToolTip.text: CallManager.isMicMuted ? qsTr("Unmute Mic") : qsTr("Mute Mic")
onClicked: CallManager.toggleMicMute()
2020-10-08 22:11:21 +03:00
}
}
}