blob: c5aa47138e798ce85618ff4d205ef1398d853649 [file] [log] [blame]
Sébastien Blin1f915762020-08-03 13:27:42 -04001/*
2 * Copyright (C) 2020 by Savoir-faire Linux
3 * Author: Mingrui Zhang <mingrui.zhang@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 */
Ming Rui Zhang96808872020-08-27 12:59:09 -040018
Sébastien Blin1f915762020-08-03 13:27:42 -040019import 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
Ming Rui Zhang96808872020-08-27 12:59:09 -040026import "../../commoncomponents/js/contextmenugenerator.js" as ContextMenuGenerator
27
28Item {
29 id: root
30
Sébastien Blin1f915762020-08-03 13:27:42 -040031 property string responsibleAccountId: ""
32 property string responsibleConvUid: ""
Ming Rui Zhang96808872020-08-27 12:59:09 -040033 property int contactType: Profile.Type.INVALID
Sébastien Blin1f915762020-08-03 13:27:42 -040034
ababidf651a22020-07-30 13:38:57 +020035 function openMenu(){
Ming Rui Zhang96808872020-08-27 12:59:09 -040036 ContextMenuGenerator.addMenuItem(qsTr("Start video call"),
37 "qrc:/images/icons/ic_video_call_24px.svg",
38 function (){
39 ConversationsAdapter.selectConversation(
40 responsibleAccountId,
41 responsibleConvUid, false)
42 CallAdapter.placeCall()
43 })
44 ContextMenuGenerator.addMenuItem(qsTr("Start audio call"),
45 "qrc:/images/icons/ic_phone_24px.svg",
46 function (){
47 ConversationsAdapter.selectConversation(
48 responsibleAccountId,
49 responsibleConvUid, false)
50 CallAdapter.placeAudioOnlyCall()
51 })
52 ContextMenuGenerator.addMenuItem(qsTr("Clear conversation"),
53 "qrc:/images/icons/ic_clear_24px.svg",
54 function (){
55 ClientWrapper.utilsAdaptor.clearConversationHistory(
56 responsibleAccountId,
57 responsibleConvUid)
58 })
ababidf651a22020-07-30 13:38:57 +020059
Ming Rui Zhang96808872020-08-27 12:59:09 -040060 if (contactType === Profile.Type.RING || contactType === Profile.Type.SIP) {
61 ContextMenuGenerator.addMenuItem(qsTr("Remove contact"),
62 "qrc:/images/icons/round-remove_circle-24px.svg",
63 function (){
64 ClientWrapper.utilsAdaptor.removeConversation(
65 responsibleAccountId,
66 responsibleConvUid)
67 })
ababidf651a22020-07-30 13:38:57 +020068 }
Sébastien Blin1f915762020-08-03 13:27:42 -040069
Ming Rui Zhang96808872020-08-27 12:59:09 -040070 if (contactType === Profile.Type.RING || contactType === Profile.Type.PENDING) {
71 ContextMenuGenerator.addMenuSeparator()
Sébastien Blin1f915762020-08-03 13:27:42 -040072
Ming Rui Zhang96808872020-08-27 12:59:09 -040073 if (contactType === Profile.Type.PENDING) {
74 ContextMenuGenerator.addMenuItem(qsTr("Accept request"),
75 "qrc:/images/icons/person_add-24px.svg",
76 function (){
77 MessagesAdapter.acceptInvitation(
78 responsibleConvUid)
79 })
80 ContextMenuGenerator.addMenuItem(qsTr("Decline request"),
81 "qrc:/images/icons/round-close-24px.svg",
82 function (){
83 MessagesAdapter.refuseInvitation(
84 responsibleConvUid)
85 })
86 }
87 ContextMenuGenerator.addMenuItem(qsTr("Block contact"),
88 "qrc:/images/icons/ic_block_24px.svg",
89 function (){
90 MessagesAdapter.blockConversation(
91 responsibleConvUid)
92 })
Sébastien Blin1f915762020-08-03 13:27:42 -040093
Ming Rui Zhang96808872020-08-27 12:59:09 -040094 ContextMenuGenerator.addMenuSeparator()
95 ContextMenuGenerator.addMenuItem(qsTr("Profile"),
96 "qrc:/images/icons/person-24px.svg",
97 function (){
98 userProfile.open()
99 })
Sébastien Blin1f915762020-08-03 13:27:42 -0400100 }
Ming Rui Zhang96808872020-08-27 12:59:09 -0400101
102 root.height = ContextMenuGenerator.getMenu().height
103 root.width = ContextMenuGenerator.getMenu().width
104 ContextMenuGenerator.getMenu().open()
Sébastien Blin1f915762020-08-03 13:27:42 -0400105 }
106
Ming Rui Zhang96808872020-08-27 12:59:09 -0400107 Component.onCompleted: {
108 ContextMenuGenerator.createBaseContextMenuObjects(root)
Sébastien Blin1f915762020-08-03 13:27:42 -0400109 }
110}