Debian Codegraph @

resources/qml/voip/CallInvite.qml

raw
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 id: callInv
13
14 closePolicy: Popup.NoAutoClose
15 width: parent.width
16 height: parent.height
17
18 Component {
19 id: deviceError
20
21 DeviceError {
22 }
23
24 }
25
26 Connections {
27 function onNewInviteState() {
28 if (!CallManager.haveCallInvite)
29 close();
30
31 }
32
33 target: CallManager
34 }
35
36 ColumnLayout {
37 anchors.top: parent.top
38 anchors.bottom: parent.bottom
39 anchors.horizontalCenter: parent.horizontalCenter
40
41 Label {
42 Layout.alignment: Qt.AlignCenter
43 Layout.topMargin: callInv.parent.height / 25
44 Layout.fillWidth: true
45 text: CallManager.callPartyDisplayName
46 font.pointSize: fontMetrics.font.pointSize * 2
47 color: palette.windowText
48 horizontalAlignment: Text.AlignHCenter
49 }
50
51 Avatar {
52 Layout.alignment: Qt.AlignCenter
53 Layout.preferredHeight: callInv.height / 5
54 Layout.preferredWidth: callInv.height / 5
55 url: CallManager.callPartyAvatarUrl.replace("mxc://", "image://MxcImage/")
56 userid: CallManager.callParty
57 displayName: CallManager.callPartyDisplayName
58 }
59
60 ColumnLayout {
61 Layout.alignment: Qt.AlignCenter
62 Layout.bottomMargin: callInv.height / 25
63
64 Image {
65 property string image: CallManager.callType == Voip.VIDEO ? ":/icons/icons/ui/video.svg" : ":/icons/icons/ui/place-call.svg"
66
67 Layout.alignment: Qt.AlignCenter
68 Layout.preferredWidth: callInv.height / 10
69 Layout.preferredHeight: callInv.height / 10
70 source: "image://colorimage/" + image + "?" + palette.windowText
71 }
72
73 Label {
74 Layout.alignment: Qt.AlignCenter
75 text: CallManager.callType == Voip.VIDEO ? qsTr("Video Call") : qsTr("Voice Call")
76 font.pointSize: fontMetrics.font.pointSize * 2
77 color: palette.windowText
78 }
79
80 }
81
82 ColumnLayout {
83 id: deviceCombos
84
85 property int imageSize: callInv.height / 20
86
87 Layout.alignment: Qt.AlignCenter
88 Layout.bottomMargin: callInv.height / 25
89
90 RowLayout {
91 Layout.alignment: Qt.AlignCenter
92
93 Image {
94 Layout.preferredWidth: deviceCombos.imageSize
95 Layout.preferredHeight: deviceCombos.imageSize
96 source: "image://colorimage/:/icons/icons/ui/microphone-unmute.svg?" + palette.windowText
97 }
98
99 ComboBox {
100 id: micCombo
101
102 Layout.fillWidth: true
103 model: CallManager.mics
104 }
105
106 }
107
108 RowLayout {
109 visible: CallManager.callType == Voip.VIDEO && CallManager.cameras.length > 0
110 Layout.alignment: Qt.AlignCenter
111
112 Image {
113 Layout.preferredWidth: deviceCombos.imageSize
114 Layout.preferredHeight: deviceCombos.imageSize
115 source: "image://colorimage/:/icons/icons/ui/video.svg?" + palette.windowText
116 }
117
118 ComboBox {
119 id: cameraCombo
120
121 Layout.fillWidth: true
122 model: CallManager.cameras
123 }
124
125 }
126
127 }
128
129 RowLayout {
130 id: buttonLayout
131
132 property int buttonSize: callInv.height / 8
133
134 function validateMic() {
135 if (CallManager.mics.length == 0) {
136 var dialog = deviceError.createObject(timelineRoot, {
137 "errorString": qsTr("No microphone found."),
138 "image": ":/icons/icons/ui/place-call.svg"
139 });
140 dialog.open();
141 timelineRoot.destroyOnClose(dialog);
142 return false;
143 }
144 return true;
145 }
146
147 Layout.alignment: Qt.AlignCenter
148 spacing: callInv.height / 6
149
150 RoundButton {
151 implicitWidth: buttonLayout.buttonSize
152 implicitHeight: buttonLayout.buttonSize
153 onClicked: {
154 CallManager.rejectInvite();
155 close();
156 }
157
158 background: Rectangle {
159 radius: buttonLayout.buttonSize / 2
160 color: "#ff0000"
161 }
162
163 contentItem: Image {
164 source: "image://colorimage/:/icons/icons/ui/end-call.svg?#ffffff"
165 }
166
167 }
168
169 RoundButton {
170 id: acceptButton
171
172 property string image: CallManager.callType == Voip.VIDEO ? ":/icons/icons/ui/video.svg" : ":/icons/icons/ui/place-call.svg"
173
174 implicitWidth: buttonLayout.buttonSize
175 implicitHeight: buttonLayout.buttonSize
176 onClicked: {
177 if (buttonLayout.validateMic()) {
178 Settings.microphone = micCombo.currentText;
179 if (cameraCombo.visible)
180 Settings.camera = cameraCombo.currentText;
181
182 CallManager.acceptInvite();
183 close();
184 }
185 }
186
187 background: Rectangle {
188 radius: buttonLayout.buttonSize / 2
189 color: "#00ff00"
190 }
191
192 contentItem: Image {
193 source: "image://colorimage/" + acceptButton.image + "?#ffffff"
194 }
195
196 }
197
198 }
199
200 }
201
202 background: Rectangle {
203 color: palette.window
204 border.color: palette.windowText
205 }
206
207 }