Debian Codegraph @

src/imports/Lomiri/AddressBook/ContactView/ContactDetailAvatarView.qml

raw ◀ ▶
1 Debian patch touch this file
1 /*
2 * Copyright (C) 2012-2015 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17 import QtQuick 2.12
18 import QtGraphicalEffects 1.0
19 import QtContacts 5.0
20 import Lomiri.Components 1.3
21
22 import Lomiri.Contacts 0.1
23 import Lomiri.AddressBook.Base 0.1
24
25 ContactDetailBase {
26 id: root
27
28 property alias editable: favImage.enabled
•29 property var constituents: []
30
31 implicitHeight: units.gu(12)
32 implicitWidth: parent.width
33 activeFocusOnTab: false
34
35 Connections {
36 id: connections
37
38 target: avatar.contactElement
39 ignoreUnknownSignals: true
40 function onContactChanged() { avatar.reload() }
41 }
42
43 Image {
44 id: imageBg
45
46 source: avatar.avatarUrl
47 anchors.fill: parent
48 fillMode: Image.PreserveAspectCrop
49 visible: false
50 asynchronous: true
51 autoTransform: true
52
53 OpacityMask {
54 source: mask
55 maskSource: imageBg
56 }
57
58 LinearGradient {
59 id: mask
60 anchors.fill: parent
61 start: Qt.point(0, 0)
62 end: Qt.point(imageBg.x + imageBg.width, 0)
63 gradient: Gradient {
64 GradientStop { position: 0.2; color: "transparent"}
65 GradientStop { position: 1.0; color: theme.palette.normal.background }
66 }
67 }
68
69 }
70
71 FastBlur {
72 anchors.fill: imageBg
73 source: imageBg
74 radius: 32
75 visible: avatar.avatarUrl !== avatar.fallbackAvatarUrl
76 }
77
78 ContactAvatar {
79 id: avatar
80 objectName: "contactAvatarDetail"
81
82 contactElement: root.contact
83 height: units.gu(8)
84 width: height
85
86 anchors {
87 left: parent.left
88 verticalCenter: parent.verticalCenter
89 leftMargin: units.gu(2)
90 }
91
92 }
93
94 ActionButton {
95 id: favImage
96 objectName: "contactFavoriteDetail"
97
98 iconName: root.contact && root.contact.favorite.favorite ? "starred" : "non-starred"
99 height: units.gu(4)
100 visible: root.editable || (root.contact && root.contact.favorite.favorite)
101 iconSize: units.gu(3)
102 width: height
103 anchors {
104 right: parent.right
105 rightMargin: units.gu(2)
106 verticalCenter: parent.verticalCenter
107 }
108
109 onClicked: {
•110 for (var i = 0; i < constituents.length; i++) {
111 var constituent = constituents[i]
112 constituent.favorite.favorite = !root.contact.favorite.favorite
113 constituent.save()
114 }
115 }
116 }
117 }