blob: 54ae0b26b52e096f89f28a038f169c4d2f572ae4 [file] [log] [blame]
agsantosc5687502020-09-03 21:19:10 -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 */
Ming Rui Zhang96808872020-08-27 12:59:09 -040020
Sébastien Blin8940f3c2020-07-23 17:03:11 -040021import QtQuick 2.14
22import QtQuick.Controls 2.14
23import QtGraphicalEffects 1.12
24import net.jami.Models 1.0
25
26import "../../commoncomponents"
27
Ming Rui Zhang96808872020-08-27 12:59:09 -040028import "../../commoncomponents/js/contextmenugenerator.js" as ContextMenuGenerator
Sébastien Blin8940f3c2020-07-23 17:03:11 -040029import "../js/videodevicecontextmenuitemcreation.js" as VideoDeviceContextMenuItemCreation
30import "../js/selectscreenwindowcreation.js" as SelectScreenWindowCreation
Ming Rui Zhang96808872020-08-27 12:59:09 -040031import "../js/screenrubberbandcreation.js" as ScreenRubberBandCreation
Sébastien Blin8940f3c2020-07-23 17:03:11 -040032
Ming Rui Zhang96808872020-08-27 12:59:09 -040033Item {
Sébastien Blin8940f3c2020-07-23 17:03:11 -040034 id: root
35
Sébastien Blin8940f3c2020-07-23 17:03:11 -040036 property bool isSIP: false
37 property bool isPaused: false
38 property bool isAudioOnly: false
39 property bool isRecording: false
40
Ming Rui Zhang96808872020-08-27 12:59:09 -040041 signal pluginItemClicked
Sébastien Blin8940f3c2020-07-23 17:03:11 -040042 signal transferCallButtonClicked
43
Ming Rui Zhang96808872020-08-27 12:59:09 -040044 function openMenu(){
45 if (isSIP){
46 ContextMenuGenerator.addMenuItem(isPaused ? qsTr("Resume call") : qsTr("Hold call"),
47 isPaused ?
48 "qrc:/images/icons/play_circle_outline-24px.svg" :
49 "qrc:/images/icons/pause_circle_outline-24px.svg",
50 function (){
51 CallAdapter.holdThisCallToggle()
52 })
53 ContextMenuGenerator.addMenuItem(qsTr("Sip Input Panel"),
54 "qrc:/images/icons/ic_keypad.svg",
55 function (){
56 sipInputPanel.open()
57 })
58 ContextMenuGenerator.addMenuItem(qsTr("Transfer call"),
59 "qrc:/images/icons/phone_forwarded-24px.svg",
60 function (){
61 root.transferCallButtonClicked()
62 })
63
64 ContextMenuGenerator.addMenuSeparator()
65 }
66
67 if (!isAudioOnly) {
68 ContextMenuGenerator.addMenuItem(isRecording ? qsTr("Stop recording") :
69 qsTr("Start recording"),
70 "qrc:/images/icons/ic_video_call_24px.svg",
71 function (){
72 CallAdapter.recordThisCallToggle()
73 })
74 ContextMenuGenerator.addMenuItem(videoCallPage.isFullscreen ? qsTr("Exit full screen") :
75 qsTr("Full screen mode"),
76 videoCallPage.isFullscreen ?
77 "qrc:/images/icons/close_fullscreen-24px.svg" :
78 "qrc:/images/icons/open_in_full-24px.svg",
79 function (){
80 videoCallPageRect.needToShowInFullScreen()
81 })
82
83 ContextMenuGenerator.addMenuSeparator()
84
85 generateDeviceMenuItem()
86
87 ContextMenuGenerator.addMenuSeparator()
88
89 ContextMenuGenerator.addMenuItem(qsTr("Share entire screen"),
90 "qrc:/images/icons/screen_share-24px.svg",
91 function (){
92 if (Qt.application.screens.length === 1) {
93 AvAdapter.shareEntireScreen(0)
94 } else {
95 SelectScreenWindowCreation.createSelectScreenWindowObject()
96 SelectScreenWindowCreation.showSelectScreenWindow()
97 }
98 })
99 ContextMenuGenerator.addMenuItem(qsTr("Share screen area"),
100 "qrc:/images/icons/screen_share-24px.svg",
101 function (){
102 if (Qt.application.screens.length === 1) {
103 ScreenRubberBandCreation.createScreenRubberBandWindowObject(
104 null, 0)
105 ScreenRubberBandCreation.showScreenRubberBandWindow()
106 } else {
107 SelectScreenWindowCreation.createSelectScreenWindowObject(true)
108 SelectScreenWindowCreation.showSelectScreenWindow()
109 }
110 })
111 ContextMenuGenerator.addMenuItem(qsTr("Share file"),
112 "qrc:/images/icons/insert_photo-24px.svg",
113 function (){
114 jamiFileDialog.open()
115 })
116 }
117
118 ContextMenuGenerator.addMenuItem(qsTr("Toggle plugin"),
119 "qrc:/images/icons/extension_24dp.svg",
120 function (){
121 root.pluginItemClicked()
122 })
123
124 root.height = ContextMenuGenerator.getMenu().height
125 root.width = ContextMenuGenerator.getMenu().width
126 ContextMenuGenerator.getMenu().open()
127 }
128
129 function generateDeviceMenuItem() {
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400130 var deviceContextMenuInfoMap = AvAdapter.populateVideoDeviceContextMenuItem()
Ming Rui Zhang96808872020-08-27 12:59:09 -0400131
agsantosc5687502020-09-03 21:19:10 -0400132 // Somehow, the map size is undefined, so use this instead.
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400133 var mapSize = deviceContextMenuInfoMap["size"]
134
Ming Rui Zhang96808872020-08-27 12:59:09 -0400135 if (mapSize === 0)
136 VideoDeviceContextMenuItemCreation.createVideoDeviceContextMenuItemObjects(
137 qsTr("No video device"), false)
138
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400139 for (var deviceName in deviceContextMenuInfoMap) {
Ming Rui Zhang96808872020-08-27 12:59:09 -0400140 if (deviceName === "size")
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400141 continue
Ming Rui Zhang96808872020-08-27 12:59:09 -0400142 VideoDeviceContextMenuItemCreation.createVideoDeviceContextMenuItemObjects(
143 deviceName, deviceContextMenuInfoMap[deviceName])
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400144 }
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400145 }
146
147 JamiFileDialog {
148 id: jamiFileDialog
149
150 mode: JamiFileDialog.Mode.OpenFile
151
152 onAccepted: {
153 // No need to trim file:///.
154 AvAdapter.shareFile(jamiFileDialog.file)
155 }
156 }
157
Ming Rui Zhang96808872020-08-27 12:59:09 -0400158 Component.onCompleted: {
159 ContextMenuGenerator.createBaseContextMenuObjects(root)
160 VideoDeviceContextMenuItemCreation.setVideoContextMenuObject(ContextMenuGenerator.getMenu())
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400161
Ming Rui Zhang96808872020-08-27 12:59:09 -0400162 ContextMenuGenerator.getMenu().closed.connect(function (){
163 VideoDeviceContextMenuItemCreation.removeCreatedItems()
164 })
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400165 }
166
agsantosc5687502020-09-03 21:19:10 -0400167 // TODO: In the future we want to implement this
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400168
agsantosc5687502020-09-03 21:19:10 -0400169 // GeneralMenuItem {
170 // id: advancedInfosItem
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400171
agsantosc5687502020-09-03 21:19:10 -0400172 // itemName: qsTr("Advanced informations")
173 // iconSource: "qrc:/images/icons/info-24px.svg"
174 // leftBorderWidth: commonBorderWidth
175 // rightBorderWidth: commonBorderWidth
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400176
agsantosc5687502020-09-03 21:19:10 -0400177 // onClicked: {
178 // root.close()
179 // }
180 // }
Sébastien Blin8940f3c2020-07-23 17:03:11 -0400181}
182