Dekko
Loading...
Searching...
No Matches
Avatar.qml
1/* Copyright (C) 2016 - 2017 Dan Chapman <dpniel@ubuntu.com>
2
3 This file is part of Dekko email client for Ubuntu devices
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License as
7 published by the Free Software Foundation; either version 2 of
8 the License or (at your option) version 3
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*/
18import QtQuick 2.4
19import QtQuick.Controls.Suru 2.2
20import Lomiri.Components 1.3
21import Dekko.Components 1.0
22import Dekko.Mail.Settings 1.0
23import Dekko.Lomiri.Constants 1.0
24import "./private/UiUtils.js" as UiUtils
25
26PixelPerfectItem {
27 id: avatar
28 property string name
29 property string initials
30 property string email
31 property string radius: "small"
32 property bool validContact: true
33 property string fontSize: "large"
34
35 height: units.gu(6)
36 width: height
37 Component {
38 id: component_inner_av
39 LomiriShape {
40 id: avatarCircle
41 anchors.fill: parent
42 anchors.centerIn: parent
43 aspect: LomiriShape.Flat
44 radius: avatar.radius
45 backgroundColor: UiUtils.getIconColor(name)
46 visible: validContact
47 //name: "avatar-circle"
48 Label {
49 id: initialsLabel
50 color: Suru.backgroundColor
51 text: validContact ? initials : ""
52 anchors.centerIn: parent
53 fontSize: avatar.fontSize
54 }
55
56 Icon {
57 id: contactIcon
58 name: "contact"
59 anchors.centerIn: parent
60 height: parent.height - Style.defaultSpacing
61 width: height
62 color: Suru.backgroundColor
63 visible: !initialsLabel.text
64 }
65 }
66 }
67 Loader {
68 id: loader_inner_av
69 anchors.fill: parent
70 active: !inner_name.visible
71 sourceComponent: component_inner_av
72 }
74 id: inner_name
75 radius: avatar.radius
76 emailAddress: validContact && PolicyManager.views.gravatarEnabled ? email : ""
77 clip: true
78 anchors.fill: parent
79 visible: status === Image.Ready
80 }
81}
82