| 1 |
// SPDX-FileCopyrightText: Nheko Contributors |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: GPL-3.0-or-later |
| 4 |
|
| 5 |
import "../" |
| 6 |
import QtQuick 2.9 |
| 7 |
import QtQuick.Controls 2.3 |
| 8 |
import QtQuick.Layouts 1.2 |
| 9 |
import im.nheko 1.0 |
| 10 |
|
| 11 |
Popup { |
| 12 |
modal: true |
| 13 |
// only set the anchors on Qt 5.12 or higher |
| 14 |
// see https://doc.qt.io/qt-5/qml-qtquick-controls2-popup.html#anchors.centerIn-prop |
| 15 |
Component.onCompleted: { |
| 16 |
if (anchors) |
| 17 |
anchors.centerIn = parent; |
| 18 |
|
| 19 |
} |
| 20 |
|
| 21 |
Component { |
| 22 |
id: deviceError |
| 23 |
|
| 24 |
DeviceError { |
| 25 |
} |
| 26 |
|
| 27 |
} |
| 28 |
|
| 29 |
ColumnLayout { |
| 30 |
id: columnLayout |
| 31 |
|
| 32 |
spacing: 16 |
| 33 |
|
| 34 |
RowLayout { |
| 35 |
Layout.topMargin: 8 |
| 36 |
Layout.leftMargin: 8 |
| 37 |
|
| 38 |
Label { |
| 39 |
text: qsTr("Place a call to %1?").arg(room.roomName) |
| 40 |
color: palette.windowText |
| 41 |
} |
| 42 |
|
| 43 |
Item { |
| 44 |
Layout.fillWidth: true |
| 45 |
} |
| 46 |
|
| 47 |
} |
| 48 |
|
| 49 |
RowLayout { |
| 50 |
id: buttonLayout |
| 51 |
|
| 52 |
function validateMic() { |
| 53 |
if (CallManager.mics.length == 0) { |
| 54 |
var dialog = deviceError.createObject(timelineRoot, { |
| 55 |
"errorString": qsTr("No microphone found."), |
| 56 |
"image": ":/icons/icons/ui/place-call.svg" |
| 57 |
}); |
| 58 |
dialog.open(); |
| 59 |
timelineRoot.destroyOnClose(dialog); |
| 60 |
return false; |
| 61 |
} |
| 62 |
return true; |
| 63 |
} |
| 64 |
|
| 65 |
Layout.leftMargin: 8 |
| 66 |
Layout.rightMargin: 8 |
| 67 |
|
| 68 |
Avatar { |
| 69 |
Layout.rightMargin: cameraCombo.visible ? 16 : 64 |
| 70 |
Layout.preferredWidth: Nheko.avatarSize |
| 71 |
Layout.preferredHeight: Nheko.avatarSize |
| 72 |
url: room.roomAvatarUrl.replace("mxc://", "image://MxcImage/") |
| 73 |
displayName: room.roomName |
| 74 |
roomid: room.roomId |
| 75 |
onClicked: TimelineManager.openImageOverlay(room, room.avatarUrl(userid), room.data.eventId) |
| 76 |
} |
| 77 |
|
| 78 |
Button { |
| 79 |
text: qsTr("Voice") |
| 80 |
icon.source: "qrc:/icons/icons/ui/place-call.svg" |
| 81 |
onClicked: { |
| 82 |
if (buttonLayout.validateMic()) { |
| 83 |
Settings.microphone = micCombo.currentText; |
| 84 |
CallManager.sendInvite(room.roomId, Voip.VOICE); |
| 85 |
close(); |
| 86 |
} |
| 87 |
} |
| 88 |
} |
| 89 |
|
| 90 |
Button { |
| 91 |
visible: CallManager.cameras.length > 0 |
| 92 |
text: qsTr("Video") |
| 93 |
icon.source: "qrc:/icons/icons/ui/video.svg" |
| 94 |
onClicked: { |
| 95 |
if (buttonLayout.validateMic()) { |
| 96 |
Settings.microphone = micCombo.currentText; |
| 97 |
Settings.camera = cameraCombo.currentText; |
| 98 |
CallManager.sendInvite(room.roomId, Voip.VIDEO); |
| 99 |
close(); |
| 100 |
} |
| 101 |
} |
| 102 |
} |
| 103 |
|
| 104 |
Button { |
| 105 |
text: qsTr("Screen") |
| 106 |
icon.source: "qrc:/icons/icons/ui/screen-share.svg" |
| 107 |
onClicked: { |
| 108 |
if (buttonLayout.validateMic()) { |
| 109 |
Settings.microphone = micCombo.currentText; |
| 110 |
Settings.camera = cameraCombo.currentText; |
| 111 |
|
| 112 |
var dialog = screenShareDialog.createObject(timelineRoot); |
| 113 |
dialog.open(); |
| 114 |
timelineRoot.destroyOnClose(dialog); |
| 115 |
close(); |
| 116 |
} |
| 117 |
} |
| 118 |
} |
| 119 |
|
| 120 |
Button { |
| 121 |
text: qsTr("Cancel") |
| 122 |
onClicked: { |
| 123 |
close(); |
| 124 |
} |
| 125 |
} |
| 126 |
|
| 127 |
} |
| 128 |
|
| 129 |
ColumnLayout { |
| 130 |
spacing: 8 |
| 131 |
|
| 132 |
RowLayout { |
| 133 |
Layout.leftMargin: 8 |
| 134 |
Layout.rightMargin: 8 |
| 135 |
Layout.bottomMargin: cameraCombo.visible ? 0 : 8 |
| 136 |
|
| 137 |
Image { |
| 138 |
Layout.preferredWidth: 22 |
| 139 |
Layout.preferredHeight: 22 |
| 140 |
source: "image://colorimage/:/icons/icons/ui/microphone-unmute.svg?" + palette.windowText |
| 141 |
} |
| 142 |
|
| 143 |
ComboBox { |
| 144 |
id: micCombo |
| 145 |
|
| 146 |
Layout.fillWidth: true |
| 147 |
model: CallManager.mics |
| 148 |
} |
| 149 |
|
| 150 |
} |
| 151 |
|
| 152 |
RowLayout { |
| 153 |
visible: CallManager.cameras.length > 0 |
| 154 |
Layout.leftMargin: 8 |
| 155 |
Layout.rightMargin: 8 |
| 156 |
Layout.bottomMargin: 8 |
| 157 |
|
| 158 |
Image { |
| 159 |
Layout.preferredWidth: 22 |
| 160 |
Layout.preferredHeight: 22 |
| 161 |
source: "image://colorimage/:/icons/icons/ui/video.svg?" + palette.windowText |
| 162 |
} |
| 163 |
|
| 164 |
ComboBox { |
| 165 |
id: cameraCombo |
| 166 |
|
| 167 |
Layout.fillWidth: true |
| 168 |
model: CallManager.cameras |
| 169 |
} |
| 170 |
|
| 171 |
} |
| 172 |
|
| 173 |
} |
| 174 |
|
| 175 |
} |
| 176 |
|
| 177 |
background: Rectangle { |
| 178 |
color: palette.window |
| 179 |
border.color: palette.windowText |
| 180 |
} |
| 181 |
|
| 182 |
} |