nheko/resources/qml/voip/PlaceCall.qml

186 lines
4.9 KiB
QML
Raw Normal View History

2021-03-05 00:35:15 +01:00
// SPDX-FileCopyrightText: 2021 Nheko Contributors
//
2021-03-05 00:35:15 +01:00
// SPDX-License-Identifier: GPL-3.0-or-later
2020-12-30 21:03:07 +01:00
import "../"
import QtQuick 2.9
2020-12-18 18:49:24 +01:00
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.2
2020-12-18 18:49:24 +01:00
import im.nheko 1.0
2020-12-30 21:03:07 +01:00
Popup {
modal: true
2021-01-18 12:43:27 +01: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;
}
2021-05-13 08:23:56 +02:00
palette: Nheko.colors
2020-12-18 18:49:24 +01:00
2020-12-30 21:03:07 +01:00
Component {
id: deviceError
2021-01-11 23:51:39 +01:00
2020-12-30 21:03:07 +01:00
DeviceError {
}
2021-01-11 23:51:39 +01:00
2020-12-18 18:49:24 +01:00
}
2021-02-18 21:55:29 +01:00
Component {
id: screenShareDialog
ScreenShare {
}
}
2020-12-18 18:49:24 +01:00
ColumnLayout {
id: columnLayout
2020-12-19 16:49:13 +01:00
2020-12-18 18:49:24 +01:00
spacing: 16
RowLayout {
2020-12-30 21:03:07 +01:00
Layout.topMargin: 8
2020-12-18 18:49:24 +01:00
Layout.leftMargin: 8
Label {
text: qsTr("Place a call to %1?").arg(room.roomName)
2021-05-13 08:23:56 +02:00
color: Nheko.colors.windowText
2020-12-18 18:49:24 +01:00
}
Item {
Layout.fillWidth: true
}
2021-01-11 23:51:39 +01:00
2020-12-18 18:49:24 +01:00
}
RowLayout {
2020-12-19 16:49:13 +01:00
id: buttonLayout
2020-12-18 18:49:24 +01:00
function validateMic() {
if (CallManager.mics.length == 0) {
2020-12-30 21:03:07 +01:00
var dialog = deviceError.createObject(timelineRoot, {
"errorString": qsTr("No microphone found."),
2021-01-06 23:15:43 +01:00
"image": ":/icons/icons/ui/place-call.png"
2020-12-30 21:03:07 +01:00
});
dialog.open();
2020-12-18 18:49:24 +01:00
return false;
}
return true;
}
2021-01-11 23:51:39 +01:00
Layout.leftMargin: 8
Layout.rightMargin: 8
2020-12-18 18:49:24 +01:00
Avatar {
2020-12-30 21:03:07 +01:00
Layout.rightMargin: cameraCombo.visible ? 16 : 64
2021-05-13 11:32:20 +02:00
width: Nheko.avatarSize
height: Nheko.avatarSize
url: room.roomAvatarUrl.replace("mxc://", "image://MxcImage/")
displayName: room.roomName
roomid: room.roomid
onClicked: TimelineManager.openImageOverlay(room.avatarUrl(userid), room.data.eventId)
2020-12-18 18:49:24 +01:00
}
Button {
2021-01-15 13:57:19 +01:00
text: qsTr("Voice")
2020-12-18 18:49:24 +01:00
icon.source: "qrc:/icons/icons/ui/place-call.png"
onClicked: {
2020-12-19 16:49:13 +01:00
if (buttonLayout.validateMic()) {
2021-01-11 23:51:39 +01:00
Settings.microphone = micCombo.currentText;
2021-07-17 22:56:56 +02:00
CallManager.sendInvite(room.roomId, CallType.VOICE);
2020-12-18 18:49:24 +01:00
close();
}
}
}
Button {
visible: CallManager.cameras.length > 0
2021-01-15 13:57:19 +01:00
text: qsTr("Video")
2020-12-18 18:49:24 +01:00
icon.source: "qrc:/icons/icons/ui/video-call.png"
onClicked: {
2020-12-19 16:49:13 +01:00
if (buttonLayout.validateMic()) {
2021-01-11 23:51:39 +01:00
Settings.microphone = micCombo.currentText;
Settings.camera = cameraCombo.currentText;
2021-07-17 22:56:56 +02:00
CallManager.sendInvite(room.roomId, CallType.VIDEO);
2020-12-18 18:49:24 +01:00
close();
}
}
}
2021-02-18 21:55:29 +01:00
Button {
visible: CallManager.screenShareSupported
text: qsTr("Screen")
icon.source: "qrc:/icons/icons/ui/screen-share.png"
onClicked: {
var dialog = screenShareDialog.createObject(timelineRoot);
dialog.open();
close();
}
}
2020-12-18 18:49:24 +01:00
Button {
text: qsTr("Cancel")
onClicked: {
close();
}
}
2021-01-11 23:51:39 +01:00
2020-12-18 18:49:24 +01:00
}
2020-12-19 16:49:13 +01:00
2020-12-20 16:33:22 +01:00
ColumnLayout {
spacing: 8
2020-12-19 16:49:13 +01:00
2020-12-20 16:33:22 +01:00
RowLayout {
Layout.leftMargin: 8
Layout.rightMargin: 8
2020-12-30 21:03:07 +01:00
Layout.bottomMargin: cameraCombo.visible ? 0 : 8
2020-12-19 16:49:13 +01:00
2020-12-20 16:33:22 +01:00
Image {
Layout.preferredWidth: 22
Layout.preferredHeight: 22
2021-05-13 08:23:56 +02:00
source: "image://colorimage/:/icons/icons/ui/microphone-unmute.png?" + Nheko.colors.windowText
2020-12-20 16:33:22 +01:00
}
2020-12-19 16:49:13 +01:00
2020-12-20 16:33:22 +01:00
ComboBox {
id: micCombo
2021-01-11 23:51:39 +01:00
2020-12-20 16:33:22 +01:00
Layout.fillWidth: true
model: CallManager.mics
}
2021-01-11 23:51:39 +01:00
2020-12-20 16:33:22 +01:00
}
2020-12-19 16:49:13 +01:00
2020-12-20 16:33:22 +01:00
RowLayout {
visible: CallManager.cameras.length > 0
Layout.leftMargin: 8
Layout.rightMargin: 8
2020-12-30 21:03:07 +01:00
Layout.bottomMargin: 8
2020-12-20 16:33:22 +01:00
Image {
Layout.preferredWidth: 22
Layout.preferredHeight: 22
2021-05-13 08:23:56 +02:00
source: "image://colorimage/:/icons/icons/ui/video-call.png?" + Nheko.colors.windowText
2020-12-20 16:33:22 +01:00
}
2020-12-19 16:49:13 +01:00
2020-12-20 16:33:22 +01:00
ComboBox {
id: cameraCombo
2021-01-11 23:51:39 +01:00
2020-12-20 16:33:22 +01:00
Layout.fillWidth: true
model: CallManager.cameras
}
2021-01-11 23:51:39 +01:00
2020-12-19 16:49:13 +01:00
}
2021-01-11 23:51:39 +01:00
2020-12-19 16:49:13 +01:00
}
2021-01-11 23:51:39 +01:00
2020-12-18 18:49:24 +01:00
}
2021-01-11 23:51:39 +01:00
background: Rectangle {
2021-05-13 08:23:56 +02:00
color: Nheko.colors.window
border.color: Nheko.colors.windowText
2021-01-11 23:51:39 +01:00
}
2020-12-18 18:49:24 +01:00
}