Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 1 | |
| 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 | */ |
| 19 | import QtQuick 2.14 |
| 20 | import QtQuick.Controls 2.14 |
ababi | df651a2 | 2020-07-30 13:38:57 +0200 | [diff] [blame] | 21 | import QtGraphicalEffects 1.12 |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 22 | import net.jami.Models 1.0 |
| 23 | |
| 24 | import "../../commoncomponents" |
| 25 | |
| 26 | Menu { |
| 27 | id: contextMenu |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 28 | property string responsibleAccountId: "" |
| 29 | property string responsibleConvUid: "" |
| 30 | |
| 31 | property int generalMenuSeparatorCount: 0 |
ababi | df651a2 | 2020-07-30 13:38:57 +0200 | [diff] [blame] | 32 | property int commonBorderWidth: 1 |
| 33 | font.pointSize: JamiTheme.menuFontSize |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 34 | |
ababi | df651a2 | 2020-07-30 13:38:57 +0200 | [diff] [blame] | 35 | 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 Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 49 | |
| 50 | /* |
| 51 | * All GeneralMenuItems should remain the same width / height. |
| 52 | */ |
| 53 | GeneralMenuItem { |
| 54 | id: startVideoCallItem |
| 55 | |
| 56 | itemName: qsTr("Start video call") |
ababi | df651a2 | 2020-07-30 13:38:57 +0200 | [diff] [blame] | 57 | iconSource: "qrc:/images/icons/ic_video_call_24px.svg" |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 58 | 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") |
ababi | df651a2 | 2020-07-30 13:38:57 +0200 | [diff] [blame] | 73 | iconSource: "qrc:/images/icons/ic_phone_24px.svg" |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 74 | 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") |
ababi | df651a2 | 2020-07-30 13:38:57 +0200 | [diff] [blame] | 89 | iconSource: "qrc:/images/icons/ic_clear_24px.svg" |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 90 | 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") |
ababi | df651a2 | 2020-07-30 13:38:57 +0200 | [diff] [blame] | 104 | iconSource: "qrc:/images/icons/round-remove_circle-24px.svg" |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 105 | 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") |
ababi | df651a2 | 2020-07-30 13:38:57 +0200 | [diff] [blame] | 128 | iconSource: "qrc:/images/icons/ic_block_24px.svg" |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 129 | 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") |
ababi | df651a2 | 2020-07-30 13:38:57 +0200 | [diff] [blame] | 152 | iconSource: "qrc:/images/icons/person-24px.svg" |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 153 | leftBorderWidth: commonBorderWidth |
| 154 | rightBorderWidth: commonBorderWidth |
| 155 | |
| 156 | onClicked: { |
| 157 | contextMenu.close() |
| 158 | userProfile.open() |
| 159 | } |
| 160 | } |
| 161 | |
ababi | df651a2 | 2020-07-30 13:38:57 +0200 | [diff] [blame] | 162 | GeneralMenuSeparator { |
| 163 | preferredWidth: startVideoCallItem.preferredWidth |
| 164 | preferredHeight: 8 |
| 165 | separatorColor: "transparent" |
| 166 | Component.onCompleted: { |
| 167 | generalMenuSeparatorCount++ |
| 168 | } |
| 169 | } |
| 170 | |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 171 | 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 | } |