nheko/resources/qml/voip/ActiveCallBar.qml

226 lines
6.5 KiB
QML
Raw Normal View History

2020-12-30 21:03:07 +01: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 17:25:32 +01:00
color: callInviteBar.color
implicitHeight: visible ? rowLayout.height + 8 : 0
2020-10-08 21:11:21 +02:00
2020-10-27 18:14:06 +01:00
MouseArea {
anchors.fill: parent
2020-11-15 04:52:49 +01:00
onClicked: {
2021-02-21 22:30:10 +01:00
if (CallManager.callType != CallType.VOICE)
2020-11-15 04:52:49 +01:00
stackLayout.currentIndex = stackLayout.currentIndex ? 0 : 1;
}
2020-10-27 18:14:06 +01:00
}
2020-10-08 21:11:21 +02: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 17:25:32 +01:00
displayName: CallManager.callParty
2021-01-12 02:02:39 +01:00
onClicked: TimelineManager.openImageOverlay(TimelineManager.timeline.avatarUrl(userid), TimelineManager.timeline.data.id)
2020-10-08 21:11:21 +02:00
}
Label {
2020-12-19 15:32:20 +01:00
Layout.leftMargin: 8
2020-10-08 21:11:21 +02:00
font.pointSize: fontMetrics.font.pointSize * 1.1
2020-12-19 15:32:20 +01:00
text: CallManager.callParty
2020-12-30 21:03:07 +01:00
color: "#000000"
2020-10-08 21:11:21 +02:00
}
Image {
2021-02-18 21:55:29 +01:00
id: callTypeIcon
2020-12-19 15:32:20 +01:00
Layout.leftMargin: 4
2020-10-08 21:11:21 +02:00
Layout.preferredWidth: 24
Layout.preferredHeight: 24
2021-02-18 21:55:29 +01:00
}
Item {
states: [
State {
name: "VOICE"
when: CallManager.callType == CallType.VOICE
PropertyChanges {
target: callTypeIcon
source: "qrc:/icons/icons/ui/place-call.png"
}
},
State {
name: "VIDEO"
when: CallManager.callType == CallType.VIDEO
PropertyChanges {
target: callTypeIcon
source: "qrc:/icons/icons/ui/video-call.png"
}
},
State {
name: "SCREEN"
when: CallManager.callType == CallType.SCREEN
PropertyChanges {
target: callTypeIcon
source: "qrc:/icons/icons/ui/screen-share.png"
}
}
]
2020-10-08 21:11:21 +02:00
}
Label {
id: callStateLabel
font.pointSize: fontMetrics.font.pointSize * 1.1
2020-12-30 21:03:07 +01:00
color: "#000000"
2020-10-08 21:11:21 +02:00
}
2020-11-25 21:54:54 +01:00
Item {
states: [
State {
2020-11-30 12:09:24 +01:00
name: "OFFERSENT"
when: CallManager.callState == WebRTCState.OFFERSENT
2020-11-30 12:09:24 +01:00
PropertyChanges {
target: callStateLabel
2020-12-20 16:14:55 +01:00
text: qsTr("Calling...")
2020-11-30 12:09:24 +01:00
}
2020-11-25 21:54:54 +01:00
},
State {
2020-11-30 12:09:24 +01:00
name: "CONNECTING"
when: CallManager.callState == WebRTCState.CONNECTING
2020-11-30 12:09:24 +01:00
PropertyChanges {
target: callStateLabel
2020-12-20 16:14:55 +01:00
text: qsTr("Connecting...")
2020-11-30 12:09:24 +01:00
}
2020-11-25 21:54:54 +01:00
},
State {
2020-11-30 12:09:24 +01:00
name: "ANSWERSENT"
when: CallManager.callState == WebRTCState.ANSWERSENT
2020-11-30 12:09:24 +01:00
PropertyChanges {
target: callStateLabel
2020-12-20 16:14:55 +01:00
text: qsTr("Connecting...")
2020-11-30 12:09:24 +01:00
}
2020-11-25 21:54:54 +01:00
},
State {
2020-11-30 12:09:24 +01:00
name: "CONNECTED"
when: CallManager.callState == WebRTCState.CONNECTED
2020-11-30 12:09:24 +01:00
PropertyChanges {
target: callStateLabel
text: "00:00"
}
PropertyChanges {
target: callTimer
startTime: Math.floor((new Date()).getTime() / 1000)
}
PropertyChanges {
target: stackLayout
2021-02-21 22:30:10 +01:00
currentIndex: CallManager.callType != CallType.VOICE ? 1 : 0
2020-11-30 12:09:24 +01:00
}
2020-11-25 21:54:54 +01:00
},
State {
2020-11-30 12:09:24 +01:00
name: "DISCONNECTED"
when: CallManager.callState == WebRTCState.DISCONNECTED
2020-11-30 12:09:24 +01:00
PropertyChanges {
target: callStateLabel
text: ""
}
PropertyChanges {
target: stackLayout
currentIndex: 0
}
2020-10-08 21:11:21 +02:00
}
2020-11-25 21:54:54 +01:00
]
2020-10-08 21:11:21 +02: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 21:11:21 +02: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 21:55:29 +01: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 21:11:21 +02:00
Item {
Layout.fillWidth: true
}
2020-11-09 16:51:17 +01:00
ImageButton {
2021-02-21 22:30:10 +01:00
visible: CallManager.haveLocalPiP
2020-11-09 16:51:17 +01:00
width: 24
height: 24
buttonTextColor: "#000000"
image: ":/icons/icons/ui/toggle-camera-view.png"
hoverEnabled: true
ToolTip.visible: hovered
2021-02-21 22:30:10 +01:00
ToolTip.text: qsTr("Hide/Show Picture-in-Picture")
onClicked: CallManager.toggleLocalPiP()
2020-11-09 16:51:17 +01:00
}
2020-10-08 21:11:21 +02:00
ImageButton {
2020-12-30 21:03:07 +01:00
Layout.leftMargin: 8
Layout.rightMargin: 16
2020-10-08 21:11:21 +02: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 21:11:21 +02:00
hoverEnabled: true
ToolTip.visible: hovered
ToolTip.text: CallManager.isMicMuted ? qsTr("Unmute Mic") : qsTr("Mute Mic")
onClicked: CallManager.toggleMicMute()
2020-10-08 21:11:21 +02:00
}
}
}