2023-02-22 01:48:49 +03:00
|
|
|
// SPDX-FileCopyrightText: Nheko Contributors
|
2021-03-07 07:57:56 +03:00
|
|
|
//
|
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 "../"
|
2021-01-12 17:03:39 +03:00
|
|
|
import QtQuick 2.9
|
2020-09-25 17:26:36 +03:00
|
|
|
import QtQuick.Controls 2.3
|
2021-01-12 17:03:39 +03:00
|
|
|
import QtQuick.Layouts 1.2
|
2020-09-25 17:26:36 +03:00
|
|
|
import im.nheko 1.0
|
|
|
|
|
|
|
|
Rectangle {
|
2020-12-10 04:49:48 +03:00
|
|
|
visible: CallManager.isOnCall
|
2020-12-17 19:25:32 +03:00
|
|
|
color: callInviteBar.color
|
2020-10-26 16:57:54 +03:00
|
|
|
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: {
|
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
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.leftMargin: 8
|
|
|
|
|
|
|
|
Avatar {
|
2023-10-26 17:43:09 +03:00
|
|
|
implicitWidth: Nheko.avatarSize
|
|
|
|
implicitHeight: Nheko.avatarSize
|
2020-12-10 04:49:48 +03:00
|
|
|
url: CallManager.callPartyAvatarUrl.replace("mxc://", "image://MxcImage/")
|
2021-09-01 04:53:12 +03:00
|
|
|
userid: CallManager.callParty
|
2021-09-05 03:54:02 +03:00
|
|
|
displayName: CallManager.callPartyDisplayName
|
2022-01-02 23:46:29 +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
|
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"
|
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
|
|
|
|
|
|
|
|
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"
|
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 {
|
|
|
|
target: stackLayout
|
2023-10-26 17:43:09 +03:00
|
|
|
currentIndex: 0 // qmllint disable Quick.property-changes-parsed
|
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
|
2023-06-19 02:38:40 +03:00
|
|
|
running: CallManager.callState == Voip.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
|
2023-06-19 02:38:40 +03:00
|
|
|
visible: CallManager.callType == Voip.SCREEN && CallManager.callState == Voip.CONNECTED
|
2021-02-18 23:55:29 +03:00
|
|
|
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
|
2023-10-26 17:43:09 +03:00
|
|
|
Layout.preferredWidth: 24
|
|
|
|
Layout.preferredHeight: 24
|
2020-11-09 18:51:17 +03:00
|
|
|
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
|
2023-10-26 17:43:09 +03:00
|
|
|
Layout.preferredWidth: 24
|
|
|
|
Layout.preferredHeight: 24
|
2020-10-08 22:11:21 +03:00
|
|
|
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
|
2020-12-10 04:49:48 +03:00
|
|
|
ToolTip.text: CallManager.isMicMuted ? qsTr("Unmute Mic") : qsTr("Mute Mic")
|
|
|
|
onClicked: CallManager.toggleMicMute()
|
2020-10-08 22:11:21 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-09-25 17:26:36 +03:00
|
|
|
}
|