blob: 26c5406f22734d38db7ea11f5ef6e2ebc1a01029 [file] [log] [blame]
Sébastien Blin1f915762020-08-03 13:27:42 -04001
2/*
3 * Copyright (C) 2020 by Savoir-faire Linux
4 * Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19import QtQuick 2.14
20import QtQuick.Controls 2.14
ababidf651a22020-07-30 13:38:57 +020021import QtGraphicalEffects 1.12
Sébastien Blin1f915762020-08-03 13:27:42 -040022import net.jami.Models 1.0
23
24import "../../commoncomponents"
25
26Menu {
27 id: contextMenu
Sébastien Blin1f915762020-08-03 13:27:42 -040028 property string responsibleAccountId: ""
29 property string responsibleConvUid: ""
30
31 property int generalMenuSeparatorCount: 0
ababidf651a22020-07-30 13:38:57 +020032 property int commonBorderWidth: 1
33 font.pointSize: JamiTheme.menuFontSize
Sébastien Blin1f915762020-08-03 13:27:42 -040034
ababidf651a22020-07-30 13:38:57 +020035 function openMenu(){
36 visible = true
37 visible = false
38 visible = true
39 }
40
41 GeneralMenuSeparator {
42 preferredWidth: startVideoCallItem.preferredWidth
43 preferredHeight: 8
44 separatorColor: "transparent"
45 Component.onCompleted: {
46 generalMenuSeparatorCount++
47 }
48 }
Sébastien Blin1f915762020-08-03 13:27:42 -040049
50 /*
51 * All GeneralMenuItems should remain the same width / height.
52 */
53 GeneralMenuItem {
54 id: startVideoCallItem
55
56 itemName: qsTr("Start video call")
ababidf651a22020-07-30 13:38:57 +020057 iconSource: "qrc:/images/icons/ic_video_call_24px.svg"
Sébastien Blin1f915762020-08-03 13:27:42 -040058 leftBorderWidth: commonBorderWidth
59 rightBorderWidth: commonBorderWidth
60
61 onClicked: {
62 contextMenu.close()
63 ConversationsAdapter.selectConversation(responsibleAccountId,
64 responsibleConvUid, false)
65 CallAdapter.placeCall()
66 }
67 }
68
69 GeneralMenuItem {
70 id: startAudioCallItem
71
72 itemName: qsTr("Start audio call")
ababidf651a22020-07-30 13:38:57 +020073 iconSource: "qrc:/images/icons/ic_phone_24px.svg"
Sébastien Blin1f915762020-08-03 13:27:42 -040074 leftBorderWidth: commonBorderWidth
75 rightBorderWidth: commonBorderWidth
76
77 onClicked: {
78 contextMenu.close()
79 ConversationsAdapter.selectConversation(responsibleAccountId,
80 responsibleConvUid, false)
81 CallAdapter.placeAudioOnlyCall()
82 }
83 }
84
85 GeneralMenuItem {
86 id: clearConversationItem
87
88 itemName: qsTr("Clear conversation")
ababidf651a22020-07-30 13:38:57 +020089 iconSource: "qrc:/images/icons/ic_clear_24px.svg"
Sébastien Blin1f915762020-08-03 13:27:42 -040090 leftBorderWidth: commonBorderWidth
91 rightBorderWidth: commonBorderWidth
92
93 onClicked: {
94 contextMenu.close()
95 ClientWrapper.utilsAdaptor.clearConversationHistory(responsibleAccountId,
96 responsibleConvUid)
97 }
98 }
99
100 GeneralMenuItem {
101 id: removeContactItem
102
103 itemName: qsTr("Remove contact")
ababidf651a22020-07-30 13:38:57 +0200104 iconSource: "qrc:/images/icons/round-remove_circle-24px.svg"
Sébastien Blin1f915762020-08-03 13:27:42 -0400105 leftBorderWidth: commonBorderWidth
106 rightBorderWidth: commonBorderWidth
107
108 onClicked: {
109 contextMenu.close()
110 ClientWrapper.utilsAdaptor.removeConversation(responsibleAccountId,
111 responsibleConvUid)
112 }
113 }
114
115 GeneralMenuSeparator {
116 preferredWidth: startVideoCallItem.preferredWidth
117 preferredHeight: commonBorderWidth
118
119 Component.onCompleted: {
120 generalMenuSeparatorCount++
121 }
122 }
123
124 GeneralMenuItem {
125 id: blockContactItem
126
127 itemName: qsTr("Block contact")
ababidf651a22020-07-30 13:38:57 +0200128 iconSource: "qrc:/images/icons/ic_block_24px.svg"
Sébastien Blin1f915762020-08-03 13:27:42 -0400129 leftBorderWidth: commonBorderWidth
130 rightBorderWidth: commonBorderWidth
131
132 onClicked: {
133 contextMenu.close()
134 ClientWrapper.utilsAdaptor.removeConversation(responsibleAccountId,
135 responsibleConvUid, true)
136 }
137 }
138
139 GeneralMenuSeparator {
140 preferredWidth: startVideoCallItem.preferredWidth
141 preferredHeight: commonBorderWidth
142
143 Component.onCompleted: {
144 generalMenuSeparatorCount++
145 }
146 }
147
148 GeneralMenuItem {
149 id: profileItem
150
151 itemName: qsTr("Profile")
ababidf651a22020-07-30 13:38:57 +0200152 iconSource: "qrc:/images/icons/person-24px.svg"
Sébastien Blin1f915762020-08-03 13:27:42 -0400153 leftBorderWidth: commonBorderWidth
154 rightBorderWidth: commonBorderWidth
155
156 onClicked: {
157 contextMenu.close()
158 userProfile.open()
159 }
160 }
161
ababidf651a22020-07-30 13:38:57 +0200162 GeneralMenuSeparator {
163 preferredWidth: startVideoCallItem.preferredWidth
164 preferredHeight: 8
165 separatorColor: "transparent"
166 Component.onCompleted: {
167 generalMenuSeparatorCount++
168 }
169 }
170
Sébastien Blin1f915762020-08-03 13:27:42 -0400171 background: Rectangle {
172 implicitWidth: startVideoCallItem.preferredWidth
173 implicitHeight: startVideoCallItem.preferredHeight
174 * (contextMenu.count - generalMenuSeparatorCount)
175
176 border.width: commonBorderWidth
177 border.color: JamiTheme.tabbarBorderColor
178 }
179}