matrixion/resources/qml/voip/ActiveCallBar.qml

206 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 {
2020-12-17 19:25:32 +03:00
color: callInviteBar.color
implicitHeight: visible ? rowLayout.height + 8 : 0
2023-10-31 05:11:03 +03:00
visible: CallManager.isOnCall
2020-10-08 22:11:21 +03:00
2020-10-27 20:14:06 +03:00
MouseArea {
anchors.fill: parent
2023-10-31 05:11:03 +03:00
2020-11-15 06:52:49 +03:00
onClicked: {
2023-06-19 02:38:40 +03:00
if (CallManager.callType != Voip.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
2023-10-31 05:11:03 +03:00
anchors.leftMargin: 8
2020-10-08 22:11:21 +03:00
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
Avatar {
2023-10-31 05:11:03 +03:00
displayName: CallManager.callPartyDisplayName
2023-10-26 17:43:09 +03:00
implicitHeight: Nheko.avatarSize
2023-10-31 05:11:03 +03:00
implicitWidth: Nheko.avatarSize
url: CallManager.callPartyAvatarUrl.replace("mxc://", "image://MxcImage/")
userid: CallManager.callParty
2023-10-31 05:11:03 +03:00
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
2023-10-31 05:11:03 +03:00
color: "#000000"
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-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.preferredHeight: 24
2023-10-31 05:11:03 +03:00
Layout.preferredWidth: 24
2021-02-18 23:55:29 +03:00
}
Item {
states: [
State {
name: "VOICE"
2023-06-19 02:38:40 +03:00
when: CallManager.callType == Voip.VOICE
2021-02-18 23:55:29 +03:00
PropertyChanges {
2023-10-26 17:43:09 +03:00
callTypeIcon.source: "qrc:/icons/icons/ui/place-call.svg"
2021-02-18 23:55:29 +03:00
}
},
State {
name: "VIDEO"
2023-06-19 02:38:40 +03:00
when: CallManager.callType == Voip.VIDEO
2021-02-18 23:55:29 +03:00
PropertyChanges {
2023-10-26 17:43:09 +03:00
callTypeIcon.source: "qrc:/icons/icons/ui/video.svg"
2021-02-18 23:55:29 +03:00
}
},
State {
name: "SCREEN"
2023-06-19 02:38:40 +03:00
when: CallManager.callType == Voip.SCREEN
2021-02-18 23:55:29 +03:00
PropertyChanges {
2023-10-26 17:43:09 +03:00
callTypeIcon.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
2020-12-30 23:03:07 +03:00
color: "#000000"
2023-10-31 05:11:03 +03:00
font.pointSize: fontMetrics.font.pointSize * 1.1
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"
2023-06-19 02:38:40 +03:00
when: CallManager.callState == Voip.OFFERSENT
2020-11-30 14:09:24 +03:00
PropertyChanges {
2023-10-26 17:43:09 +03:00
callStateLabel.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"
2023-06-19 02:38:40 +03:00
when: CallManager.callState == Voip.CONNECTING
2020-11-30 14:09:24 +03:00
PropertyChanges {
2023-10-26 17:43:09 +03:00
callStateLabel.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"
2023-06-19 02:38:40 +03:00
when: CallManager.callState == Voip.ANSWERSENT
2020-11-30 14:09:24 +03:00
PropertyChanges {
2023-10-26 17:43:09 +03:00
callStateLabel.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"
2023-06-19 02:38:40 +03:00
when: CallManager.callState == Voip.CONNECTED
2020-11-30 14:09:24 +03:00
PropertyChanges {
2023-10-26 17:43:09 +03:00
callStateLabel.text: "00:00"
2020-11-30 14:09:24 +03:00
}
PropertyChanges {
2023-10-26 17:43:09 +03:00
callTimer.startTime: Math.floor((new Date()).getTime() / 1000)
2020-11-30 14:09:24 +03:00
}
PropertyChanges {
2023-10-26 17:43:09 +03:00
stackLayout.currentIndex: CallManager.callType != Voip.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"
2023-06-19 02:38:40 +03:00
when: CallManager.callState == Voip.DISCONNECTED
2020-11-30 14:09:24 +03:00
PropertyChanges {
2023-10-26 17:43:09 +03:00
callStateLabel.text: ""
2020-11-30 14:09:24 +03:00
}
2023-10-26 17:43:09 +03:00
// HACK(Nico): Somehow this causes a crash when not using the custom parser for that property change...
//PropertyChanges {
// stackLayout.currentIndex: 0
//}
2020-11-30 14:09:24 +03:00
PropertyChanges {
2023-10-26 17:43:09 +03:00
currentIndex: 0 // qmllint disable Quick.property-changes-parsed
2023-10-31 05:11:03 +03:00
target: stackLayout
2020-11-30 14:09:24 +03:00
}
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
repeat: true
2023-10-31 05:11:03 +03:00
running: CallManager.callState == Voip.CONNECTED
2020-10-08 22:11:21 +03:00
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
color: "#000000"
2023-10-31 05:11:03 +03:00
font.pointSize: fontMetrics.font.pointSize * 1.1
text: qsTr("You are screen sharing")
visible: CallManager.callType == Voip.SCREEN && CallManager.callState == Voip.CONNECTED
2021-02-18 23:55:29 +03:00
}
2020-10-08 22:11:21 +03:00
Item {
Layout.fillWidth: true
}
2020-11-09 18:51:17 +03:00
ImageButton {
2023-10-26 17:43:09 +03:00
Layout.preferredHeight: 24
2023-10-31 05:11:03 +03:00
Layout.preferredWidth: 24
ToolTip.text: qsTr("Hide/Show Picture-in-Picture")
ToolTip.visible: hovered
2020-11-09 18:51:17 +03:00
buttonTextColor: "#000000"
hoverEnabled: true
2023-10-31 05:11:03 +03:00
image: ":/icons/icons/ui/picture-in-picture.svg"
visible: CallManager.haveLocalPiP
2021-02-22 00:30:10 +03:00
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
2023-10-26 17:43:09 +03:00
Layout.preferredHeight: 24
2023-10-31 05:11:03 +03:00
Layout.preferredWidth: 24
Layout.rightMargin: 16
ToolTip.text: CallManager.isMicMuted ? qsTr("Unmute Mic") : qsTr("Mute Mic")
ToolTip.visible: hovered
2020-10-08 22:11:21 +03:00
buttonTextColor: "#000000"
hoverEnabled: true
2023-10-31 05:11:03 +03:00
image: CallManager.isMicMuted ? ":/icons/icons/ui/microphone-unmute.svg" : ":/icons/icons/ui/microphone-mute.svg"
onClicked: CallManager.toggleMicMute()
2020-10-08 22:11:21 +03:00
}
}
}