Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 1 | /* |
| 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 Zhang | 9680887 | 2020-08-27 12:59:09 -0400 | [diff] [blame] | 18 | |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 19 | import QtQuick 2.14 |
| 20 | import QtQuick.Controls 2.14 |
| 21 | import net.jami.Models 1.0 |
| 22 | |
| 23 | import "../../commoncomponents" |
| 24 | |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 25 | /* |
Ming Rui Zhang | 9680887 | 2020-08-27 12:59:09 -0400 | [diff] [blame] | 26 | * Menu item wrapper for video device checkable item. |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 27 | */ |
| 28 | GeneralMenuItem { |
| 29 | id: videoCallPageContextMenuDeviceItem |
| 30 | |
| 31 | property int contextMenuPreferredWidth: 250 |
| 32 | |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 33 | TextMetrics { |
| 34 | id: textMetrics |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 35 | elide: Text.ElideMiddle |
| 36 | elideWidth: contextMenuPreferredWidth |
| 37 | - videoCallPageContextMenuDeviceItem.implicitIndicatorWidth |
| 38 | text: videoCallPageContextMenuDeviceItem.itemName |
| 39 | } |
| 40 | |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 41 | itemName: textMetrics.elidedText.length !== 0 ? |
| 42 | textMetrics.elidedText : |
| 43 | qsTr("No video device") |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 44 | |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 45 | indicator: null |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 46 | |
Sébastien Blin | 8940f3c | 2020-07-23 17:03:11 -0400 | [diff] [blame] | 47 | iconSource: videoCallPageContextMenuDeviceItem.checked ? |
| 48 | "qrc:/images/icons/check_box-24px.svg" : |
| 49 | "qrc:/images/icons/check_box_outline_blank-24px.svg" |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 50 | |
| 51 | onClicked: { |
| 52 | var deviceName = videoCallPageContextMenuDeviceItem.itemName |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 53 | AvAdapter.onVideoContextMenuDeviceItemClicked(deviceName) |
| 54 | } |
| 55 | } |