agsantos | c568750 | 2020-09-03 21:19:10 -0400 | [diff] [blame] | 1 | /* |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 2 | * Copyright (C) 2020 by Savoir-faire Linux |
| 3 | * Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com> |
| 4 | * Author: Sébastien Blin <sebastien.blin@savoirfairelinux.com> |
agsantos | 655d8e2 | 2020-08-10 17:36:47 -0400 | [diff] [blame] | 5 | * Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com> |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 6 | * |
| 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 Zhang | 9680887 | 2020-08-27 12:59:09 -0400 | [diff] [blame] | 20 | |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 21 | import QtQuick 2.14 |
| 22 | import QtQuick.Controls 2.14 |
| 23 | import QtGraphicalEffects 1.12 |
| 24 | import net.jami.Models 1.0 |
| 25 | |
| 26 | import "../../commoncomponents" |
| 27 | |
Ming Rui Zhang | 9680887 | 2020-08-27 12:59:09 -0400 | [diff] [blame] | 28 | import "../../commoncomponents/js/contextmenugenerator.js" as ContextMenuGenerator |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 29 | import "../js/videodevicecontextmenuitemcreation.js" as VideoDeviceContextMenuItemCreation |
| 30 | import "../js/selectscreenwindowcreation.js" as SelectScreenWindowCreation |
Ming Rui Zhang | 9680887 | 2020-08-27 12:59:09 -0400 | [diff] [blame] | 31 | import "../js/screenrubberbandcreation.js" as ScreenRubberBandCreation |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 32 | |
Ming Rui Zhang | 9680887 | 2020-08-27 12:59:09 -0400 | [diff] [blame] | 33 | Item { |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 34 | id: root |
| 35 | |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 36 | property bool isSIP: false |
| 37 | property bool isPaused: false |
| 38 | property bool isAudioOnly: false |
| 39 | property bool isRecording: false |
| 40 | |
Ming Rui Zhang | 9680887 | 2020-08-27 12:59:09 -0400 | [diff] [blame] | 41 | signal pluginItemClicked |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 42 | signal transferCallButtonClicked |
| 43 | |
Ming Rui Zhang | 9680887 | 2020-08-27 12:59:09 -0400 | [diff] [blame] | 44 | 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 Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 130 | var deviceContextMenuInfoMap = AvAdapter.populateVideoDeviceContextMenuItem() |
Ming Rui Zhang | 9680887 | 2020-08-27 12:59:09 -0400 | [diff] [blame] | 131 | |
agsantos | c568750 | 2020-09-03 21:19:10 -0400 | [diff] [blame] | 132 | // Somehow, the map size is undefined, so use this instead. |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 133 | var mapSize = deviceContextMenuInfoMap["size"] |
| 134 | |
Ming Rui Zhang | 9680887 | 2020-08-27 12:59:09 -0400 | [diff] [blame] | 135 | if (mapSize === 0) |
| 136 | VideoDeviceContextMenuItemCreation.createVideoDeviceContextMenuItemObjects( |
| 137 | qsTr("No video device"), false) |
| 138 | |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 139 | for (var deviceName in deviceContextMenuInfoMap) { |
Ming Rui Zhang | 9680887 | 2020-08-27 12:59:09 -0400 | [diff] [blame] | 140 | if (deviceName === "size") |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 141 | continue |
Ming Rui Zhang | 9680887 | 2020-08-27 12:59:09 -0400 | [diff] [blame] | 142 | VideoDeviceContextMenuItemCreation.createVideoDeviceContextMenuItemObjects( |
| 143 | deviceName, deviceContextMenuInfoMap[deviceName]) |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 144 | } |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 145 | } |
| 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 Zhang | 9680887 | 2020-08-27 12:59:09 -0400 | [diff] [blame] | 158 | Component.onCompleted: { |
| 159 | ContextMenuGenerator.createBaseContextMenuObjects(root) |
| 160 | VideoDeviceContextMenuItemCreation.setVideoContextMenuObject(ContextMenuGenerator.getMenu()) |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 161 | |
Ming Rui Zhang | 9680887 | 2020-08-27 12:59:09 -0400 | [diff] [blame] | 162 | ContextMenuGenerator.getMenu().closed.connect(function (){ |
| 163 | VideoDeviceContextMenuItemCreation.removeCreatedItems() |
| 164 | }) |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 165 | } |
| 166 | |
agsantos | c568750 | 2020-09-03 21:19:10 -0400 | [diff] [blame] | 167 | // TODO: In the future we want to implement this |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 168 | |
agsantos | c568750 | 2020-09-03 21:19:10 -0400 | [diff] [blame] | 169 | // GeneralMenuItem { |
| 170 | // id: advancedInfosItem |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 171 | |
agsantos | c568750 | 2020-09-03 21:19:10 -0400 | [diff] [blame] | 172 | // itemName: qsTr("Advanced informations") |
| 173 | // iconSource: "qrc:/images/icons/info-24px.svg" |
| 174 | // leftBorderWidth: commonBorderWidth |
| 175 | // rightBorderWidth: commonBorderWidth |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 176 | |
agsantos | c568750 | 2020-09-03 21:19:10 -0400 | [diff] [blame] | 177 | // onClicked: { |
| 178 | // root.close() |
| 179 | // } |
| 180 | // } |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 181 | } |
| 182 | |