blob: fb49a46874d47574a5bc0cdbfe6eacdb4fab4e23 [file] [log] [blame]
Sébastien Blin6607e0e2020-07-24 15:15:47 -04001/*
2 * Copyright (C) 2020 by Savoir-faire Linux
3 * Author: Sébastien Blin <sebastien.blin@savoirfairelinux.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18import QtQuick 2.14
19import QtQuick.Controls 2.14
20import QtQuick.Layouts 1.14
21import QtQuick.Controls.Universal 2.12
22import QtGraphicalEffects 1.14
23import net.jami.Models 1.0
24
25import "../../commoncomponents"
26
27Rectangle {
28 id: root
29
30 property int buttonPreferredSize: 12
31 property var uri: ""
32 property var active: true
33 property var isLocal: true
34 property var injectedContextMenu: null
35
36 function setParticipantName(name) {
37 participantName.text = name
38 }
39
40 function setMenuVisible(isVisible) {
41 optionsButton.visible = isVisible
42 }
43
44 border.width: 1
45 opacity: 0
46 color: "transparent"
47 z: 1
48
49 MouseArea {
50 id: mouseAreaHover
51 anchors.fill: parent
52 hoverEnabled: true
53 propagateComposedEvents: true
54 acceptedButtons: Qt.LeftButton
55
56 RowLayout {
57 id: bottomLabel
58
59 height: 24
60 width: parent.width
61 anchors.bottom: parent.bottom
62
63 Rectangle {
64 color: "black"
65 opacity: 0.8
66 height: parent.height
67 width: parent.width
68 Layout.fillWidth: true
69 Layout.preferredHeight: parent.height
70
71 Text {
72 id: participantName
73 anchors.fill: parent
74 leftPadding: 8.0
75
76 TextMetrics {
77 id: participantMetrics
78 elide: Text.ElideRight
79 elideWidth: bottomLabel.width - 8
80 }
81
82 text: participantMetrics.elidedText
83
84 color: "white"
85 font.pointSize: JamiTheme.textFontSize
86 horizontalAlignment: Text.AlignLeft
87 verticalAlignment: Text.AlignVCenter
88 }
89
90 Button {
91 id: optionsButton
92
93 anchors.right: parent.right
94 anchors.verticalCenter: parent.verticalCenter
95
96 background: Rectangle {
97 color: "transparent"
98 }
99
100
101 icon.color: "white"
102 icon.height: buttonPreferredSize
103 icon.width: buttonPreferredSize
104 icon.source: "qrc:/images/icons/more_vert-24px.svg"
105
106 onClicked: {
107 if (!injectedContextMenu) {
108 console.log("Participant's overlay don't have any injected context menu")
109 return
110 }
111 var mousePos = mapToItem(videoCallPageRect, parent.x, parent.y)
112 var layout = CallAdapter.getCurrentLayoutType()
113 var showMaximized = layout !== 2
114 var showMinimized = !(layout === 0 || (layout === 1 && !active))
115 injectedContextMenu.showHangup(!root.isLocal)
116 injectedContextMenu.showMaximize(showMaximized)
117 injectedContextMenu.showMinimize(showMinimized)
118 injectedContextMenu.setHeight(
119 (root.isLocal ? 0 : 1)
120 + (showMaximized ? 1 : 0)
121 + (showMinimized ? 1 : 0))
122 injectedContextMenu.uri = uri
123 injectedContextMenu.active = active
124 injectedContextMenu.x = mousePos.x
125 injectedContextMenu.y = mousePos.y - injectedContextMenu.height
126 injectedContextMenu.open()
127 }
128 }
129 }
130 }
131
132 onClicked: {
133 CallAdapter.maximizeParticipant(uri, active)
134 }
135
136 onEntered: {
137 root.state = "entered"
138 }
139
140 onExited: {
141 root.state = "exited"
142 }
143 }
144
145 states: [
146 State {
147 name: "entered"
148 PropertyChanges {
149 target: root
150 opacity: 1
151 }
152 },
153 State {
154 name: "exited"
155 PropertyChanges {
156 target: root
157 opacity: 0
158 }
159 }
160 ]
161
162 transitions: Transition {
163 PropertyAnimation {
164 target: root
165 property: "opacity"
166 duration: 500
167 }
168 }
169}