agsantos | 655d8e2 | 2020-08-10 17:36:47 -0400 | [diff] [blame] | 1 | /** |
| 2 | * Copyright (C) 2020 by Savoir-faire Linux |
| 3 | * Author: Aline Gondim Santos <aline.gondimsantos@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 | */ |
| 18 | import QtQuick 2.14 |
| 19 | import QtQuick.Controls 2.14 |
| 20 | import QtQuick.Layouts 1.14 |
| 21 | import QtQuick.Controls.Universal 2.12 |
| 22 | import net.jami.Models 1.0 |
| 23 | |
| 24 | import "../../commoncomponents" |
| 25 | |
| 26 | Popup { |
| 27 | id: mediahandlerPickerPopup |
| 28 | |
| 29 | function toggleMediaHandlerSlot(mediaHandlerId, isLoaded) { |
| 30 | ClientWrapper.pluginModel.toggleCallMediaHandler(mediaHandlerId, !isLoaded) |
| 31 | mediahandlerPickerListView.model = MediaHandlerAdapter.getMediaHandlerSelectableModel() |
| 32 | } |
| 33 | |
| 34 | contentWidth: 350 |
| 35 | contentHeight: mediahandlerPickerPopupRectColumnLayout.height + 50 |
| 36 | |
| 37 | padding: 0 |
| 38 | |
| 39 | modal: true |
| 40 | |
| 41 | contentItem: Rectangle { |
| 42 | id: mediahandlerPickerPopupRect |
| 43 | |
| 44 | width: 250 |
| 45 | |
| 46 | HoverableButton { |
| 47 | id: closeButton |
| 48 | |
| 49 | anchors.top: mediahandlerPickerPopupRect.top |
| 50 | anchors.topMargin: 5 |
| 51 | anchors.right: mediahandlerPickerPopupRect.right |
| 52 | anchors.rightMargin: 5 |
| 53 | |
| 54 | width: 30 |
| 55 | height: 30 |
| 56 | |
| 57 | radius: 30 |
| 58 | source: "qrc:/images/icons/round-close-24px.svg" |
| 59 | |
| 60 | onClicked: { |
| 61 | mediahandlerPickerPopup.close() |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | ColumnLayout { |
| 66 | id: mediahandlerPickerPopupRectColumnLayout |
| 67 | |
| 68 | anchors.top: mediahandlerPickerPopupRect.top |
| 69 | anchors.topMargin: 15 |
| 70 | |
| 71 | Text { |
| 72 | id: mediahandlerPickerTitle |
| 73 | |
| 74 | Layout.alignment: Qt.AlignCenter |
| 75 | Layout.preferredWidth: mediahandlerPickerPopupRect.width |
| 76 | Layout.preferredHeight: 30 |
| 77 | |
| 78 | font.pointSize: JamiTheme.textFontSize |
| 79 | font.bold: true |
| 80 | |
| 81 | horizontalAlignment: Text.AlignHCenter |
| 82 | verticalAlignment: Text.AlignVCenter |
| 83 | |
| 84 | text: qsTr("Choose plugin") |
| 85 | } |
| 86 | |
| 87 | ListView { |
| 88 | id: mediahandlerPickerListView |
| 89 | |
| 90 | Layout.alignment: Qt.AlignCenter |
| 91 | Layout.preferredWidth: mediahandlerPickerPopupRect.width |
| 92 | Layout.preferredHeight: 200 |
| 93 | |
| 94 | model: MediaHandlerAdapter.getMediaHandlerSelectableModel() |
| 95 | |
| 96 | clip: true |
| 97 | |
| 98 | delegate: MediaHandlerItemDelegate { |
| 99 | id: mediaHandlerItemDelegate |
| 100 | visible: ClientWrapper.pluginModel.getPluginsEnabled() |
| 101 | width: mediahandlerPickerListView.width |
| 102 | height: 50 |
| 103 | |
| 104 | mediaHandlerName : MediaHandlerName |
| 105 | mediaHandlerId: MediaHandlerId |
| 106 | mediaHandlerIcon: MediaHandlerIcon |
| 107 | isLoaded: IsLoaded |
| 108 | |
| 109 | onBtnLoadMediaHandlerToggled: { |
| 110 | toggleMediaHandlerSlot(mediaHandlerId, isLoaded) |
| 111 | } |
| 112 | |
| 113 | } |
| 114 | |
| 115 | ScrollIndicator.vertical: ScrollIndicator {} |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | radius: 10 |
| 120 | color: "white" |
| 121 | } |
| 122 | |
| 123 | onAboutToShow: { |
| 124 | // Reset the model on each show. |
| 125 | mediahandlerPickerListView.model = MediaHandlerAdapter.getMediaHandlerSelectableModel() |
| 126 | } |
| 127 | |
| 128 | background: Rectangle { |
| 129 | color: "transparent" |
| 130 | } |
| 131 | } |