matrixion/qml/voip/PlaceCall.qml

164 lines
5.2 KiB
QML
Raw Permalink Normal View History

2021-03-05 02:35:15 +03:00
// SPDX-FileCopyrightText: 2021 Nheko Contributors
// SPDX-FileCopyrightText: 2022 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
2020-12-18 20:49:24 +03:00
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.2
import im.nheko
2020-12-18 20:49:24 +03:00
2020-12-30 23:03:07 +03:00
Popup {
modal: true
2022-04-16 03:13:01 +03:00
palette: timelineRoot.palette
background: Rectangle {
border.color: timelineRoot.palette.windowText
color: timelineRoot.palette.window
}
2021-01-18 14:43:27 +03:00
// only set the anchors on Qt 5.12 or higher
// see https://doc.qt.io/qt-5/qml-qtquick-controls2-popup.html#anchors.centerIn-prop
Component.onCompleted: {
if (anchors)
anchors.centerIn = parent;
}
2020-12-18 20:49:24 +03:00
2020-12-30 23:03:07 +03:00
Component {
id: deviceError
DeviceError {
}
2020-12-18 20:49:24 +03:00
}
ColumnLayout {
id: columnLayout
spacing: 16
RowLayout {
Layout.leftMargin: 8
2022-04-16 03:13:01 +03:00
Layout.topMargin: 8
2020-12-18 20:49:24 +03:00
Label {
2022-04-11 05:18:16 +03:00
color: timelineRoot.palette.windowText
2022-04-16 03:13:01 +03:00
text: qsTr("Place a call to %1?").arg(room.roomName)
2020-12-18 20:49:24 +03:00
}
Item {
Layout.fillWidth: true
}
}
RowLayout {
2020-12-19 18:49:13 +03:00
id: buttonLayout
2020-12-18 20:49:24 +03:00
function validateMic() {
if (CallManager.mics.length == 0) {
2020-12-30 23:03:07 +03:00
var dialog = deviceError.createObject(timelineRoot, {
2022-04-16 03:13:01 +03:00
"errorString": qsTr("No microphone found."),
"image": ":/icons/icons/ui/place-call.svg"
});
2020-12-30 23:03:07 +03:00
dialog.open();
timelineRoot.destroyOnClose(dialog);
2020-12-18 20:49:24 +03:00
return false;
}
return true;
}
2021-01-12 01:51:39 +03:00
Layout.leftMargin: 8
Layout.rightMargin: 8
2020-12-18 20:49:24 +03:00
Avatar {
2020-12-30 23:03:07 +03:00
Layout.rightMargin: cameraCombo.visible ? 16 : 64
displayName: room.roomName
2022-04-16 03:13:01 +03:00
height: Nheko.avatarSize
roomid: room.roomId
2022-04-16 03:13:01 +03:00
url: room.roomAvatarUrl.replace("mxc://", "image://MxcImage/")
width: Nheko.avatarSize
onClicked: TimelineManager.openImageOverlay(room, room.avatarUrl(userid), room.data.eventId)
2020-12-18 20:49:24 +03:00
}
Button {
2021-11-14 04:23:10 +03:00
icon.source: "qrc:/icons/icons/ui/place-call.svg"
2022-04-16 03:13:01 +03:00
text: qsTr("Voice")
2020-12-18 20:49:24 +03:00
onClicked: {
2020-12-19 18:49:13 +03:00
if (buttonLayout.validateMic()) {
2021-01-12 01:51:39 +03:00
Settings.microphone = micCombo.currentText;
CallManager.sendInvite(room.roomId, Voip.VOICE);
2020-12-18 20:49:24 +03:00
close();
}
}
}
Button {
2021-11-14 04:23:10 +03:00
icon.source: "qrc:/icons/icons/ui/video.svg"
2022-04-16 03:13:01 +03:00
text: qsTr("Video")
visible: CallManager.cameras.length > 0
2020-12-18 20:49:24 +03:00
onClicked: {
2020-12-19 18:49:13 +03:00
if (buttonLayout.validateMic()) {
2021-01-12 01:51:39 +03:00
Settings.microphone = micCombo.currentText;
Settings.camera = cameraCombo.currentText;
CallManager.sendInvite(room.roomId, Voip.VIDEO);
2020-12-18 20:49:24 +03:00
close();
}
}
}
2021-02-18 23:55:29 +03:00
Button {
2021-11-14 04:23:10 +03:00
icon.source: "qrc:/icons/icons/ui/screen-share.svg"
2022-04-16 03:13:01 +03:00
text: qsTr("Screen")
visible: CallManager.screenShareSupported
2021-02-18 23:55:29 +03:00
onClicked: {
2022-03-13 22:40:09 +03:00
if (buttonLayout.validateMic()) {
Settings.microphone = micCombo.currentText;
Settings.camera = cameraCombo.currentText;
var dialog = screenShareDialog.createObject(timelineRoot);
dialog.open();
timelineRoot.destroyOnClose(dialog);
close();
}
2021-02-18 23:55:29 +03:00
}
}
2020-12-18 20:49:24 +03:00
Button {
text: qsTr("Cancel")
2022-04-16 03:13:01 +03:00
2020-12-18 20:49:24 +03:00
onClicked: {
close();
}
}
}
2020-12-20 18:33:22 +03:00
ColumnLayout {
spacing: 8
2020-12-19 18:49:13 +03:00
2020-12-20 18:33:22 +03:00
RowLayout {
2022-04-16 03:13:01 +03:00
Layout.bottomMargin: cameraCombo.visible ? 0 : 8
2020-12-20 18:33:22 +03:00
Layout.leftMargin: 8
Layout.rightMargin: 8
2020-12-19 18:49:13 +03:00
2020-12-20 18:33:22 +03:00
Image {
Layout.preferredHeight: 22
2022-04-16 03:13:01 +03:00
Layout.preferredWidth: 22
2022-04-11 05:18:16 +03:00
source: "image://colorimage/:/icons/icons/ui/microphone-unmute.svg?" + timelineRoot.palette.windowText
2020-12-20 18:33:22 +03:00
}
ComboBox {
id: micCombo
Layout.fillWidth: true
model: CallManager.mics
}
}
RowLayout {
2022-04-16 03:13:01 +03:00
Layout.bottomMargin: 8
2020-12-20 18:33:22 +03:00
Layout.leftMargin: 8
Layout.rightMargin: 8
2022-04-16 03:13:01 +03:00
visible: CallManager.cameras.length > 0
2020-12-20 18:33:22 +03:00
Image {
Layout.preferredHeight: 22
2022-04-16 03:13:01 +03:00
Layout.preferredWidth: 22
2022-04-11 05:18:16 +03:00
source: "image://colorimage/:/icons/icons/ui/video.svg?" + timelineRoot.palette.windowText
2020-12-20 18:33:22 +03:00
}
ComboBox {
id: cameraCombo
Layout.fillWidth: true
model: CallManager.cameras
}
2020-12-19 18:49:13 +03:00
}
}
2020-12-18 20:49:24 +03:00
}
}