Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2019-2020 by Savoir-faire Linux |
| 3 | * Author: Yang Wang <yang.wang@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 <http://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | |
| 19 | import QtQuick 2.15 |
| 20 | import QtQuick.Window 2.15 |
| 21 | import QtQuick.Controls 2.15 |
| 22 | import QtQuick.Controls.Universal 2.12 |
| 23 | import QtQuick.Layouts 1.3 |
| 24 | import QtGraphicalEffects 1.14 |
| 25 | import QtQuick.Controls.Styles 1.4 |
| 26 | import net.jami.Models 1.0 |
| 27 | |
| 28 | import "../../commoncomponents" |
| 29 | |
| 30 | ItemDelegate { |
| 31 | id: pluginItemDelegate |
| 32 | |
| 33 | property string pluginName : "" |
| 34 | property string pluginId: "" |
| 35 | property string pluginIcon: "" |
| 36 | property bool isLoaded: false |
| 37 | |
| 38 | signal btnLoadPluginToggled |
| 39 | signal btnPreferencesPluginClicked |
| 40 | |
| 41 | highlighted: ListView.isCurrentItem |
| 42 | |
| 43 | RowLayout{ |
| 44 | anchors.fill: parent |
| 45 | |
| 46 | Label{ |
| 47 | Layout.leftMargin: 7 |
| 48 | Layout.bottomMargin: 7 |
| 49 | |
| 50 | Layout.minimumWidth: 30 |
| 51 | Layout.preferredWidth: 30 |
| 52 | Layout.maximumWidth: 30 |
| 53 | |
| 54 | Layout.minimumHeight: 30 |
| 55 | Layout.preferredHeight: 30 |
| 56 | Layout.maximumHeight: 30 |
| 57 | |
| 58 | background: Rectangle{ |
| 59 | anchors.fill: parent |
| 60 | Image { |
| 61 | anchors.fill: parent |
| 62 | source: "file:"+pluginIcon |
| 63 | } |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | ColumnLayout{ |
| 68 | Layout.fillWidth: true |
| 69 | Layout.fillHeight: true |
| 70 | |
| 71 | Layout.leftMargin: 7 |
| 72 | Layout.topMargin: 7 |
| 73 | Layout.bottomMargin: 7 |
| 74 | |
| 75 | RowLayout{ |
| 76 | |
| 77 | Layout.minimumHeight: 30 |
| 78 | |
| 79 | Label{ |
| 80 | id: labelDeviceId |
| 81 | |
| 82 | Layout.minimumHeight: 20 |
| 83 | |
| 84 | font.pointSize: 10 |
| 85 | font.kerning: true |
| 86 | text: pluginName === "" ? pluginId : pluginName |
| 87 | } |
| 88 | |
| 89 | Item{ |
| 90 | Layout.fillWidth: true |
| 91 | |
| 92 | Layout.minimumWidth: 0 |
| 93 | Layout.minimumHeight: 20 |
| 94 | } |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | Switch { |
| 99 | id: loadSwitch |
| 100 | property bool isHovering: false |
| 101 | |
| 102 | Layout.bottomMargin: 7 |
| 103 | Layout.rightMargin: 15 |
| 104 | |
| 105 | Layout.maximumWidth: 30 |
| 106 | Layout.preferredWidth: 30 |
| 107 | Layout.minimumWidth: 30 |
| 108 | |
| 109 | Layout.minimumHeight: 30 |
| 110 | Layout.preferredHeight: 30 |
| 111 | Layout.maximumHeight: 30 |
| 112 | |
| 113 | ToolTip.visible: isHovering |
| 114 | ToolTip.text: { |
| 115 | return qsTr("Load/Unload") |
| 116 | } |
| 117 | |
| 118 | checked: isLoaded |
| 119 | onClicked: { |
| 120 | btnLoadPluginToggled() |
| 121 | } |
| 122 | |
| 123 | background: Rectangle { |
| 124 | id: switchBackground |
| 125 | MouseArea { |
| 126 | id: btnMouseArea |
| 127 | anchors.fill: parent |
| 128 | hoverEnabled: true |
| 129 | onPressed: { |
| 130 | } |
| 131 | onReleased: { |
| 132 | loadSwitch.clicked() |
| 133 | } |
| 134 | onEntered: { |
| 135 | loadSwitch.isHovering = true |
| 136 | } |
| 137 | onExited: { |
| 138 | loadSwitch.isHovering = false |
| 139 | } |
| 140 | } |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | HoverableRadiusButton{ |
| 145 | id: btnPreferencesPlugin |
| 146 | |
| 147 | Layout.bottomMargin: 7 |
| 148 | Layout.rightMargin: 7 |
| 149 | Layout.alignment: Qt.AlignRight |
| 150 | |
| 151 | Layout.minimumWidth: 30 |
| 152 | Layout.preferredWidth: 30 |
| 153 | Layout.maximumWidth: 30 |
| 154 | |
| 155 | Layout.minimumHeight: 30 |
| 156 | Layout.preferredHeight: 30 |
| 157 | Layout.maximumHeight: 30 |
| 158 | |
| 159 | buttonImageHeight: height |
| 160 | buttonImageWidth: height |
| 161 | |
| 162 | source:{ |
| 163 | return "qrc:/images/icons/round-settings-24px.svg" |
| 164 | } |
| 165 | |
| 166 | ToolTip.visible: isHovering |
| 167 | ToolTip.text: { |
| 168 | return qsTr("Edit preferences") |
| 169 | } |
| 170 | |
| 171 | onClicked: { |
| 172 | btnPreferencesPluginClicked() |
| 173 | } |
| 174 | } |
| 175 | } |
| 176 | } |