matrixion/resources/qml/voip/CallInvite.qml

201 lines
5.7 KiB
QML
Raw Normal View History

2021-03-05 02:35:15 +03:00
// SPDX-FileCopyrightText: 2021 Nheko Contributors
// SPDX-License-Identifier: GPL-3.0-or-later
2021-01-12 22:22:52 +03:00
import "../"
import QtQuick 2.9
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.2
import im.nheko 1.0
Popup {
closePolicy: Popup.NoAutoClose
width: parent.width
height: parent.height
palette: colors
Component {
id: deviceError
2021-01-17 06:05:02 +03:00
2021-01-12 22:22:52 +03:00
DeviceError {
}
2021-01-17 06:05:02 +03:00
2021-01-12 22:22:52 +03:00
}
Connections {
target: CallManager
onNewInviteState: {
2021-01-17 06:05:02 +03:00
if (!CallManager.haveCallInvite)
2021-01-12 22:22:52 +03:00
close();
2021-01-17 06:05:02 +03:00
2021-01-12 22:22:52 +03:00
}
}
ColumnLayout {
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter
Label {
Layout.alignment: Qt.AlignCenter
2021-01-14 00:00:41 +03:00
Layout.topMargin: msgView.height / 25
2021-01-12 22:22:52 +03:00
text: CallManager.callParty
font.pointSize: fontMetrics.font.pointSize * 2
color: colors.windowText
}
Avatar {
Layout.alignment: Qt.AlignCenter
2021-01-14 00:00:41 +03:00
width: msgView.height / 5
height: msgView.height / 5
2021-01-12 22:22:52 +03:00
url: CallManager.callPartyAvatarUrl.replace("mxc://", "image://MxcImage/")
displayName: CallManager.callParty
}
ColumnLayout {
Layout.alignment: Qt.AlignCenter
2021-01-14 00:00:41 +03:00
Layout.bottomMargin: msgView.height / 25
2021-01-12 22:22:52 +03:00
Image {
2021-02-18 23:55:29 +03:00
property string image: CallManager.callType == CallType.VIDEO ? ":/icons/icons/ui/video-call.png" : ":/icons/icons/ui/place-call.png"
2021-01-17 06:05:02 +03:00
2021-01-14 00:00:41 +03:00
Layout.alignment: Qt.AlignCenter
Layout.preferredWidth: msgView.height / 10
2021-01-17 06:05:02 +03:00
Layout.preferredHeight: msgView.height / 10
2021-01-12 22:22:52 +03:00
source: "image://colorimage/" + image + "?" + colors.windowText
}
Label {
Layout.alignment: Qt.AlignCenter
2021-02-18 23:55:29 +03:00
text: CallManager.callType == CallType.VIDEO ? qsTr("Video Call") : qsTr("Voice Call")
2021-01-12 22:22:52 +03:00
font.pointSize: fontMetrics.font.pointSize * 2
color: colors.windowText
}
2021-01-17 06:05:02 +03:00
2021-01-12 22:22:52 +03:00
}
ColumnLayout {
id: deviceCombos
2021-01-14 00:00:41 +03:00
property int imageSize: msgView.height / 20
2021-01-17 06:05:02 +03:00
2021-01-12 22:22:52 +03:00
Layout.alignment: Qt.AlignCenter
2021-01-14 00:00:41 +03:00
Layout.bottomMargin: msgView.height / 25
2021-01-12 22:22:52 +03:00
RowLayout {
Layout.alignment: Qt.AlignCenter
Image {
Layout.preferredWidth: deviceCombos.imageSize
Layout.preferredHeight: deviceCombos.imageSize
source: "image://colorimage/:/icons/icons/ui/microphone-unmute.png?" + colors.windowText
}
ComboBox {
id: micCombo
2021-01-17 06:05:02 +03:00
2021-01-12 22:22:52 +03:00
Layout.fillWidth: true
model: CallManager.mics
}
2021-01-17 06:05:02 +03:00
2021-01-12 22:22:52 +03:00
}
RowLayout {
2021-02-18 23:55:29 +03:00
visible: CallManager.callType == CallType.VIDEO && CallManager.cameras.length > 0
2021-01-12 22:22:52 +03:00
Layout.alignment: Qt.AlignCenter
Image {
Layout.preferredWidth: deviceCombos.imageSize
Layout.preferredHeight: deviceCombos.imageSize
source: "image://colorimage/:/icons/icons/ui/video-call.png?" + colors.windowText
}
ComboBox {
id: cameraCombo
2021-01-17 06:05:02 +03:00
2021-01-12 22:22:52 +03:00
Layout.fillWidth: true
model: CallManager.cameras
}
2021-01-17 06:05:02 +03:00
2021-01-12 22:22:52 +03:00
}
2021-01-17 06:05:02 +03:00
2021-01-12 22:22:52 +03:00
}
RowLayout {
id: buttonLayout
2021-01-14 00:00:41 +03:00
property int buttonSize: msgView.height / 8
2021-01-12 22:22:52 +03:00
function validateMic() {
if (CallManager.mics.length == 0) {
var dialog = deviceError.createObject(timelineRoot, {
"errorString": qsTr("No microphone found."),
"image": ":/icons/icons/ui/place-call.png"
});
dialog.open();
return false;
}
return true;
}
2021-01-17 06:05:02 +03:00
Layout.alignment: Qt.AlignCenter
spacing: msgView.height / 6
2021-01-12 22:22:52 +03:00
RoundButton {
2021-01-14 00:00:41 +03:00
implicitWidth: buttonLayout.buttonSize
implicitHeight: buttonLayout.buttonSize
2021-01-17 06:05:02 +03:00
onClicked: {
CallManager.hangUp();
close();
}
2021-01-14 00:00:41 +03:00
background: Rectangle {
radius: buttonLayout.buttonSize / 2
color: "#ff0000"
}
2021-01-17 06:05:02 +03:00
contentItem: Image {
2021-01-14 00:00:41 +03:00
source: "image://colorimage/:/icons/icons/ui/end-call.png?#ffffff"
}
2021-01-12 22:22:52 +03:00
}
RoundButton {
2021-01-14 00:00:41 +03:00
id: acceptButton
2021-02-18 23:55:29 +03:00
property string image: CallManager.callType == CallType.VIDEO ? ":/icons/icons/ui/video-call.png" : ":/icons/icons/ui/place-call.png"
2021-01-17 06:05:02 +03:00
2021-01-14 00:00:41 +03:00
implicitWidth: buttonLayout.buttonSize
implicitHeight: buttonLayout.buttonSize
2021-01-12 22:22:52 +03:00
onClicked: {
if (buttonLayout.validateMic()) {
Settings.microphone = micCombo.currentText;
if (cameraCombo.visible)
Settings.camera = cameraCombo.currentText;
2021-01-17 06:05:02 +03:00
2021-01-12 22:22:52 +03:00
CallManager.acceptInvite();
close();
}
}
2021-01-17 06:05:02 +03:00
background: Rectangle {
radius: buttonLayout.buttonSize / 2
color: "#00ff00"
}
contentItem: Image {
source: "image://colorimage/" + acceptButton.image + "?#ffffff"
}
2021-01-12 22:22:52 +03:00
}
2021-01-17 06:05:02 +03:00
2021-01-12 22:22:52 +03:00
}
2021-01-17 06:05:02 +03:00
2021-01-12 22:22:52 +03:00
}
2021-01-17 06:05:02 +03:00
background: Rectangle {
color: colors.window
border.color: colors.windowText
}
2021-01-12 22:22:52 +03:00
}