Warning, /pim/kube/views/composer/qml/AddresseeListEditor.qml is written in an unsupported language. File is not indexed.
0001 /*
0002 * Copyright (C) 2017 Michael Bohlender, <michael.bohlender@kdemail.net>
0003 * Copyright (C) 2017 Christian Mollekopf, <mollekopf@kolabsys.com>
0004 *
0005 * This program is free software; you can redistribute it and/or modify
0006 * it under the terms of the GNU General Public License as published by
0007 * the Free Software Foundation; either version 2 of the License, or
0008 * (at your option) any later version.
0009 *
0010 * This program is distributed in the hope that it will be useful,
0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0013 * GNU General Public License for more details.
0014 *
0015 * You should have received a copy of the GNU General Public License along
0016 * with this program; if not, write to the Free Software Foundation, Inc.,
0017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
0018 */
0019
0020
0021 import QtQuick 2.7
0022 import QtQuick.Layouts 1.1
0023 import QtQuick.Controls 2.2
0024
0025 import org.kube.framework 1.0 as Kube
0026
0027 FocusScope {
0028 id: root
0029 property var controller
0030 property var completer
0031 property bool encrypt: false
0032 property alias label: heading.text
0033
0034 implicitHeight: heading.height + listView.contentHeight + lineEdit.height + 2 * Kube.Units.smallSpacing
0035
0036 DropArea {
0037 anchors.fill: parent
0038
0039 Rectangle {
0040 anchors.fill: parent
0041 color: Kube.Colors.highlightColor
0042 opacity: 0.3
0043 visible: parent.containsDrag
0044 }
0045
0046 onDropped: {
0047 drop.accept(Qt.MoveAction)
0048 root.controller.add({name: drop.source.name})
0049 }
0050 }
0051
0052 ColumnLayout {
0053 anchors.fill: parent
0054
0055 spacing: Kube.Units.smallSpacing
0056
0057 Kube.Label {
0058 id: heading
0059 }
0060
0061 Kube.ListView {
0062 id: listView
0063 Layout.fillHeight: true
0064 Layout.fillWidth: true
0065
0066 contentHeight: contentItem.childrenRect.height
0067 spacing: Kube.Units.smallSpacing
0068 model: controller.model
0069 delegate: Rectangle {
0070 id: delegateRoot
0071 property var recipientId: model.id
0072 property var name: model.name
0073 height: Kube.Units.gridUnit + Kube.Units.smallSpacing * 2 //smallSpacing for padding
0074 width: ListView.view.availableWidth
0075 color: Kube.Colors.buttonColor
0076
0077 MouseArea {
0078 id: mouseArea
0079 anchors.fill: parent
0080 hoverEnabled: true
0081 drag.target: parent
0082 drag.filterChildren: true
0083 drag.axis: "YAxis"
0084 onReleased: {
0085 if (parent.Drag.drop() == Qt.MoveAction) {
0086 root.controller.remove(recipientId)
0087 }
0088 }
0089 }
0090
0091 states: [
0092 State {
0093 name: "dnd"
0094 when: mouseArea.drag.active
0095
0096 PropertyChanges {target: mouseArea; cursorShape: Qt.ClosedHandCursor}
0097 PropertyChanges {target: delegateRoot; opacity: 0.5}
0098 ParentChange {target: delegateRoot; parent: recipients; x: x; y: y}
0099 }
0100 ]
0101
0102 Drag.active: mouseArea.drag.active
0103 Drag.hotSpot.x: mouseArea.mouseX
0104 Drag.hotSpot.y: mouseArea.mouseY
0105 Drag.source: delegateRoot
0106
0107 Kube.Label {
0108 id: label
0109 anchors {
0110 verticalCenter: parent.verticalCenter
0111 left: parent.left
0112 right: keyIcon.left
0113 margins: Kube.Units.smallSpacing
0114 }
0115 text: model.name
0116 elide: Text.ElideRight
0117 ToolTip.visible: mouseArea.containsMouse && !mouseArea.drag.active
0118 ToolTip.text: text
0119 }
0120 Kube.IconButton {
0121 id: keyIcon
0122 anchors {
0123 verticalCenter: parent.verticalCenter
0124 right: removeButton.left
0125 }
0126 height: Kube.Units.gridUnit
0127 width: visible ? height : 0
0128 padding: 0
0129 visible: root.encrypt && !model.fetching
0130 iconName: model.keyFound ? Kube.Icons.secure: (hovered ? Kube.Icons.save : Kube.Icons.insecure)
0131 enabled: !model.keyFound
0132 tooltip: qsTr("Fetch key from keyserver")
0133 onClicked: root.controller.fetchKeys(model.id, model.name)
0134 }
0135 Kube.Icon {
0136 visible: model.fetching
0137 anchors {
0138 verticalCenter: parent.verticalCenter
0139 right: removeButton.left
0140 }
0141 height: Kube.Units.gridUnit
0142 iconName: Kube.Icons.busy
0143 }
0144 Kube.IconButton {
0145 id: removeButton
0146 anchors {
0147 right: parent.right
0148 verticalCenter: parent.verticalCenter
0149 margins: Kube.Units.smallSpacing
0150 }
0151 height: Kube.Units.gridUnit
0152 width: height
0153 onClicked: root.controller.remove(model.id)
0154 padding: 0
0155 iconName: Kube.Icons.remove
0156 }
0157
0158 }
0159 }
0160
0161 FocusScope {
0162 Layout.fillWidth: true
0163 height: Kube.Units.gridUnit + Kube.Units.smallSpacing * 2
0164 focus: true
0165
0166 Kube.TextButton {
0167 id: button
0168 text: "+ " + qsTr("Add recipient")
0169 textColor: Kube.Colors.highlightColor
0170 focus: true
0171 onClicked: {
0172 lineEdit.visible = true
0173 lineEdit.forceActiveFocus()
0174 }
0175 }
0176
0177 Kube.AutocompleteLineEdit {
0178 id: lineEdit
0179 anchors {
0180 left: parent.left
0181 right: parent.right
0182 }
0183 visible: false
0184
0185 placeholderText: "+ " + qsTr("Add recipient")
0186 model: root.completer.model
0187 onSearchTermChanged: root.completer.searchString = searchTerm
0188 onAccepted: {
0189 root.controller.add({name: text});
0190 clear()
0191 visible = false
0192 button.forceActiveFocus(Qt.TabFocusReason)
0193 }
0194 onAborted: {
0195 clear()
0196 visible = false
0197 button.forceActiveFocus(Qt.TabFocusReason)
0198 }
0199 }
0200 }
0201 }
0202 }