blob: 23da3fd700184a619072fef6b35d1437f70e9a46 [file] [log] [blame]
agsantos655d8e22020-08-10 17:36:47 -04001/**
Sébastien Blin8940f3c2020-07-23 17:03:11 -04002 * Copyright (C) 2020 by Savoir-faire Linux
3 * Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com>
4 * Author: Sébastien Blin <sebastien.blin@savoirfairelinux.com>
agsantos655d8e22020-08-10 17:36:47 -04005 * Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com>
Sébastien Blin8940f3c2020-07-23 17:03:11 -04006 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20import QtQuick 2.14
21import QtQuick.Controls 2.14
22import QtGraphicalEffects 1.12
23import net.jami.Models 1.0
24
25import "../../commoncomponents"
26
27import "../js/videodevicecontextmenuitemcreation.js" as VideoDeviceContextMenuItemCreation
28import "../js/selectscreenwindowcreation.js" as SelectScreenWindowCreation
29
30Menu {
31 id: root
32
33 property int generalMenuSeparatorCount: 0
34 property int commonBorderWidth: 1
agsantos655d8e22020-08-10 17:36:47 -040035
36 signal pluginItemClicked
37
Sébastien Blin8940f3c2020-07-23 17:03:11 -040038 font.pointSize: JamiTheme.textFontSize+3
39
40 property bool isSIP: false
41 property bool isPaused: false
42 property bool isAudioOnly: false
43 property bool isRecording: false
44
45 signal transferCallButtonClicked
46
47 function activate() {
48 var deviceContextMenuInfoMap = AvAdapter.populateVideoDeviceContextMenuItem()
49 /*
50 * Somehow, the map size is undefined, so use this instead.
51 */
52 var mapSize = deviceContextMenuInfoMap["size"]
53
54 var count = 2
55 for (var deviceName in deviceContextMenuInfoMap) {
56 if (deviceName === "size" || root.isAudioOnly)
57 continue
58 if (videoDeviceItem.itemName === "No video device") {
59 videoDeviceItem.checkable = true
60 videoDeviceItem.itemName = deviceName
61 videoDeviceItem.checked = deviceContextMenuInfoMap[deviceName]
62 if (count === mapSize)
63 root.open()
64 } else {
65 VideoDeviceContextMenuItemCreation.createVideoDeviceContextMenuItemObjects(
66 deviceName, deviceContextMenuInfoMap[deviceName],
67 count === mapSize)
68 }
69 count++
70 }
71 root.open()
72 }
73
74 Component.onCompleted: {
75 VideoDeviceContextMenuItemCreation.setVideoContextMenuObject(root)
76 }
77
78
79 onClosed: {
80 videoDeviceItem.itemName = "No video device"
81 VideoDeviceContextMenuItemCreation.removeCreatedItems()
82 }
83
84 JamiFileDialog {
85 id: jamiFileDialog
86
87 mode: JamiFileDialog.Mode.OpenFile
88
89 onAccepted: {
90 // No need to trim file:///.
91 AvAdapter.shareFile(jamiFileDialog.file)
92 }
93 }
94
95 /*
96 * All GeneralMenuItems should remain the same width / height.
97 */
98 GeneralMenuItem {
99 id: holdCallButton
100
101 visible: isSIP
102 height: isSIP? undefined : 0
103
104 itemName: isPaused? qsTr("Resume call") : qsTr("Hold call")
105 iconSource: isPaused? "qrc:/images/icons/play_circle_outline-24px.svg" : "qrc:/images/icons/pause_circle_outline-24px.svg"
106 leftBorderWidth: commonBorderWidth
107 rightBorderWidth: commonBorderWidth
108
109 onClicked: {
110 CallAdapter.holdThisCallToggle()
111 root.close()
112 }
113 }
114
115 GeneralMenuItem {
116 id: transferCallButton
117
118 visible: isSIP
119 height: isSIP? undefined : 0
120
121 itemName: qsTr("Transfer call")
122 iconSource: "qrc:/images/icons/phone_forwarded-24px.svg"
123 leftBorderWidth: commonBorderWidth
124 rightBorderWidth: commonBorderWidth
125
126 onClicked: {
127 root.transferCallButtonClicked()
128 root.close()
129 }
130 }
131
132 GeneralMenuSeparator {
133 preferredWidth: startRecordingItem.preferredWidth
134 preferredHeight: commonBorderWidth
135
136 visible: isSIP
137 height: isSIP? undefined : 0
138
139 Component.onCompleted: {
140 generalMenuSeparatorCount++
141 }
142 }
143
144 GeneralMenuItem {
145 id: startRecordingItem
146
147 itemName: isRecording? qsTr("Stop recording") : qsTr("Start recording")
148 iconSource: "qrc:/images/icons/ic_video_call_24px.svg"
149 leftBorderWidth: commonBorderWidth
150 rightBorderWidth: commonBorderWidth
151
152 onClicked: {
153 root.close()
154 CallAdapter.recordThisCallToggle()
155 }
156 }
157
158 GeneralMenuItem {
159 id: fullScreenItem
160
161 itemName: videoCallPage.isFullscreen ? qsTr("Exit full screen") : qsTr(
162 "Full screen mode")
163 iconSource: videoCallPage.isFullscreen ? "qrc:/images/icons/close_fullscreen-24px.svg" : "qrc:/images/icons/open_in_full-24px.svg"
164 leftBorderWidth: commonBorderWidth
165 rightBorderWidth: commonBorderWidth
166
167 onClicked: {
168 root.close()
169 videoCallPageRect.needToShowInFullScreen()
170 }
171 }
172
173 GeneralMenuSeparator {
174 preferredWidth: startRecordingItem.preferredWidth
175 preferredHeight: commonBorderWidth
176
177 Component.onCompleted: {
178 generalMenuSeparatorCount++
179 }
180 }
181
182 VideoCallPageContextMenuDeviceItem {
183 id: videoDeviceItem
184 visible: !isAudioOnly
185 height: !isAudioOnly? undefined : 0
186
187 contextMenuPreferredWidth: root.implicitWidth
188 }
189
190 GeneralMenuSeparator {
191 preferredWidth: startRecordingItem.preferredWidth
192 preferredHeight: commonBorderWidth
193 visible: !isAudioOnly
194 height: !isAudioOnly? undefined : 0
195
196 Component.onCompleted: {
197 generalMenuSeparatorCount++
198 }
199 }
200
201 GeneralMenuItem {
202 id: shareEntireScreenItem
203
204 itemName: qsTr("Share entire screen")
205 iconSource: "qrc:/images/icons/screen_share-24px.svg"
206 leftBorderWidth: commonBorderWidth
207 rightBorderWidth: commonBorderWidth
208 visible: !isAudioOnly
209 height: !isAudioOnly? undefined : 0
210
211 onClicked: {
212 root.close()
213 if (Qt.application.screens.length === 1) {
214 AvAdapter.shareEntireScreen(0)
215 } else {
216 SelectScreenWindowCreation.createSelectScreenWindowObject()
217 SelectScreenWindowCreation.showSelectScreenWindow()
218 }
219 }
220 }
221
222 GeneralMenuItem {
223 id: shareScreenAreaItem
224
225 itemName: qsTr("Share screen area")
226 iconSource: "qrc:/images/icons/screen_share-24px.svg"
227 leftBorderWidth: commonBorderWidth
228 rightBorderWidth: commonBorderWidth
229 visible: !isAudioOnly
230 height: !isAudioOnly? undefined : 0
231
232 onClicked: {
233 root.close()
234 if (Qt.application.screens.length === 1) {
235 ScreenRubberBandCreation.createScreenRubberBandWindowObject(
236 null, 0)
237 ScreenRubberBandCreation.showScreenRubberBandWindow()
238 } else {
239 SelectScreenWindowCreation.createSelectScreenWindowObject(true)
240 SelectScreenWindowCreation.showSelectScreenWindow()
241 }
242 }
243 }
244
245 GeneralMenuItem {
246 id: shareFileItem
247
248 itemName: qsTr("Share file")
249 iconSource: "qrc:/images/icons/insert_photo-24px.svg"
250 leftBorderWidth: commonBorderWidth
251 rightBorderWidth: commonBorderWidth
252 visible: !isAudioOnly
253 height: !isAudioOnly? undefined : 0
254
255 onClicked: {
256 root.close()
257 jamiFileDialog.open()
258 }
259 }
260
261 /* TODO: In the future we want to implement this
262
263 GeneralMenuItem {
264 id: advancedInfosItem
265
266 itemName: qsTr("Advanced informations")
267 iconSource: "qrc:/images/icons/info-24px.svg"
268 leftBorderWidth: commonBorderWidth
269 rightBorderWidth: commonBorderWidth
270
271 onClicked: {
272 root.close()
273 }
agsantos655d8e22020-08-10 17:36:47 -0400274 }*/
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400275
276 GeneralMenuItem {
277 id: pluginItem
278
279 itemName: qsTr("Toggle plugin")
280 iconSource: "qrc:/images/icons/extension_24dp.svg"
281 leftBorderWidth: commonBorderWidth
282 rightBorderWidth: commonBorderWidth
283
284 onClicked: {
agsantos655d8e22020-08-10 17:36:47 -0400285 root.pluginItemClicked()
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400286 root.close()
287 }
agsantos655d8e22020-08-10 17:36:47 -0400288 }
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400289
290 background: Rectangle {
291 implicitWidth: startRecordingItem.preferredWidth
292 implicitHeight: startRecordingItem.preferredHeight
293 * (root.count
294 - (isSIP? 0 : 2)
295 - (isAudioOnly? 6 : 0)
296 - generalMenuSeparatorCount)
297
298 border.width: commonBorderWidth
299 border.color: JamiTheme.tabbarBorderColor
300 }
301}
302