matrixion/resources/qml/voip/ActiveCallBar.qml

181 lines
5.1 KiB
QML
Raw Normal View History

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: {
2020-12-17 19:25:32 +03:00
if (CallManager.isVideo)
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 {
width: avatarSize
height: avatarSize
url: CallManager.callPartyAvatarUrl.replace("mxc://", "image://MxcImage/")
2020-12-17 19:25:32 +03:00
displayName: CallManager.callParty
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
2020-12-19 17:32:20 +03:00
text: CallManager.callParty
2020-12-30 23:03:07 +03:00
color: "#000000"
2020-10-08 22:11:21 +03:00
}
Image {
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
2020-12-17 19:25:32 +03:00
source: CallManager.isVideo ? "qrc:/icons/icons/ui/video-call.png" : "qrc:/icons/icons/ui/place-call.png"
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
2020-12-17 19:25:32 +03:00
currentIndex: CallManager.isVideo ? 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);
}
}
Item {
Layout.fillWidth: true
}
2020-11-09 18:51:17 +03:00
ImageButton {
2020-12-17 20:45:54 +03:00
visible: CallManager.haveLocalVideo
2020-11-09 18:51:17 +03:00
width: 24
height: 24
buttonTextColor: "#000000"
image: ":/icons/icons/ui/toggle-camera-view.png"
hoverEnabled: true
ToolTip.visible: hovered
2020-12-20 18:14:55 +03:00
ToolTip.text: qsTr("Toggle camera view")
onClicked: CallManager.toggleCameraView()
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"
image: CallManager.isMicMuted ? ":/icons/icons/ui/microphone-unmute.png" : ":/icons/icons/ui/microphone-mute.png"
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
}
}
}