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-01-15 15:57:19 +03:00
|
|
|
text: qsTr("Place a call to %1?").arg(TimelineManager.timeline.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-01-07 01:15:43 +03:00
|
|
|
"image": ":/icons/icons/ui/place-call.png"
|
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
|
2020-12-18 20:49:24 +03:00
|
|
|
url: TimelineManager.timeline.roomAvatarUrl.replace("mxc://", "image://MxcImage/")
|
|
|
|
displayName: TimelineManager.timeline.roomName
|
2021-01-12 04:02:39 +03:00
|
|
|
onClicked: TimelineManager.openImageOverlay(TimelineManager.timeline.avatarUrl(userid), TimelineManager.timeline.data.id)
|
2020-12-18 20:49:24 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
Button {
|
2021-01-15 15:57:19 +03:00
|
|
|
text: qsTr("Voice")
|
2020-12-18 20:49:24 +03:00
|
|
|
icon.source: "qrc:/icons/icons/ui/place-call.png"
|
|
|
|
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-02-18 23:55:29 +03:00
|
|
|
CallManager.sendInvite(TimelineManager.timeline.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")
|
2020-12-18 20:49:24 +03:00
|
|
|
icon.source: "qrc:/icons/icons/ui/video-call.png"
|
|
|
|
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-02-18 23:55:29 +03:00
|
|
|
CallManager.sendInvite(TimelineManager.timeline.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")
|
|
|
|
icon.source: "qrc:/icons/icons/ui/screen-share.png"
|
|
|
|
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-05-13 09:23:56 +03:00
|
|
|
source: "image://colorimage/:/icons/icons/ui/microphone-unmute.png?" + 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-05-13 09:23:56 +03:00
|
|
|
source: "image://colorimage/:/icons/icons/ui/video-call.png?" + 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
|
|
|
}
|