Debian Codegraph @

src/imports/Lomiri/Contacts/ContactListButtonDelegate.qml

raw
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.4
18 import Lomiri.Components 1.3
19
20 Item {
21 id: root
22
23 property string iconSource
24 property alias labelText: name.text
25 property bool expandIcon: false
26 property bool showContents: true
27 signal clicked()
28
29 anchors {
30 left: parent.left
31 right: parent.right
32 }
33 height: visible ? units.gu(8) : 0
34
35 Rectangle {
36 anchors.fill: parent
37 color: Theme.palette.selected.background
38 opacity: addNewContactButtonArea.pressed ? 1.0 : 0.0
39 }
40
41 LomiriShape {
42 id: uShape
43
44 anchors {
45 left: parent.left
46 top: parent.top
47 bottom: parent.bottom
48 margins: units.gu(1)
49 }
50 width: height
51 radius: "medium"
52 backgroundColor: Theme.palette.normal.overlay
53 source: Image {
54 source: root.expandIcon ? root.iconSource : ""
55 asynchronous: true
56 }
57 Image {
58 anchors.centerIn: parent
59 source: root.expandIcon ? "" : root.iconSource
60 visible: !root.expandIcon
61 width: units.gu(2)
62 height: units.gu(2)
63 asynchronous: true
64 }
65 visible: root.showContents
66 }
67
68 Label {
69 id: name
70
71 anchors {
72 left: uShape.right
73 leftMargin: units.gu(2)
74 verticalCenter: parent.verticalCenter
75 right: parent.right
76 rightMargin: units.gu(2)
77 }
78 elide: Text.ElideRight
79 visible: root.showContents
80 }
81
82 MouseArea {
83 id: addNewContactButtonArea
84
85 anchors.fill: parent
86 onClicked: root.clicked()
87 visible: root.showContents
88 }
89 }