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 |
| 21 | import net.jami.Models 1.0 |
| 22 | |
| 23 | import "../../commoncomponents" |
| 24 | |
| 25 | |
| 26 | /* |
| 27 | * Take advantage of child can access parent's item (ex: contextMenu, commonBorderWidth). |
| 28 | */ |
| 29 | GeneralMenuItem { |
| 30 | id: videoCallPageContextMenuDeviceItem |
| 31 | |
| 32 | property int contextMenuPreferredWidth: 250 |
| 33 | |
| 34 | itemName: qsTr("No video device") |
| 35 | leftBorderWidth: commonBorderWidth |
| 36 | rightBorderWidth: commonBorderWidth |
| 37 | |
| 38 | TextMetrics { |
| 39 | id: textMetrics |
| 40 | font: deviceNameText.font |
| 41 | elide: Text.ElideMiddle |
| 42 | elideWidth: contextMenuPreferredWidth |
| 43 | - videoCallPageContextMenuDeviceItem.implicitIndicatorWidth |
| 44 | text: videoCallPageContextMenuDeviceItem.itemName |
| 45 | } |
| 46 | |
| 47 | contentItem: Text { |
| 48 | id: deviceNameText |
| 49 | |
| 50 | leftPadding: 30 |
| 51 | rightPadding: videoCallPageContextMenuDeviceItem.arrow.width |
| 52 | |
| 53 | horizontalAlignment: Text.AlignLeft |
| 54 | verticalAlignment: Text.AlignVCenter |
| 55 | |
| 56 | font.pointSize: JamiTheme.textFontSize - 3 |
| 57 | text: textMetrics.elidedText |
| 58 | } |
| 59 | |
| 60 | indicator: Item { |
| 61 | id: selectItem |
| 62 | |
| 63 | anchors.left: parent.left |
| 64 | anchors.verticalCenter: parent.verticalCenter |
| 65 | |
| 66 | implicitWidth: 32 |
| 67 | implicitHeight: 32 |
| 68 | |
| 69 | Rectangle { |
| 70 | id: selectRect |
| 71 | |
| 72 | width: selectItem.width / 2 |
| 73 | height: selectItem.height / 2 |
| 74 | anchors.centerIn: parent |
| 75 | visible: videoCallPageContextMenuDeviceItem.checkable |
| 76 | border.color: JamiTheme.selectionGreen |
| 77 | radius: 3 |
| 78 | Rectangle { |
| 79 | width: selectRect.width / 2 |
| 80 | height: selectRect.height / 2 |
| 81 | anchors.centerIn: parent |
| 82 | visible: videoCallPageContextMenuDeviceItem.checked |
| 83 | color: JamiTheme.selectionGreen |
| 84 | radius: 2 |
| 85 | } |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | onClicked: { |
| 90 | var deviceName = videoCallPageContextMenuDeviceItem.itemName |
| 91 | contextMenu.close() |
| 92 | AvAdapter.onVideoContextMenuDeviceItemClicked(deviceName) |
| 93 | } |
| 94 | } |