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