nheko/resources/qml/voip/CallInvite.qml

210 lines
6.1 KiB
QML
Raw Normal View History

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